@Test public void testIsDiscovering() throws Exception { EnumSet<WifiPeerDiscoverer.WifiPeerDiscovererStateSet> wifiStates = EnumSet.of(WifiPeerDiscoverer.WifiPeerDiscovererStateSet.SCANNING); EnumSet<BlePeerDiscoverer.BlePeerDiscovererStateSet> bleStates = EnumSet.of(BlePeerDiscoverer.BlePeerDiscovererStateSet.NOT_STARTED); Field mBlePeerDiscovererField = discoveryManager.getClass() .getDeclaredField("mBlePeerDiscoverer"); mBlePeerDiscovererField.setAccessible(true); Field mWifiPeerDiscovererField = discoveryManager.getClass() .getDeclaredField("mWifiPeerDiscoverer"); mWifiPeerDiscovererField.setAccessible(true); mWifiPeerDiscovererField.set(discoveryManager, mMockWifiPeerDiscoverer); mBlePeerDiscovererField.set(discoveryManager, mMockBlePeerDiscoverer); when(mMockWifiPeerDiscoverer.getState()) .thenReturn(wifiStates); when(mMockBlePeerDiscoverer.getState()) .thenReturn(bleStates); assertThat("Should be true when WifiPeerDiscoverer is scanning", discoveryManager.isDiscovering(), is(true)); assertThat("Should be true when WifiPeerDiscoverer is scanning", discoveryManager.isWifiDiscovering(), is(true)); assertThat("Should be false when BlePeerDiscoverer is not scanning", discoveryManager.isBleDiscovering(), is(false)); bleStates = EnumSet.of(BlePeerDiscoverer.BlePeerDiscovererStateSet.SCANNING); wifiStates = EnumSet.of(WifiPeerDiscoverer.WifiPeerDiscovererStateSet.NOT_STARTED); when(mMockWifiPeerDiscoverer.getState()) .thenReturn(wifiStates); when(mMockBlePeerDiscoverer.getState()) .thenReturn(bleStates); assertThat("Should be true when BlePeerDiscoverer is scanning", discoveryManager.isDiscovering(), is(true)); assertThat("Should be true when BlePeerDiscoverer is scanning", discoveryManager.isBleDiscovering(), is(true)); assertThat("Should be false when BlePeerDiscoverer is not scanning", discoveryManager.isWifiDiscovering(), is(false)); }
public boolean isDiscovering() { return (isBleDiscovering() || isWifiDiscovering()); }
DiscoveryManager extends AbstractBluetoothConnectivityAgent implements
        WifiDirectManager.WifiStateListener,
        WifiPeerDiscoverer.WifiPeerDiscoveryListener,
        BlePeerDiscoverer.BlePeerDiscoveryListener,
        BluetoothMacAddressResolutionHelper.BluetoothMacAddressResolutionHelperListener,
        PeerModel.Listener,
        DiscoveryManagerSettings.Listener { public boolean isDiscovering() { return (isBleDiscovering() || isWifiDiscovering()); } }
DiscoveryManager extends AbstractBluetoothConnectivityAgent implements
        WifiDirectManager.WifiStateListener,
        WifiPeerDiscoverer.WifiPeerDiscoveryListener,
        BlePeerDiscoverer.BlePeerDiscoveryListener,
        BluetoothMacAddressResolutionHelper.BluetoothMacAddressResolutionHelperListener,
        PeerModel.Listener,
        DiscoveryManagerSettings.Listener { public boolean isDiscovering() { return (isBleDiscovering() || isWifiDiscovering()); } DiscoveryManager(Context context, DiscoveryManagerListener listener, UUID bleServiceUuid, String serviceType);  DiscoveryManager(Context context, DiscoveryManagerListener listener, UUID bleServiceUuid,
                            String serviceType, BluetoothManager bluetoothManager, SharedPreferences preferences); }
DiscoveryManager extends AbstractBluetoothConnectivityAgent implements
        WifiDirectManager.WifiStateListener,
        WifiPeerDiscoverer.WifiPeerDiscoveryListener,
        BlePeerDiscoverer.BlePeerDiscoveryListener,
        BluetoothMacAddressResolutionHelper.BluetoothMacAddressResolutionHelperListener,
        PeerModel.Listener,
        DiscoveryManagerSettings.Listener { public boolean isDiscovering() { return (isBleDiscovering() || isWifiDiscovering()); } DiscoveryManager(Context context, DiscoveryManagerListener listener, UUID bleServiceUuid, String serviceType);  DiscoveryManager(Context context, DiscoveryManagerListener listener, UUID bleServiceUuid,
                            String serviceType, BluetoothManager bluetoothManager, SharedPreferences preferences); boolean isBleMultipleAdvertisementSupported(); boolean isBleOffloadedScanBatchingSupported(); boolean isBleOffloadedFilteringSupported(); boolean isBleSupported(); boolean isWifiDirectSupported(); DiscoveryManagerState getState(); boolean isRunning(); boolean isDiscovering(); boolean isBleDiscovering(); boolean isWifiDiscovering(); boolean isAdvertising(); boolean isBleAdvertising(); boolean isWifiAdvertising(); WifiDirectManager getWifiDirectManager(); PeerModel getPeerModel(); BluetoothMacAddressResolutionHelper getBluetoothMacAddressResolutionHelper(); String getMissingPermission(); synchronized boolean start(); synchronized boolean start(boolean startDiscovery, boolean startAdvertising); synchronized void stopDiscovery(); synchronized void stopAdvertising(); synchronized void stop(); void makeDeviceDiscoverable(int durationInSeconds); @Override void dispose(); BlePeerDiscoverer getBlePeerDiscovererInstanceAndCheckBluetoothMacAddress(); @Override void onDiscoveryModeChanged(final DiscoveryMode discoveryMode, boolean startIfNotRunning); @Override void onPeerExpirationSettingChanged(long peerExpirationInMilliseconds); @Override void onAdvertiseScanSettingsChanged(); @Override void onPeerExtraInfoChanged(int newExtraInfo); @Override void onBluetoothAdapterScanModeChanged(int mode); @Override void onBluetoothAdapterStateChanged(int state); @Override void onWifiP2PStateChanged(int state); @Override void onWifiStateChanged(int state); @Override void onWifiPeerDiscovererStateChanged(EnumSet<WifiPeerDiscovererStateSet> state); @Override void onBlePeerDiscovererStateChanged(EnumSet<BlePeerDiscovererStateSet> state); @Override void onPeerDiscovered(PeerProperties peerProperties); @Override synchronized void onP2pDeviceListChanged(Collection<WifiP2pDevice> p2pDeviceList); @Override void onProvideBluetoothMacAddressRequest(final String requestId); @Override void onPeerReadyToProvideBluetoothMacAddress(String requestId); @Override void onProvideBluetoothMacAddressResult(String requestId, boolean wasCompleted); @Override void onBluetoothMacAddressResolved(final String bluetoothMacAddress); @Override void onProvideBluetoothMacAddressModeStartedChanged(final boolean isStarted); @Override void onReceiveBluetoothMacAddressModeStartedChanged(final boolean isStarted); @Override void onPeerAdded(final PeerProperties peerProperties); @Override void onPeerUpdated(final PeerProperties peerProperties); @Override void onPeerExpiredAndRemoved(final PeerProperties peerProperties); }
DiscoveryManager extends AbstractBluetoothConnectivityAgent implements
        WifiDirectManager.WifiStateListener,
        WifiPeerDiscoverer.WifiPeerDiscoveryListener,
        BlePeerDiscoverer.BlePeerDiscoveryListener,
        BluetoothMacAddressResolutionHelper.BluetoothMacAddressResolutionHelperListener,
        PeerModel.Listener,
        DiscoveryManagerSettings.Listener { public boolean isDiscovering() { return (isBleDiscovering() || isWifiDiscovering()); } DiscoveryManager(Context context, DiscoveryManagerListener listener, UUID bleServiceUuid, String serviceType);  DiscoveryManager(Context context, DiscoveryManagerListener listener, UUID bleServiceUuid,
                            String serviceType, BluetoothManager bluetoothManager, SharedPreferences preferences); boolean isBleMultipleAdvertisementSupported(); boolean isBleOffloadedScanBatchingSupported(); boolean isBleOffloadedFilteringSupported(); boolean isBleSupported(); boolean isWifiDirectSupported(); DiscoveryManagerState getState(); boolean isRunning(); boolean isDiscovering(); boolean isBleDiscovering(); boolean isWifiDiscovering(); boolean isAdvertising(); boolean isBleAdvertising(); boolean isWifiAdvertising(); WifiDirectManager getWifiDirectManager(); PeerModel getPeerModel(); BluetoothMacAddressResolutionHelper getBluetoothMacAddressResolutionHelper(); String getMissingPermission(); synchronized boolean start(); synchronized boolean start(boolean startDiscovery, boolean startAdvertising); synchronized void stopDiscovery(); synchronized void stopAdvertising(); synchronized void stop(); void makeDeviceDiscoverable(int durationInSeconds); @Override void dispose(); BlePeerDiscoverer getBlePeerDiscovererInstanceAndCheckBluetoothMacAddress(); @Override void onDiscoveryModeChanged(final DiscoveryMode discoveryMode, boolean startIfNotRunning); @Override void onPeerExpirationSettingChanged(long peerExpirationInMilliseconds); @Override void onAdvertiseScanSettingsChanged(); @Override void onPeerExtraInfoChanged(int newExtraInfo); @Override void onBluetoothAdapterScanModeChanged(int mode); @Override void onBluetoothAdapterStateChanged(int state); @Override void onWifiP2PStateChanged(int state); @Override void onWifiStateChanged(int state); @Override void onWifiPeerDiscovererStateChanged(EnumSet<WifiPeerDiscovererStateSet> state); @Override void onBlePeerDiscovererStateChanged(EnumSet<BlePeerDiscovererStateSet> state); @Override void onPeerDiscovered(PeerProperties peerProperties); @Override synchronized void onP2pDeviceListChanged(Collection<WifiP2pDevice> p2pDeviceList); @Override void onProvideBluetoothMacAddressRequest(final String requestId); @Override void onPeerReadyToProvideBluetoothMacAddress(String requestId); @Override void onProvideBluetoothMacAddressResult(String requestId, boolean wasCompleted); @Override void onBluetoothMacAddressResolved(final String bluetoothMacAddress); @Override void onProvideBluetoothMacAddressModeStartedChanged(final boolean isStarted); @Override void onReceiveBluetoothMacAddressModeStartedChanged(final boolean isStarted); @Override void onPeerAdded(final PeerProperties peerProperties); @Override void onPeerUpdated(final PeerProperties peerProperties); @Override void onPeerExpiredAndRemoved(final PeerProperties peerProperties);  }