@Test public void testLoad() throws Exception { mConnectionManagerSettings.load(); verify(mMockSharedPreferences, atLeast(1)) .getBoolean(contains("require_handshake"), anyBoolean()); verify(mMockSharedPreferences, atLeast(1)) .getLong(contains("connection_timeout"), anyInt()); verify(mMockSharedPreferences, atLeast(1)) .getInt(contains("port_number"), anyInt()); verify(mMockSharedPreferences, atLeast(1)) .getInt(contains("max_number_of_connection_attempt_retries"), anyInt()); }
@Override public void load() { if (!mLoaded) { mLoaded = true; mConnectionTimeoutInMilliseconds = mSharedPreferences.getLong( KEY_CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT_IN_MILLISECONDS); mInsecureRfcommSocketPortNumber = mSharedPreferences.getInt( KEY_PORT_NUMBER, SYSTEM_DECIDED_INSECURE_RFCOMM_SOCKET_PORT); mMaxNumberOfConnectionAttemptRetries = mSharedPreferences.getInt( KEY_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES, DEFAULT_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES); mHandshakeRequired = mSharedPreferences.getBoolean(KEY_HANDSHAKE_REQUIRED, DEFAULT_HANDSHAKE_REQUIRED); Log.v(TAG, "load: " + "\n - Connection timeout in milliseconds: " + mConnectionTimeoutInMilliseconds + "\n - Insecure RFCOMM socket port number: " + mInsecureRfcommSocketPortNumber + "\n - Maximum number of connection attempt retries: " + mMaxNumberOfConnectionAttemptRetries + "\n - Handshake required: " + mHandshakeRequired); } else { Log.v(TAG, "load: Already loaded"); } }
ConnectionManagerSettings extends AbstractSettings { @Override public void load() { if (!mLoaded) { mLoaded = true; mConnectionTimeoutInMilliseconds = mSharedPreferences.getLong( KEY_CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT_IN_MILLISECONDS); mInsecureRfcommSocketPortNumber = mSharedPreferences.getInt( KEY_PORT_NUMBER, SYSTEM_DECIDED_INSECURE_RFCOMM_SOCKET_PORT); mMaxNumberOfConnectionAttemptRetries = mSharedPreferences.getInt( KEY_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES, DEFAULT_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES); mHandshakeRequired = mSharedPreferences.getBoolean(KEY_HANDSHAKE_REQUIRED, DEFAULT_HANDSHAKE_REQUIRED); Log.v(TAG, "load: " + "\n - Connection timeout in milliseconds: " + mConnectionTimeoutInMilliseconds + "\n - Insecure RFCOMM socket port number: " + mInsecureRfcommSocketPortNumber + "\n - Maximum number of connection attempt retries: " + mMaxNumberOfConnectionAttemptRetries + "\n - Handshake required: " + mHandshakeRequired); } else { Log.v(TAG, "load: Already loaded"); } } }
ConnectionManagerSettings extends AbstractSettings { @Override public void load() { if (!mLoaded) { mLoaded = true; mConnectionTimeoutInMilliseconds = mSharedPreferences.getLong( KEY_CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT_IN_MILLISECONDS); mInsecureRfcommSocketPortNumber = mSharedPreferences.getInt( KEY_PORT_NUMBER, SYSTEM_DECIDED_INSECURE_RFCOMM_SOCKET_PORT); mMaxNumberOfConnectionAttemptRetries = mSharedPreferences.getInt( KEY_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES, DEFAULT_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES); mHandshakeRequired = mSharedPreferences.getBoolean(KEY_HANDSHAKE_REQUIRED, DEFAULT_HANDSHAKE_REQUIRED); Log.v(TAG, "load: " + "\n - Connection timeout in milliseconds: " + mConnectionTimeoutInMilliseconds + "\n - Insecure RFCOMM socket port number: " + mInsecureRfcommSocketPortNumber + "\n - Maximum number of connection attempt retries: " + mMaxNumberOfConnectionAttemptRetries + "\n - Handshake required: " + mHandshakeRequired); } else { Log.v(TAG, "load: Already loaded"); } } private  ConnectionManagerSettings(Context context); private  ConnectionManagerSettings(Context context, SharedPreferences preferences); }
ConnectionManagerSettings extends AbstractSettings { @Override public void load() { if (!mLoaded) { mLoaded = true; mConnectionTimeoutInMilliseconds = mSharedPreferences.getLong( KEY_CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT_IN_MILLISECONDS); mInsecureRfcommSocketPortNumber = mSharedPreferences.getInt( KEY_PORT_NUMBER, SYSTEM_DECIDED_INSECURE_RFCOMM_SOCKET_PORT); mMaxNumberOfConnectionAttemptRetries = mSharedPreferences.getInt( KEY_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES, DEFAULT_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES); mHandshakeRequired = mSharedPreferences.getBoolean(KEY_HANDSHAKE_REQUIRED, DEFAULT_HANDSHAKE_REQUIRED); Log.v(TAG, "load: " + "\n - Connection timeout in milliseconds: " + mConnectionTimeoutInMilliseconds + "\n - Insecure RFCOMM socket port number: " + mInsecureRfcommSocketPortNumber + "\n - Maximum number of connection attempt retries: " + mMaxNumberOfConnectionAttemptRetries + "\n - Handshake required: " + mHandshakeRequired); } else { Log.v(TAG, "load: Already loaded"); } } private  ConnectionManagerSettings(Context context); private  ConnectionManagerSettings(Context context, SharedPreferences preferences); static ConnectionManagerSettings getInstance(Context context); static ConnectionManagerSettings getInstance(Context context, SharedPreferences preferences); long getConnectionTimeout(); void setConnectionTimeout(long connectionTimeoutInMilliseconds); int getInsecureRfcommSocketPortNumber(); boolean setInsecureRfcommSocketPortNumber(int insecureRfcommSocketPort); int getMaxNumberOfConnectionAttemptRetries(); void setMaxNumberOfConnectionAttemptRetries(int maxNumberOfRetries); boolean getHandshakeRequired(); void setHandshakeRequired(boolean requireHandshake); @Override void load(); @Override void resetDefaults(); }
ConnectionManagerSettings extends AbstractSettings { @Override public void load() { if (!mLoaded) { mLoaded = true; mConnectionTimeoutInMilliseconds = mSharedPreferences.getLong( KEY_CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT_IN_MILLISECONDS); mInsecureRfcommSocketPortNumber = mSharedPreferences.getInt( KEY_PORT_NUMBER, SYSTEM_DECIDED_INSECURE_RFCOMM_SOCKET_PORT); mMaxNumberOfConnectionAttemptRetries = mSharedPreferences.getInt( KEY_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES, DEFAULT_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES); mHandshakeRequired = mSharedPreferences.getBoolean(KEY_HANDSHAKE_REQUIRED, DEFAULT_HANDSHAKE_REQUIRED); Log.v(TAG, "load: " + "\n - Connection timeout in milliseconds: " + mConnectionTimeoutInMilliseconds + "\n - Insecure RFCOMM socket port number: " + mInsecureRfcommSocketPortNumber + "\n - Maximum number of connection attempt retries: " + mMaxNumberOfConnectionAttemptRetries + "\n - Handshake required: " + mHandshakeRequired); } else { Log.v(TAG, "load: Already loaded"); } } private  ConnectionManagerSettings(Context context); private  ConnectionManagerSettings(Context context, SharedPreferences preferences); static ConnectionManagerSettings getInstance(Context context); static ConnectionManagerSettings getInstance(Context context, SharedPreferences preferences); long getConnectionTimeout(); void setConnectionTimeout(long connectionTimeoutInMilliseconds); int getInsecureRfcommSocketPortNumber(); boolean setInsecureRfcommSocketPortNumber(int insecureRfcommSocketPort); int getMaxNumberOfConnectionAttemptRetries(); void setMaxNumberOfConnectionAttemptRetries(int maxNumberOfRetries); boolean getHandshakeRequired(); void setHandshakeRequired(boolean requireHandshake); @Override void load(); @Override void resetDefaults(); static final long DEFAULT_CONNECTION_TIMEOUT_IN_MILLISECONDS; static final int SYSTEM_DECIDED_INSECURE_RFCOMM_SOCKET_PORT; static final int DEFAULT_ALTERNATIVE_INSECURE_RFCOMM_SOCKET_PORT; static final int DEFAULT_MAX_NUMBER_OF_CONNECTION_ATTEMPT_RETRIES; static final boolean DEFAULT_HANDSHAKE_REQUIRED; }