@Test public void verifyInvalidKeyChangedViaSharedPrefs() { SharedPreferences mockedSharedPrefs = getMockedSharedPrefs(); collectionClient.onSharedPreferenceChanged(mockedSharedPrefs, "foo"); verifyZeroInteractions(mockedSharedPrefs); }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { try { if (LOCATION_COLLECTOR_ENABLED.equals(key)) { setEnabled(sharedPreferences.getBoolean(LOCATION_COLLECTOR_ENABLED, false)); } else if (SESSION_ROTATION_INTERVAL_MILLIS.equals(key)) { setSessionRotationInterval(sharedPreferences.getLong(SESSION_ROTATION_INTERVAL_MILLIS, TimeUnit.HOURS.toMillis(DEFAULT_SESSION_ROTATION_INTERVAL_HOURS))); } } catch (Exception ex) { Log.e(TAG, ex.toString()); } }
LocationCollectionClient implements SharedPreferences.OnSharedPreferenceChangeListener { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { try { if (LOCATION_COLLECTOR_ENABLED.equals(key)) { setEnabled(sharedPreferences.getBoolean(LOCATION_COLLECTOR_ENABLED, false)); } else if (SESSION_ROTATION_INTERVAL_MILLIS.equals(key)) { setSessionRotationInterval(sharedPreferences.getLong(SESSION_ROTATION_INTERVAL_MILLIS, TimeUnit.HOURS.toMillis(DEFAULT_SESSION_ROTATION_INTERVAL_HOURS))); } } catch (Exception ex) { Log.e(TAG, ex.toString()); } } }
LocationCollectionClient implements SharedPreferences.OnSharedPreferenceChangeListener { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { try { if (LOCATION_COLLECTOR_ENABLED.equals(key)) { setEnabled(sharedPreferences.getBoolean(LOCATION_COLLECTOR_ENABLED, false)); } else if (SESSION_ROTATION_INTERVAL_MILLIS.equals(key)) { setSessionRotationInterval(sharedPreferences.getLong(SESSION_ROTATION_INTERVAL_MILLIS, TimeUnit.HOURS.toMillis(DEFAULT_SESSION_ROTATION_INTERVAL_HOURS))); } } catch (Exception ex) { Log.e(TAG, ex.toString()); } } @VisibleForTesting  LocationCollectionClient(@NonNull LocationEngineController collectionController,
                           @NonNull HandlerThread handlerThread,
                           @NonNull SessionIdentifier sessionIdentifier,
                           @NonNull SharedPreferences sharedPreferences,
                           @NonNull MapboxTelemetry telemetry); }
LocationCollectionClient implements SharedPreferences.OnSharedPreferenceChangeListener { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { try { if (LOCATION_COLLECTOR_ENABLED.equals(key)) { setEnabled(sharedPreferences.getBoolean(LOCATION_COLLECTOR_ENABLED, false)); } else if (SESSION_ROTATION_INTERVAL_MILLIS.equals(key)) { setSessionRotationInterval(sharedPreferences.getLong(SESSION_ROTATION_INTERVAL_MILLIS, TimeUnit.HOURS.toMillis(DEFAULT_SESSION_ROTATION_INTERVAL_HOURS))); } } catch (Exception ex) { Log.e(TAG, ex.toString()); } } @VisibleForTesting  LocationCollectionClient(@NonNull LocationEngineController collectionController,
                           @NonNull HandlerThread handlerThread,
                           @NonNull SessionIdentifier sessionIdentifier,
                           @NonNull SharedPreferences sharedPreferences,
                           @NonNull MapboxTelemetry telemetry); static LocationCollectionClient install(@NonNull Context context, long defaultInterval); @Override void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key); }
LocationCollectionClient implements SharedPreferences.OnSharedPreferenceChangeListener { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { try { if (LOCATION_COLLECTOR_ENABLED.equals(key)) { setEnabled(sharedPreferences.getBoolean(LOCATION_COLLECTOR_ENABLED, false)); } else if (SESSION_ROTATION_INTERVAL_MILLIS.equals(key)) { setSessionRotationInterval(sharedPreferences.getLong(SESSION_ROTATION_INTERVAL_MILLIS, TimeUnit.HOURS.toMillis(DEFAULT_SESSION_ROTATION_INTERVAL_HOURS))); } } catch (Exception ex) { Log.e(TAG, ex.toString()); } } @VisibleForTesting  LocationCollectionClient(@NonNull LocationEngineController collectionController,
                           @NonNull HandlerThread handlerThread,
                           @NonNull SessionIdentifier sessionIdentifier,
                           @NonNull SharedPreferences sharedPreferences,
                           @NonNull MapboxTelemetry telemetry); static LocationCollectionClient install(@NonNull Context context, long defaultInterval); @Override void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key); static final int DEFAULT_SESSION_ROTATION_INTERVAL_HOURS; }