From bd0716ba580c27a1c85f6193a5fa6999865ba7c8 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Mon, 23 Nov 2015 23:04:46 +0100 Subject: [PATCH] Some more lint warnings fixed --- .../activities/AbstractFragmentPagerAdapter.java | 2 +- .../activities/AbstractSettingsActivity.java | 4 ++-- .../activities/AppBlacklistActivity.java | 2 +- .../activities/AppManagerActivity.java | 2 +- .../gadgetbridge/activities/DebugActivity.java | 2 +- .../gadgetbridge/activities/DiscoveryActivity.java | 10 +++++----- .../activities/FwAppInstallerActivity.java | 4 ++-- .../activities/charts/AbstractChartFragment.java | 6 +++--- .../activities/charts/ChartsActivity.java | 2 +- .../activities/charts/LiveActivityFragment.java | 4 ++-- .../devices/miband/MiBandPairingActivity.java | 2 +- .../devices/miband/MiBandSampleProvider.java | 2 +- .../gadgetbridge/devices/miband/MiBandService.java | 2 +- .../gadgetbridge/devices/miband/UserInfo.java | 14 +++++++------- .../devices/miband/VibrationProfile.java | 4 ++-- .../devices/pebble/MisfitSampleProvider.java | 2 +- .../gadgetbridge/devices/pebble/STM32CRC.java | 2 +- .../externalevents/NotificationListener.java | 4 +--- .../freeyourgadget/gadgetbridge/impl/GBAlarm.java | 2 +- .../gadgetbridge/impl/GBDeviceCandidate.java | 4 ++-- .../gadgetbridge/model/ActivityAmount.java | 2 +- .../gadgetbridge/model/ActivityAmounts.java | 2 +- .../service/DeviceCommunicationService.java | 2 +- .../gadgetbridge/service/DeviceSupportFactory.java | 2 +- .../service/btle/AbstractBTLEDeviceSupport.java | 2 +- .../gadgetbridge/service/btle/BtLEQueue.java | 10 +++++----- .../service/btle/GattCharacteristic.java | 2 +- .../gadgetbridge/service/btle/GattService.java | 2 +- .../gadgetbridge/service/btle/Transaction.java | 6 +++--- .../service/btle/TransactionBuilder.java | 2 +- .../service/btle/actions/SetProgressAction.java | 6 +++--- .../service/btle/actions/WaitAction.java | 2 +- .../service/btle/actions/WriteAction.java | 2 +- .../service/devices/miband/AbstractInfo.java | 2 +- .../service/devices/miband/MiBandSupport.java | 4 ++-- .../miband/operations/FetchActivityOperation.java | 4 ++-- .../service/devices/pebble/PebbleIoThread.java | 3 ++- .../service/devices/pebble/PebbleProtocol.java | 6 +++--- .../gadgetbridge/util/DeviceHelper.java | 2 +- .../service/AbstractServiceTestCase.java | 2 +- .../gadgetbridge/test/GBMockIntent.java | 2 +- 41 files changed, 71 insertions(+), 72 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractFragmentPagerAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractFragmentPagerAdapter.java index a811992e1..dd98b49a3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractFragmentPagerAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractFragmentPagerAdapter.java @@ -8,7 +8,7 @@ import java.util.HashSet; import java.util.Set; public abstract class AbstractFragmentPagerAdapter extends FragmentStatePagerAdapter { - private Set fragments = new HashSet<>(); + private final Set fragments = new HashSet<>(); private Object primaryFragment; public AbstractFragmentPagerAdapter(FragmentManager fm) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractSettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractSettingsActivity.java index 26ccfe0a4..d12fee966 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractSettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractSettingsActivity.java @@ -56,7 +56,7 @@ public abstract class AbstractSettingsActivity extends PreferenceActivity { } private static class ExtraSetSummaryOnChangeListener extends SimpleSetSummaryOnChangeListener { - private Preference.OnPreferenceChangeListener delegate; + private final Preference.OnPreferenceChangeListener delegate; public ExtraSetSummaryOnChangeListener(Preference.OnPreferenceChangeListener delegate) { this.delegate = delegate; @@ -72,7 +72,7 @@ public abstract class AbstractSettingsActivity extends PreferenceActivity { } } - private static SimpleSetSummaryOnChangeListener sBindPreferenceSummaryToValueListener = new SimpleSetSummaryOnChangeListener(); + private static final SimpleSetSummaryOnChangeListener sBindPreferenceSummaryToValueListener = new SimpleSetSummaryOnChangeListener(); @Override protected void onPostCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppBlacklistActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppBlacklistActivity.java index 371572dba..b3ead6b14 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppBlacklistActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppBlacklistActivity.java @@ -35,7 +35,7 @@ import nodomain.freeyourgadget.gadgetbridge.R; public class AppBlacklistActivity extends Activity { private static final Logger LOG = LoggerFactory.getLogger(AppBlacklistActivity.class); - private BroadcastReceiver mReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java index a47244748..b219b0654 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java @@ -37,7 +37,7 @@ public class AppManagerActivity extends Activity { = "nodomain.freeyourgadget.gadgetbridge.appmanager.action.refresh_applist"; private static final Logger LOG = LoggerFactory.getLogger(AppManagerActivity.class); - private BroadcastReceiver mReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java index 76c8b2102..8c30bd969 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java @@ -50,7 +50,7 @@ public class DebugActivity extends Activity { private Button importDBButton; private EditText editContent; - private BroadcastReceiver mReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(ControlCenter.ACTION_QUIT)) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java index 53268827c..192eebbe3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java @@ -36,9 +36,9 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli private static final Logger LOG = LoggerFactory.getLogger(DiscoveryActivity.class); private static final long SCAN_DURATION = 60000; // 60s - private Handler handler = new Handler(); + private final Handler handler = new Handler(); - private BroadcastReceiver bluetoothReceiver = new BroadcastReceiver() { + private final BroadcastReceiver bluetoothReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { @@ -78,14 +78,14 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli } }; - private BluetoothAdapter.LeScanCallback leScanCallback = new BluetoothAdapter.LeScanCallback() { + private final BluetoothAdapter.LeScanCallback leScanCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) { handleDeviceFound(device, (short) rssi); } }; - private Runnable stopRunnable = new Runnable() { + private final Runnable stopRunnable = new Runnable() { @Override public void run() { stopDiscovery(); @@ -94,7 +94,7 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli private ProgressBar progressView; private BluetoothAdapter adapter; - private ArrayList deviceCandidates = new ArrayList<>(); + private final ArrayList deviceCandidates = new ArrayList<>(); private DeviceCandidateAdapter cadidateListAdapter; private Button startButton; private Scanning isScanning = Scanning.SCANNING_OFF; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java index 74df6ecb2..19a457862 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java @@ -45,7 +45,7 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity private InstallHandler installHandler; private boolean mayConnect; - private BroadcastReceiver mReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); @@ -72,7 +72,7 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity }; private ProgressBar mProgressBar; private ListView itemListView; - private List mItems = new ArrayList<>(); + private final List mItems = new ArrayList<>(); private ItemWithDetailsAdapter mItemAdapter; private void refreshBusyState(GBDevice dev) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java index 254bb177b..61afd2792 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java @@ -60,12 +60,12 @@ import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper; * shift the date by one day. */ public abstract class AbstractChartFragment extends AbstractGBFragment { - protected int ANIM_TIME = 350; + protected final int ANIM_TIME = 350; private static final Logger LOG = LoggerFactory.getLogger(AbstractChartFragment.class); private final Set mIntentFilterActions; - private BroadcastReceiver mReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { AbstractChartFragment.this.onReceive(context, intent); @@ -82,7 +82,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment { protected static final class ActivityConfig { public final int type; public final String label; - public Integer color; + public final Integer color; public ActivityConfig(int kind, String label, Integer color) { this.type = kind; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ChartsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ChartsActivity.java index 58f4848b5..c3c755026 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ChartsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ChartsActivity.java @@ -80,7 +80,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts } } - private BroadcastReceiver mReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java index cbd4e8eab..2e9d29b98 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java @@ -60,7 +60,7 @@ public class LiveActivityFragment extends AbstractChartFragment { private CustomBarChart mStepsPerMinuteCurrentChart; private CustomBarChart mTotalStepsChart; - private Steps mSteps = new Steps(); + private final Steps mSteps = new Steps(); private ScheduledExecutorService pulseScheduler; private int maxStepsResetCounter; @@ -140,7 +140,7 @@ public class LiveActivityFragment extends AbstractChartFragment { } } - private BroadcastReceiver mReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandPairingActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandPairingActivity.java index 1049f9d8b..5ae009bad 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandPairingActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandPairingActivity.java @@ -26,7 +26,7 @@ public class MiBandPairingActivity extends Activity { private TextView message; private boolean isPairing; private String macAddress; - private BroadcastReceiver mPairingReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mPairingReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (GBDevice.ACTION_DEVICE_CHANGED.equals(intent.getAction())) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandSampleProvider.java index a2fc1dc76..95026cb07 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandSampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandSampleProvider.java @@ -20,7 +20,7 @@ public class MiBandSampleProvider implements SampleProvider { // public static final byte TYPE_WALKING = 1; // maybe this should be configurable 256 seems way off, though. - private float movementDivisor = 180.0f; //256.0f; + private final float movementDivisor = 180.0f; //256.0f; @Override public int normalizeType(byte rawType) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandService.java index 6ce3e26e9..d3e33cc4b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandService.java @@ -207,7 +207,7 @@ public class MiBandService { */ - private static Map MIBAND_DEBUG; + private static final Map MIBAND_DEBUG; static { MIBAND_DEBUG = new HashMap<>(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/UserInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/UserInfo.java index f14515308..cccb2d7ba 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/UserInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/UserInfo.java @@ -10,13 +10,13 @@ import java.util.Arrays; */ public class UserInfo { - private String btAddress; - private String alias; - private int gender; - private int age; - private int height; - private int weight; - private int type; + private final String btAddress; + private final String alias; + private final int gender; + private final int age; + private final int height; + private final int weight; + private final int type; private byte[] data = new byte[20]; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/VibrationProfile.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/VibrationProfile.java index 136f3515e..97dfc4e63 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/VibrationProfile.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/VibrationProfile.java @@ -40,8 +40,8 @@ public class VibrationProfile { private final String id; - private int[] onOffSequence; - private short repeat; + private final int[] onOffSequence; + private final short repeat; /** * Creates a new profile instance. diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/MisfitSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/MisfitSampleProvider.java index 4723c04a2..608f97712 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/MisfitSampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/MisfitSampleProvider.java @@ -4,7 +4,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; public class MisfitSampleProvider implements SampleProvider { - protected float movementDivisor = 300f; + protected final float movementDivisor = 300f; @Override public int normalizeType(byte rawType) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/STM32CRC.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/STM32CRC.java index 465d81ffd..ac1c6de33 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/STM32CRC.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/STM32CRC.java @@ -14,7 +14,7 @@ import java.nio.ByteOrder; public class STM32CRC { private int crc; private byte rem; - private byte buffer[] = {0, 0, 0, 0}; + private final byte[] buffer = {0, 0, 0, 0}; private static final int[] crc_table = { 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java index 5f0a82bc7..deec40347 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -1,7 +1,6 @@ package nodomain.freeyourgadget.gadgetbridge.externalevents; import android.annotation.SuppressLint; -import android.annotation.TargetApi; import android.app.ActivityManager; import android.app.Notification; import android.app.PendingIntent; @@ -12,7 +11,6 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; -import android.os.Build; import android.os.Bundle; import android.os.PowerManager; import android.preference.PreferenceManager; @@ -41,7 +39,7 @@ public class NotificationListener extends NotificationListenerService { public static final String ACTION_MUTE = "nodomain.freeyourgadget.gadgetbridge.notificationlistener.action.mute"; - private BroadcastReceiver mReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @SuppressLint("NewApi") @Override public void onReceive(Context context, Intent intent) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBAlarm.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBAlarm.java index bca028cd0..d0178e4cf 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBAlarm.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBAlarm.java @@ -18,7 +18,7 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PR public class GBAlarm implements Alarm { - private int index; + private final int index; private boolean enabled; private boolean smartWakeup; private int repetition; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceCandidate.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceCandidate.java index 3e7bc210b..d07556360 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceCandidate.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceCandidate.java @@ -14,8 +14,8 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; * support this candidate, will the candidate be promoted to a GBDevice. */ public class GBDeviceCandidate implements Parcelable { - private BluetoothDevice device; - private short rssi; + private final BluetoothDevice device; + private final short rssi; private DeviceType deviceType = DeviceType.UNKNOWN; public GBDeviceCandidate(BluetoothDevice device, short rssi) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityAmount.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityAmount.java index b2be2d405..17a2873c7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityAmount.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityAmount.java @@ -5,7 +5,7 @@ import android.content.Context; import nodomain.freeyourgadget.gadgetbridge.R; public class ActivityAmount { - private int activityKind; + private final int activityKind; private short percent; private long totalSeconds; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityAmounts.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityAmounts.java index 6566d8fa6..fb98d2bb5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityAmounts.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityAmounts.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; public class ActivityAmounts { - private List amounts = new ArrayList<>(4); + private final List amounts = new ArrayList<>(4); private long totalSeconds; public void addAmount(ActivityAmount amount) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java index 022fa3e13..e9539d689 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java @@ -93,7 +93,7 @@ public class DeviceCommunicationService extends Service { private MusicPlaybackReceiver mMusicPlaybackReceiver = null; private TimeChangeReceiver mTimeChangeReceiver = null; - private BroadcastReceiver mReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java index 62259e5e3..b79812719 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java @@ -18,7 +18,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB; public class DeviceSupportFactory { private final BluetoothAdapter mBtAdapter; - private Context mContext; + private final Context mContext; public DeviceSupportFactory(Context context) { mContext = context; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/AbstractBTLEDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/AbstractBTLEDeviceSupport.java index d06116acb..051c8ce61 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/AbstractBTLEDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/AbstractBTLEDeviceSupport.java @@ -33,7 +33,7 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im private BtLEQueue mQueue; private HashMap mAvailableCharacteristics; - private Set mSupportedServices = new HashSet<>(4); + private final Set mSupportedServices = new HashSet<>(4); public static final String BASE_UUID = "0000%s-0000-1000-8000-00805f9b34fb"; //this is common for all BTLE devices. see http://stackoverflow.com/questions/18699251/finding-out-android-bluetooth-le-gatt-profiles diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java index d97ac8c89..b5f3125df 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java @@ -31,8 +31,8 @@ public final class BtLEQueue { private static final Logger LOG = LoggerFactory.getLogger(BtLEQueue.class); private final Object mGattMonitor = new Object(); - private GBDevice mGbDevice; - private BluetoothAdapter mBluetoothAdapter; + private final GBDevice mGbDevice; + private final BluetoothAdapter mBluetoothAdapter; private BluetoothGatt mBluetoothGatt; /** * When an automatic reconnect was attempted after a connection breakdown (error) @@ -41,12 +41,12 @@ public final class BtLEQueue { private static final long MIN_MILLIS_BEFORE_RECONNECT = 1000 * 60 * 5; // 5 minutes - private volatile BlockingQueue mTransactions = new LinkedBlockingQueue<>(); + private final BlockingQueue mTransactions = new LinkedBlockingQueue<>(); private volatile boolean mDisposed; private volatile boolean mCrashed; private volatile boolean mAbortTransaction; - private Context mContext; + private final Context mContext; private CountDownLatch mWaitForActionResultLatch; private CountDownLatch mConnectionLatch; private BluetoothGattCharacteristic mWaitCharacteristic; @@ -284,7 +284,7 @@ public final class BtLEQueue { private @Nullable GattCallback mTransactionGattCallback; - private GattCallback mExternalGattCallback; + private final GattCallback mExternalGattCallback; public InternalGattCallback(GattCallback externalGattCallback) { mExternalGattCallback = externalGattCallback; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/GattCharacteristic.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/GattCharacteristic.java index 2d45d69f9..afbd9ee6d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/GattCharacteristic.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/GattCharacteristic.java @@ -178,7 +178,7 @@ public class GattCharacteristic { //do we need this? - private static Map GATTCHARACTERISTIC_DEBUG; + private static final Map GATTCHARACTERISTIC_DEBUG; static { GATTCHARACTERISTIC_DEBUG = new HashMap<>(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/GattService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/GattService.java index 9c55e6b10..7ff1a10be 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/GattService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/GattService.java @@ -43,7 +43,7 @@ public class GattService { //do we need this? - private static Map GATTSERVICE_DEBUG; + private static final Map GATTSERVICE_DEBUG; static { GATTSERVICE_DEBUG = new HashMap<>(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/Transaction.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/Transaction.java index 1fccb5287..abd05d255 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/Transaction.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/Transaction.java @@ -16,9 +16,9 @@ import java.util.Locale; * @author TREND */ public class Transaction { - private String mName; - private List mActions = new ArrayList<>(4); - private long creationTimestamp = System.currentTimeMillis(); + private final String mName; + private final List mActions = new ArrayList<>(4); + private final long creationTimestamp = System.currentTimeMillis(); private @Nullable GattCallback gattCallback; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/TransactionBuilder.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/TransactionBuilder.java index 09d6b1b87..597e0422c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/TransactionBuilder.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/TransactionBuilder.java @@ -14,7 +14,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction; public class TransactionBuilder { private static final Logger LOG = LoggerFactory.getLogger(TransactionBuilder.class); - private Transaction mTransaction; + private final Transaction mTransaction; private boolean mQueued; public TransactionBuilder(String taskName) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/SetProgressAction.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/SetProgressAction.java index 8312b5fd1..f4a58bebc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/SetProgressAction.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/SetProgressAction.java @@ -7,9 +7,9 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB; public class SetProgressAction extends PlainAction { - private String text; - private boolean ongoing; - private int percentage; + private final String text; + private final boolean ongoing; + private final int percentage; private final Context context; /** diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/WaitAction.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/WaitAction.java index 77e233fc0..d2b74d917 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/WaitAction.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/WaitAction.java @@ -4,7 +4,7 @@ import android.bluetooth.BluetoothGatt; public class WaitAction extends PlainAction { - private int mMillis; + private final int mMillis; public WaitAction(int millis) { mMillis = millis; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/WriteAction.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/WriteAction.java index a16747138..b4ec95489 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/WriteAction.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/WriteAction.java @@ -13,7 +13,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction; */ public class WriteAction extends BtLEAction { - private byte[] value; + private final byte[] value; public WriteAction(BluetoothGattCharacteristic characteristic, byte[] value) { super(characteristic); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/AbstractInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/AbstractInfo.java index c68d135f4..e60a47b97 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/AbstractInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/AbstractInfo.java @@ -1,7 +1,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.miband; public class AbstractInfo { - protected byte[] mData; + protected final byte[] mData; public AbstractInfo(byte[] data) { mData = new byte[data.length]; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBandSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBandSupport.java index 832957fd7..342a42320 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBandSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBandSupport.java @@ -78,8 +78,8 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport { private DeviceInfo mDeviceInfo; - GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo(); - GBDeviceEventBatteryInfo batteryCmd = new GBDeviceEventBatteryInfo(); + private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo(); + private final GBDeviceEventBatteryInfo batteryCmd = new GBDeviceEventBatteryInfo(); public MiBandSupport() { addSupportedService(GattService.UUID_SERVICE_GENERIC_ACCESS); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java index 66c183019..ab448543e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java @@ -50,13 +50,13 @@ public class FetchActivityOperation extends AbstractBTLEOperation //private ScheduledExecutorService scheduleTaskExecutor; //private ScheduledFuture scheduledTask; - private int activityMetadataLength = 11; + private final int activityMetadataLength = 11; //temporary buffer, size is a multiple of 60 because we want to store complete minutes (1 minute = 3 bytes) private static final int activityDataHolderSize = 3 * 60 * 4; // 4h private static class ActivityStruct { - private byte[] activityDataHolder = new byte[activityDataHolderSize]; + private final byte[] activityDataHolder = new byte[activityDataHolderSize]; //index of the buffer above private int activityDataHolderProgress = 0; //number of bytes we will get in a single data transfer, used as counter diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java index 24c48c098..63e2121fe 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java @@ -56,7 +56,7 @@ public class PebbleIoThread extends GBDeviceIoThread { public static final String PEBBLEKIT_ACTION_APP_START = "com.getpebble.action.app.START"; public static final String PEBBLEKIT_ACTION_APP_STOP = "com.getpebble.action.app.STOP"; - SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); private final PebbleProtocol mPebbleProtocol; private final PebbleSupport mPebbleSupport; @@ -419,6 +419,7 @@ public class PebbleIoThread extends GBDeviceIoThread { mOutStream.flush(); } } catch (IOException e) { + LOG.error("Error writing.", e); } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index 2c1a2a405..bcc962a4d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -228,7 +228,7 @@ public class PebbleProtocol extends GBDeviceProtocol { "snowy_evt2", "snowy_dvt", "spalding_dvt", "snowy_s3", "spalding" }; - private static Random mRandom = new Random(); + private static final Random mRandom = new Random(); boolean isFw3x = false; boolean mForceProtocol = false; @@ -327,14 +327,14 @@ public class PebbleProtocol extends GBDeviceProtocol { byte last_id = -1; - private ArrayList tmpUUIDS = new ArrayList<>(); + private final ArrayList tmpUUIDS = new ArrayList<>(); private static final UUID UUID_GBPEBBLE = UUID.fromString("61476764-7465-7262-6469-656775527a6c"); private static final UUID UUID_MORPHEUZ = UUID.fromString("5be44f1d-d262-4ea6-aa30-ddbec1e3cab2"); private static final UUID UUID_WHETHERNEAT = UUID.fromString("3684003b-a685-45f9-a713-abc6364ba051"); private static final UUID UUID_MISFIT = UUID.fromString("0b73b76a-cd65-4dc2-9585-aaa213320858"); - private static Map mAppMessageHandlers = new HashMap<>(); + private static final Map mAppMessageHandlers = new HashMap<>(); { mAppMessageHandlers.put(UUID_GBPEBBLE, new AppMessageHandlerGBPebble(UUID_GBPEBBLE, PebbleProtocol.this)); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java index 4f77db3d6..9f997d9e9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java @@ -13,7 +13,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; public class DeviceHelper { - private static DeviceHelper instance = new DeviceHelper(); + private static final DeviceHelper instance = new DeviceHelper(); public static DeviceHelper getInstance() { return instance; diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractServiceTestCase.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractServiceTestCase.java index ea82165d3..c7ba649fe 100644 --- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractServiceTestCase.java +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractServiceTestCase.java @@ -19,7 +19,7 @@ import nodomain.freeyourgadget.gadgetbridge.test.MockHelper; public abstract class AbstractServiceTestCase { private static final int ID = -1; // currently not supported - private Class mServiceClass; + private final Class mServiceClass; private T mServiceInstance; private Context mContext; private Application mApplication; diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/GBMockIntent.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/GBMockIntent.java index a6bb9857a..667e44977 100644 --- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/GBMockIntent.java +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/GBMockIntent.java @@ -12,7 +12,7 @@ import java.util.Map; public class GBMockIntent extends Intent { private String mAction; - private Map extras = new HashMap<>(); + private final Map extras = new HashMap<>(); @NonNull @Override