@Test synchronized public void testBind() throws Exception { Field mListenersField = mBluetoothManager.getClass().getDeclaredField("mListeners"); mListenersField.setAccessible(true); CopyOnWriteArrayList<BluetoothManager.BluetoothManagerListener> myListeners = new CopyOnWriteArrayList<>(); mListenersField.set(mBluetoothManager, myListeners); assertThat("should be true as it is bound successfully", mBluetoothManager.bind(mMockBluetoothManagerListener), is(true)); verify(mMockContext, times(1)).registerReceiver( any(BroadcastReceiver.class), any(IntentFilter.class)); assertThat("should be equal as listener is added", myListeners.get(0), is(mMockBluetoothManagerListener)); assertThat("should be true as it is already bound successfully", mBluetoothManager.bind(mMockBluetoothManagerListener), is(true)); reset(mMockContext); verify(mMockContext, never()).registerReceiver( any(BroadcastReceiver.class), any(IntentFilter.class)); }
public synchronized boolean bind(BluetoothManagerListener listener) { if (!mListeners.contains(listener)) { Log.i(TAG, "bind: Binding a new listener"); mListeners.add(listener); } return initialize(); }
BluetoothManager { public synchronized boolean bind(BluetoothManagerListener listener) { if (!mListeners.contains(listener)) { Log.i(TAG, "bind: Binding a new listener"); mListeners.add(listener); } return initialize(); } }
BluetoothManager { public synchronized boolean bind(BluetoothManagerListener listener) { if (!mListeners.contains(listener)) { Log.i(TAG, "bind: Binding a new listener"); mListeners.add(listener); } return initialize(); } private  BluetoothManager(Context context); private  BluetoothManager(Context context, BluetoothAdapter bluetoothAdapter,
                             SharedPreferences sharedPreferences); }
BluetoothManager { public synchronized boolean bind(BluetoothManagerListener listener) { if (!mListeners.contains(listener)) { Log.i(TAG, "bind: Binding a new listener"); mListeners.add(listener); } return initialize(); } private  BluetoothManager(Context context); private  BluetoothManager(Context context, BluetoothAdapter bluetoothAdapter,
                             SharedPreferences sharedPreferences); static BluetoothManager getInstance(Context context); static BluetoothManager getInstance(Context context, BluetoothAdapter bluetoothAdapter,
                                               SharedPreferences sharedPreferences); synchronized boolean bind(BluetoothManagerListener listener); synchronized void release(BluetoothManagerListener listener); boolean isBluetoothSupported(); boolean isBleSupported(); @TargetApi(21) FeatureSupportedStatus isBleMultipleAdvertisementSupported(); @TargetApi(21) FeatureSupportedStatus isBleOffloadedScanBatchingSupported(); @TargetApi(21) FeatureSupportedStatus isBleOffloadedFilteringSupported(); boolean isBluetoothEnabled(); boolean setBluetoothEnabled(boolean enable); BluetoothAdapter getBluetoothAdapter(); String getBluetoothMacAddress(); String getBluetoothName(); BluetoothDevice getRemoteDevice(String address); }
BluetoothManager { public synchronized boolean bind(BluetoothManagerListener listener) { if (!mListeners.contains(listener)) { Log.i(TAG, "bind: Binding a new listener"); mListeners.add(listener); } return initialize(); } private  BluetoothManager(Context context); private  BluetoothManager(Context context, BluetoothAdapter bluetoothAdapter,
                             SharedPreferences sharedPreferences); static BluetoothManager getInstance(Context context); static BluetoothManager getInstance(Context context, BluetoothAdapter bluetoothAdapter,
                                               SharedPreferences sharedPreferences); synchronized boolean bind(BluetoothManagerListener listener); synchronized void release(BluetoothManagerListener listener); boolean isBluetoothSupported(); boolean isBleSupported(); @TargetApi(21) FeatureSupportedStatus isBleMultipleAdvertisementSupported(); @TargetApi(21) FeatureSupportedStatus isBleOffloadedScanBatchingSupported(); @TargetApi(21) FeatureSupportedStatus isBleOffloadedFilteringSupported(); boolean isBluetoothEnabled(); boolean setBluetoothEnabled(boolean enable); BluetoothAdapter getBluetoothAdapter(); String getBluetoothMacAddress(); String getBluetoothName(); BluetoothDevice getRemoteDevice(String address);  }