@Test public void testStartBluetoothDeviceDiscovery_success() throws Exception { EnumSet<BlePeerDiscoverer.BlePeerDiscovererStateSet> mStateSet = EnumSet.of(BlePeerDiscoverer.BlePeerDiscovererStateSet.NOT_STARTED); when(mMockBlePeerDiscoverer.getState()).thenReturn(mStateSet); when(mMockBluetoothAdapter.isDiscovering()).thenReturn(true); assertThat("Returns true if bt discovery is started", mBluetoothMacAddressResolutionHelper.startBluetoothDeviceDiscovery(), is(equalTo(true))); verify(mMockDiscoveryManager, times(1)) .getBlePeerDiscovererInstanceAndCheckBluetoothMacAddress(); verify(mMockBlePeerDiscoverer, times(1)).stopScanner(); assertThat("Returns true if bt discovery is started", mBluetoothMacAddressResolutionHelper.startBluetoothDeviceDiscovery(), is(equalTo(true))); verify(mMockDiscoveryManager, times(2)). getBlePeerDiscovererInstanceAndCheckBluetoothMacAddress(); verify(mMockBlePeerDiscoverer, times(2)).stopScanner(); }
public synchronized boolean startBluetoothDeviceDiscovery() { Log.d(TAG, "startBluetoothDeviceDiscovery"); BlePeerDiscoverer blePeerDiscoverer = mDiscoveryManager.getBlePeerDiscovererInstanceAndCheckBluetoothMacAddress(); blePeerDiscoverer.stopScanner(); if (mBluetoothDeviceDiscoverer == null) { mBluetoothDeviceDiscoverer = new BluetoothDeviceDiscoverer(mContext, mBluetoothAdapter, this); } boolean isStarted = false; if (blePeerDiscoverer == null || !blePeerDiscoverer.getState().contains(BlePeerDiscoverer.BlePeerDiscovererStateSet.SCANNING)) { isStarted = (mBluetoothDeviceDiscoverer.isRunning() || mBluetoothDeviceDiscoverer.start(mSettings.getProvideBluetoothMacAddressTimeout())); } else { Log.e(TAG, "startBluetoothDeviceDiscovery: Bluetooth LE peer discoverer cannot be running, when doing Bluetooth LE scanning"); } return isStarted; }
BluetoothMacAddressResolutionHelper implements BluetoothDeviceDiscoverer.BluetoothDeviceDiscovererListener,
                   BluetoothGattManager.BluetoothGattManagerListener { public synchronized boolean startBluetoothDeviceDiscovery() { Log.d(TAG, "startBluetoothDeviceDiscovery"); BlePeerDiscoverer blePeerDiscoverer = mDiscoveryManager.getBlePeerDiscovererInstanceAndCheckBluetoothMacAddress(); blePeerDiscoverer.stopScanner(); if (mBluetoothDeviceDiscoverer == null) { mBluetoothDeviceDiscoverer = new BluetoothDeviceDiscoverer(mContext, mBluetoothAdapter, this); } boolean isStarted = false; if (blePeerDiscoverer == null || !blePeerDiscoverer.getState().contains(BlePeerDiscoverer.BlePeerDiscovererStateSet.SCANNING)) { isStarted = (mBluetoothDeviceDiscoverer.isRunning() || mBluetoothDeviceDiscoverer.start(mSettings.getProvideBluetoothMacAddressTimeout())); } else { Log.e(TAG, "startBluetoothDeviceDiscovery: Bluetooth LE peer discoverer cannot be running, when doing Bluetooth LE scanning"); } return isStarted; } }
BluetoothMacAddressResolutionHelper implements BluetoothDeviceDiscoverer.BluetoothDeviceDiscovererListener,
                   BluetoothGattManager.BluetoothGattManagerListener { public synchronized boolean startBluetoothDeviceDiscovery() { Log.d(TAG, "startBluetoothDeviceDiscovery"); BlePeerDiscoverer blePeerDiscoverer = mDiscoveryManager.getBlePeerDiscovererInstanceAndCheckBluetoothMacAddress(); blePeerDiscoverer.stopScanner(); if (mBluetoothDeviceDiscoverer == null) { mBluetoothDeviceDiscoverer = new BluetoothDeviceDiscoverer(mContext, mBluetoothAdapter, this); } boolean isStarted = false; if (blePeerDiscoverer == null || !blePeerDiscoverer.getState().contains(BlePeerDiscoverer.BlePeerDiscovererStateSet.SCANNING)) { isStarted = (mBluetoothDeviceDiscoverer.isRunning() || mBluetoothDeviceDiscoverer.start(mSettings.getProvideBluetoothMacAddressTimeout())); } else { Log.e(TAG, "startBluetoothDeviceDiscovery: Bluetooth LE peer discoverer cannot be running, when doing Bluetooth LE scanning"); } return isStarted; } BluetoothMacAddressResolutionHelper(
            Context context, BluetoothAdapter bluetoothAdapter, DiscoveryManager discoveryManager,
            UUID bleServiceUuid, UUID provideBluetoothMacAddressRequestUuid);  BluetoothMacAddressResolutionHelper(
            Context context, BluetoothAdapter bluetoothAdapter, DiscoveryManager discoveryManager,
            UUID bleServiceUuid, UUID provideBluetoothMacAddressRequestUuid, SharedPreferences preferences); }
BluetoothMacAddressResolutionHelper implements BluetoothDeviceDiscoverer.BluetoothDeviceDiscovererListener,
                   BluetoothGattManager.BluetoothGattManagerListener { public synchronized boolean startBluetoothDeviceDiscovery() { Log.d(TAG, "startBluetoothDeviceDiscovery"); BlePeerDiscoverer blePeerDiscoverer = mDiscoveryManager.getBlePeerDiscovererInstanceAndCheckBluetoothMacAddress(); blePeerDiscoverer.stopScanner(); if (mBluetoothDeviceDiscoverer == null) { mBluetoothDeviceDiscoverer = new BluetoothDeviceDiscoverer(mContext, mBluetoothAdapter, this); } boolean isStarted = false; if (blePeerDiscoverer == null || !blePeerDiscoverer.getState().contains(BlePeerDiscoverer.BlePeerDiscovererStateSet.SCANNING)) { isStarted = (mBluetoothDeviceDiscoverer.isRunning() || mBluetoothDeviceDiscoverer.start(mSettings.getProvideBluetoothMacAddressTimeout())); } else { Log.e(TAG, "startBluetoothDeviceDiscovery: Bluetooth LE peer discoverer cannot be running, when doing Bluetooth LE scanning"); } return isStarted; } BluetoothMacAddressResolutionHelper(
            Context context, BluetoothAdapter bluetoothAdapter, DiscoveryManager discoveryManager,
            UUID bleServiceUuid, UUID provideBluetoothMacAddressRequestUuid);  BluetoothMacAddressResolutionHelper(
            Context context, BluetoothAdapter bluetoothAdapter, DiscoveryManager discoveryManager,
            UUID bleServiceUuid, UUID provideBluetoothMacAddressRequestUuid, SharedPreferences preferences); UUID getProvideBluetoothMacAddressRequestUuid(); String getCurrentProvideBluetoothMacAddressRequestId(); boolean getIsProvideBluetoothMacAddressModeStarted(); boolean getIsBluetoothMacAddressGattServerStarted(); boolean getIsReceiveBluetoothMacAddressModeStarted(); synchronized void stopAllBluetoothMacAddressResolutionOperations(); synchronized boolean startProvideBluetoothMacAddressMode(String requestId); synchronized void stopProvideBluetoothMacAddressMode(); void provideBluetoothMacAddressToDevice(BluetoothDevice bluetoothDevice); synchronized void startReceiveBluetoothMacAddressMode(String requestId); synchronized void stopReceiveBluetoothMacAddressMode(); void startBluetoothMacAddressGattServer(String requestId); synchronized boolean startBluetoothDeviceDiscovery(); synchronized boolean stopBluetoothDeviceDiscovery(); @Override void onBluetoothDeviceDiscovered(BluetoothDevice bluetoothDevice); @Override void onBluetoothGattClientOperationCountInQueueChanged(int operationCountInQueue); @Override void onProvideBluetoothMacAddressResult(String requestId, boolean wasCompleted); @Override void onBluetoothMacAddressResolved(String bluetoothMacAddress); }
BluetoothMacAddressResolutionHelper implements BluetoothDeviceDiscoverer.BluetoothDeviceDiscovererListener,
                   BluetoothGattManager.BluetoothGattManagerListener { public synchronized boolean startBluetoothDeviceDiscovery() { Log.d(TAG, "startBluetoothDeviceDiscovery"); BlePeerDiscoverer blePeerDiscoverer = mDiscoveryManager.getBlePeerDiscovererInstanceAndCheckBluetoothMacAddress(); blePeerDiscoverer.stopScanner(); if (mBluetoothDeviceDiscoverer == null) { mBluetoothDeviceDiscoverer = new BluetoothDeviceDiscoverer(mContext, mBluetoothAdapter, this); } boolean isStarted = false; if (blePeerDiscoverer == null || !blePeerDiscoverer.getState().contains(BlePeerDiscoverer.BlePeerDiscovererStateSet.SCANNING)) { isStarted = (mBluetoothDeviceDiscoverer.isRunning() || mBluetoothDeviceDiscoverer.start(mSettings.getProvideBluetoothMacAddressTimeout())); } else { Log.e(TAG, "startBluetoothDeviceDiscovery: Bluetooth LE peer discoverer cannot be running, when doing Bluetooth LE scanning"); } return isStarted; } BluetoothMacAddressResolutionHelper(
            Context context, BluetoothAdapter bluetoothAdapter, DiscoveryManager discoveryManager,
            UUID bleServiceUuid, UUID provideBluetoothMacAddressRequestUuid);  BluetoothMacAddressResolutionHelper(
            Context context, BluetoothAdapter bluetoothAdapter, DiscoveryManager discoveryManager,
            UUID bleServiceUuid, UUID provideBluetoothMacAddressRequestUuid, SharedPreferences preferences); UUID getProvideBluetoothMacAddressRequestUuid(); String getCurrentProvideBluetoothMacAddressRequestId(); boolean getIsProvideBluetoothMacAddressModeStarted(); boolean getIsBluetoothMacAddressGattServerStarted(); boolean getIsReceiveBluetoothMacAddressModeStarted(); synchronized void stopAllBluetoothMacAddressResolutionOperations(); synchronized boolean startProvideBluetoothMacAddressMode(String requestId); synchronized void stopProvideBluetoothMacAddressMode(); void provideBluetoothMacAddressToDevice(BluetoothDevice bluetoothDevice); synchronized void startReceiveBluetoothMacAddressMode(String requestId); synchronized void stopReceiveBluetoothMacAddressMode(); void startBluetoothMacAddressGattServer(String requestId); synchronized boolean startBluetoothDeviceDiscovery(); synchronized boolean stopBluetoothDeviceDiscovery(); @Override void onBluetoothDeviceDiscovered(BluetoothDevice bluetoothDevice); @Override void onBluetoothGattClientOperationCountInQueueChanged(int operationCountInQueue); @Override void onProvideBluetoothMacAddressResult(String requestId, boolean wasCompleted); @Override void onBluetoothMacAddressResolved(String bluetoothMacAddress);  }