@Test public void testOnConnectionManagerSettingsChanged() throws Exception { Field settingsField = connectionManager.getClass().getDeclaredField("mSettings"); settingsField.setAccessible(true); settingsField.set(connectionManager, mMockConnectionManagerSettings); when(mMockConnectionManagerSettings.getConnectionTimeout()).thenReturn(100L); when(mMockConnectionManagerSettings.getInsecureRfcommSocketPortNumber()).thenReturn(1); when(mMockConnectionManagerSettings.getMaxNumberOfConnectionAttemptRetries()).thenReturn(10); connectionManager.onConnectionManagerSettingsChanged(); verify(mMockBluetoothConnector, atLeastOnce()) .setConnectionTimeout(100L); verify(mMockBluetoothConnector, atLeastOnce()) .setInsecureRfcommSocketPort(1); verify(mMockBluetoothConnector, atLeastOnce()) .setMaxNumberOfOutgoingConnectionAttemptRetries(10); }
@Override public void onConnectionManagerSettingsChanged() { mBluetoothConnector.setConnectionTimeout(mSettings.getConnectionTimeout()); mBluetoothConnector.setInsecureRfcommSocketPort(mSettings.getInsecureRfcommSocketPortNumber()); mBluetoothConnector.setMaxNumberOfOutgoingConnectionAttemptRetries(mSettings.getMaxNumberOfConnectionAttemptRetries()); }
ConnectionManager extends AbstractBluetoothConnectivityAgent implements
        BluetoothConnector.BluetoothConnectorListener,
        ConnectionManagerSettings.Listener,
        DiscoveryManagerSettings.Listener { @Override public void onConnectionManagerSettingsChanged() { mBluetoothConnector.setConnectionTimeout(mSettings.getConnectionTimeout()); mBluetoothConnector.setInsecureRfcommSocketPort(mSettings.getInsecureRfcommSocketPortNumber()); mBluetoothConnector.setMaxNumberOfOutgoingConnectionAttemptRetries(mSettings.getMaxNumberOfConnectionAttemptRetries()); } }
ConnectionManager extends AbstractBluetoothConnectivityAgent implements
        BluetoothConnector.BluetoothConnectorListener,
        ConnectionManagerSettings.Listener,
        DiscoveryManagerSettings.Listener { @Override public void onConnectionManagerSettingsChanged() { mBluetoothConnector.setConnectionTimeout(mSettings.getConnectionTimeout()); mBluetoothConnector.setInsecureRfcommSocketPort(mSettings.getInsecureRfcommSocketPortNumber()); mBluetoothConnector.setMaxNumberOfOutgoingConnectionAttemptRetries(mSettings.getMaxNumberOfConnectionAttemptRetries()); } ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName);  ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName, BluetoothManager bluetoothManager,
            SharedPreferences preferences); }
ConnectionManager extends AbstractBluetoothConnectivityAgent implements
        BluetoothConnector.BluetoothConnectorListener,
        ConnectionManagerSettings.Listener,
        DiscoveryManagerSettings.Listener { @Override public void onConnectionManagerSettingsChanged() { mBluetoothConnector.setConnectionTimeout(mSettings.getConnectionTimeout()); mBluetoothConnector.setInsecureRfcommSocketPort(mSettings.getInsecureRfcommSocketPortNumber()); mBluetoothConnector.setMaxNumberOfOutgoingConnectionAttemptRetries(mSettings.getMaxNumberOfConnectionAttemptRetries()); } ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName);  ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName, BluetoothManager bluetoothManager,
            SharedPreferences preferences); ConnectionManagerState getState(); synchronized boolean startListeningForIncomingConnections(); synchronized void stopListeningForIncomingConnections(); synchronized boolean connect(PeerProperties peerToConnectTo); synchronized boolean cancelConnectionAttempt(PeerProperties peerConnectingTo); synchronized void cancelAllConnectionAttempts(); @Override void dispose(); @Override void onConnectionManagerSettingsChanged(); @Override void onHandshakeRequiredSettingChanged(boolean handshakeRequired); @Override void onBluetoothAdapterScanModeChanged(int mode); @Override void onBluetoothAdapterStateChanged(int state); @Override void onIsServerStartedChanged(boolean isStarted); @Override void onConnecting(String bluetoothDeviceName, String bluetoothDeviceAddress); @Override void onConnected(
            final BluetoothSocket bluetoothSocket, final boolean isIncoming,
            final PeerProperties peerProperties); @Override void onConnectionTimeout(final PeerProperties peerProperties); @Override void onConnectionFailed(final PeerProperties peerProperties, final String errorMessage); @Override void onDiscoveryModeChanged(DiscoveryManager.DiscoveryMode discoveryMode, boolean startIfNotRunning); @Override void onPeerExpirationSettingChanged(long peerExpirationInMilliseconds); @Override void onAdvertiseScanSettingsChanged(); @Override void onPeerExtraInfoChanged(int newExtraInfo); @Override boolean setExtraInfo(int extraInfo); }
ConnectionManager extends AbstractBluetoothConnectivityAgent implements
        BluetoothConnector.BluetoothConnectorListener,
        ConnectionManagerSettings.Listener,
        DiscoveryManagerSettings.Listener { @Override public void onConnectionManagerSettingsChanged() { mBluetoothConnector.setConnectionTimeout(mSettings.getConnectionTimeout()); mBluetoothConnector.setInsecureRfcommSocketPort(mSettings.getInsecureRfcommSocketPortNumber()); mBluetoothConnector.setMaxNumberOfOutgoingConnectionAttemptRetries(mSettings.getMaxNumberOfConnectionAttemptRetries()); } ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName);  ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName, BluetoothManager bluetoothManager,
            SharedPreferences preferences); ConnectionManagerState getState(); synchronized boolean startListeningForIncomingConnections(); synchronized void stopListeningForIncomingConnections(); synchronized boolean connect(PeerProperties peerToConnectTo); synchronized boolean cancelConnectionAttempt(PeerProperties peerConnectingTo); synchronized void cancelAllConnectionAttempts(); @Override void dispose(); @Override void onConnectionManagerSettingsChanged(); @Override void onHandshakeRequiredSettingChanged(boolean handshakeRequired); @Override void onBluetoothAdapterScanModeChanged(int mode); @Override void onBluetoothAdapterStateChanged(int state); @Override void onIsServerStartedChanged(boolean isStarted); @Override void onConnecting(String bluetoothDeviceName, String bluetoothDeviceAddress); @Override void onConnected(
            final BluetoothSocket bluetoothSocket, final boolean isIncoming,
            final PeerProperties peerProperties); @Override void onConnectionTimeout(final PeerProperties peerProperties); @Override void onConnectionFailed(final PeerProperties peerProperties, final String errorMessage); @Override void onDiscoveryModeChanged(DiscoveryManager.DiscoveryMode discoveryMode, boolean startIfNotRunning); @Override void onPeerExpirationSettingChanged(long peerExpirationInMilliseconds); @Override void onAdvertiseScanSettingsChanged(); @Override void onPeerExtraInfoChanged(int newExtraInfo); @Override boolean setExtraInfo(int extraInfo);  }