@Test public void testProvideBluetoothMacAddressToDevice() throws Exception { String reqId = "testId"; Long provideBtAddrTimeout = 1000L; Field fieldSettings = mBluetoothMacAddressResolutionHelper.getClass() .getDeclaredField("mSettings"); fieldSettings.setAccessible(true); fieldSettings.set(mBluetoothMacAddressResolutionHelper, mMockDiscoveryManagerSettings); when(mMockDiscoveryManagerSettings.getProvideBluetoothMacAddressTimeout()) .thenReturn(provideBtAddrTimeout); Field fieldGattManager = mBluetoothMacAddressResolutionHelper.getClass() .getDeclaredField("mBluetoothGattManager"); fieldGattManager.setAccessible(true); fieldGattManager.set(mBluetoothMacAddressResolutionHelper, mMockBluetoothGattManager); EnumSet<BlePeerDiscoverer.BlePeerDiscovererStateSet> mStateSet = EnumSet.of(BlePeerDiscoverer.BlePeerDiscovererStateSet.NOT_STARTED); when(mMockBlePeerDiscoverer.getState()).thenReturn(mStateSet); when(mMockBluetoothAdapter.isDiscovering()).thenReturn(true); when(mMockDiscoveryManager.isBleMultipleAdvertisementSupported()).thenReturn(true); when(mMockBlePeerDiscoverer.startPeerAddressHelperAdvertiser( reqId, PeerProperties.BLUETOOTH_MAC_ADDRESS_UNKNOWN, provideBtAddrTimeout )).thenReturn(true); mBluetoothMacAddressResolutionHelper.startProvideBluetoothMacAddressMode(reqId); mBluetoothMacAddressResolutionHelper.provideBluetoothMacAddressToDevice(mMockBluetoothDevice); verify(mMockBlePeerDiscoverer, times(1)).startPeerAddressHelperAdvertiser( reqId, PeerProperties.BLUETOOTH_MAC_ADDRESS_UNKNOWN, provideBtAddrTimeout); verify(mMockDiscoveryManager, times(1)).onProvideBluetoothMacAddressModeStartedChanged(true); verify(mMockBluetoothGattManager, times(1)).provideBluetoothMacAddressToDevice( mMockBluetoothDevice, reqId); }
public void provideBluetoothMacAddressToDevice(BluetoothDevice bluetoothDevice) { if (bluetoothDevice != null) { mBluetoothGattManager.provideBluetoothMacAddressToDevice( bluetoothDevice, mCurrentProvideBluetoothMacAddressRequestId); } }
BluetoothMacAddressResolutionHelper implements BluetoothDeviceDiscoverer.BluetoothDeviceDiscovererListener,
                   BluetoothGattManager.BluetoothGattManagerListener { public void provideBluetoothMacAddressToDevice(BluetoothDevice bluetoothDevice) { if (bluetoothDevice != null) { mBluetoothGattManager.provideBluetoothMacAddressToDevice( bluetoothDevice, mCurrentProvideBluetoothMacAddressRequestId); } } }
BluetoothMacAddressResolutionHelper implements BluetoothDeviceDiscoverer.BluetoothDeviceDiscovererListener,
                   BluetoothGattManager.BluetoothGattManagerListener { public void provideBluetoothMacAddressToDevice(BluetoothDevice bluetoothDevice) { if (bluetoothDevice != null) { mBluetoothGattManager.provideBluetoothMacAddressToDevice( bluetoothDevice, mCurrentProvideBluetoothMacAddressRequestId); } } 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 void provideBluetoothMacAddressToDevice(BluetoothDevice bluetoothDevice) { if (bluetoothDevice != null) { mBluetoothGattManager.provideBluetoothMacAddressToDevice( bluetoothDevice, mCurrentProvideBluetoothMacAddressRequestId); } } 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 void provideBluetoothMacAddressToDevice(BluetoothDevice bluetoothDevice) { if (bluetoothDevice != null) { mBluetoothGattManager.provideBluetoothMacAddressToDevice( bluetoothDevice, mCurrentProvideBluetoothMacAddressRequestId); } } 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);  }