Loading services/core/java/com/android/server/timezonedetector/ConfigurationInternal.java +8 −7 Original line number Diff line number Diff line Loading @@ -104,10 +104,10 @@ public final class ConfigurationInternal { } /** * Returns {@code true} if location time zone detection should run all the time on supported * devices, even when the user has not enabled it explicitly in settings. Enabled for internal * testing only. See {@link #isGeoDetectionExecutionEnabled()} and {@link #getDetectionMode()} * for details. * Returns {@code true} if location time zone detection should run when auto time zone detection * is enabled on supported devices, even when the user has not enabled the algorithm explicitly * in settings. Enabled for internal testing only. See {@link #isGeoDetectionExecutionEnabled()} * and {@link #getDetectionMode()} for details. */ boolean getGeoDetectionRunInBackgroundEnabledSetting() { return mGeoDetectionRunInBackgroundEnabled; Loading Loading @@ -219,6 +219,7 @@ public final class ConfigurationInternal { private boolean getGeoDetectionRunInBackgroundEnabledBehavior() { return isGeoDetectionSupported() && getLocationEnabledSetting() && getAutoDetectionEnabledSetting() && getGeoDetectionRunInBackgroundEnabledSetting(); } Loading Loading @@ -433,9 +434,9 @@ public final class ConfigurationInternal { } /** * Sets whether location time zone detection should run all the time on supported devices, * even when the user has not enabled it explicitly in settings. Enabled for internal * testing only. * Sets whether location time zone detection should run when auto time zone detection is * enabled on supported devices, even when the user has not enabled the algorithm explicitly * in settings. Enabled for internal testing only. */ public Builder setGeoDetectionRunInBackgroundEnabled(boolean enabled) { mGeoDetectionRunInBackgroundEnabled = enabled; Loading services/tests/servicestests/src/com/android/server/timezonedetector/ConfigurationInternalTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -570,7 +570,7 @@ public class ConfigurationInternalTest { .setAutoDetectionEnabledSetting(false) .build(); assertFalse(config.getAutoDetectionEnabledBehavior()); assertTrue(config.isGeoDetectionExecutionEnabled()); assertFalse(config.isGeoDetectionExecutionEnabled()); assertEquals(DETECTION_MODE_MANUAL, config.getDetectionMode()); } } Loading services/tests/servicestests/src/com/android/server/timezonedetector/location/LocationTimeZoneProviderControllerTest.java +34 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.service.timezone.TimeZoneProviderStatus.OPERATION_STATUS_O import static android.service.timezone.TimeZoneProviderStatus.OPERATION_STATUS_UNKNOWN; import static com.android.server.timezonedetector.ConfigurationInternal.DETECTION_MODE_MANUAL; import static com.android.server.timezonedetector.ConfigurationInternal.DETECTION_MODE_TELEPHONY; import static com.android.server.timezonedetector.location.LocationTimeZoneProvider.ProviderState.PROVIDER_STATE_DESTROYED; import static com.android.server.timezonedetector.location.LocationTimeZoneProvider.ProviderState.PROVIDER_STATE_PERM_FAILED; import static com.android.server.timezonedetector.location.LocationTimeZoneProvider.ProviderState.PROVIDER_STATE_STARTED_CERTAIN; Loading Loading @@ -1384,6 +1385,37 @@ public class LocationTimeZoneProviderControllerTest { assertFalse(controller.isUncertaintyTimeoutSet()); } /** * A controller-state-only test to prove that "run in background" doesn't enable the * location-based time zone detection algorithm to run when auto detection is disabled. */ @Test public void geoDetectionRunInBackground_obeysAutoDetectionDisabled() { LocationTimeZoneProviderController controller = new LocationTimeZoneProviderController( mTestThreadingDomain, mTestMetricsLogger, mTestPrimaryLocationTimeZoneProvider, mTestSecondaryLocationTimeZoneProvider, false /* recordStateChanges */); // A configuration where the user has auto detection disabled. ConfigurationInternal autoTimeZoneDisabledConfig = new ConfigurationInternal.Builder(USER1_CONFIG_GEO_DETECTION_DISABLED) .setLocationEnabledSetting(true) .setAutoDetectionEnabledSetting(false) .setGeoDetectionEnabledSetting(true) .setGeoDetectionRunInBackgroundEnabled(true) .build(); assertEquals(DETECTION_MODE_MANUAL, autoTimeZoneDisabledConfig.getDetectionMode()); assertFalse(autoTimeZoneDisabledConfig.isGeoDetectionExecutionEnabled()); TestEnvironment testEnvironment = new TestEnvironment( mTestThreadingDomain, controller, autoTimeZoneDisabledConfig); // Initialize and check initial state. controller.initialize(testEnvironment, mTestCallback); assertControllerState(controller, STATE_STOPPED); mTestMetricsLogger.assertStateChangesAndCommit(STATE_PROVIDERS_INITIALIZING, STATE_STOPPED); } /** * A controller-state-only test to prove that "run in background" configuration behaves as * intended. Provider states are well covered by other "enabled" tests. Loading @@ -1398,7 +1430,7 @@ public class LocationTimeZoneProviderControllerTest { ConfigurationInternal runInBackgroundDisabledConfig = new ConfigurationInternal.Builder(USER1_CONFIG_GEO_DETECTION_DISABLED) .setLocationEnabledSetting(true) .setAutoDetectionEnabledSetting(false) .setAutoDetectionEnabledSetting(true) .setGeoDetectionEnabledSetting(false) .setGeoDetectionRunInBackgroundEnabled(false) .build(); Loading @@ -1408,7 +1440,7 @@ public class LocationTimeZoneProviderControllerTest { new ConfigurationInternal.Builder(runInBackgroundDisabledConfig) .setGeoDetectionRunInBackgroundEnabled(true) .build(); assertEquals(DETECTION_MODE_MANUAL, runInBackgroundEnabledConfig.getDetectionMode()); assertEquals(DETECTION_MODE_TELEPHONY, runInBackgroundEnabledConfig.getDetectionMode()); assertTrue(runInBackgroundEnabledConfig.isGeoDetectionExecutionEnabled()); TestEnvironment testEnvironment = new TestEnvironment( Loading Loading
services/core/java/com/android/server/timezonedetector/ConfigurationInternal.java +8 −7 Original line number Diff line number Diff line Loading @@ -104,10 +104,10 @@ public final class ConfigurationInternal { } /** * Returns {@code true} if location time zone detection should run all the time on supported * devices, even when the user has not enabled it explicitly in settings. Enabled for internal * testing only. See {@link #isGeoDetectionExecutionEnabled()} and {@link #getDetectionMode()} * for details. * Returns {@code true} if location time zone detection should run when auto time zone detection * is enabled on supported devices, even when the user has not enabled the algorithm explicitly * in settings. Enabled for internal testing only. See {@link #isGeoDetectionExecutionEnabled()} * and {@link #getDetectionMode()} for details. */ boolean getGeoDetectionRunInBackgroundEnabledSetting() { return mGeoDetectionRunInBackgroundEnabled; Loading Loading @@ -219,6 +219,7 @@ public final class ConfigurationInternal { private boolean getGeoDetectionRunInBackgroundEnabledBehavior() { return isGeoDetectionSupported() && getLocationEnabledSetting() && getAutoDetectionEnabledSetting() && getGeoDetectionRunInBackgroundEnabledSetting(); } Loading Loading @@ -433,9 +434,9 @@ public final class ConfigurationInternal { } /** * Sets whether location time zone detection should run all the time on supported devices, * even when the user has not enabled it explicitly in settings. Enabled for internal * testing only. * Sets whether location time zone detection should run when auto time zone detection is * enabled on supported devices, even when the user has not enabled the algorithm explicitly * in settings. Enabled for internal testing only. */ public Builder setGeoDetectionRunInBackgroundEnabled(boolean enabled) { mGeoDetectionRunInBackgroundEnabled = enabled; Loading
services/tests/servicestests/src/com/android/server/timezonedetector/ConfigurationInternalTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -570,7 +570,7 @@ public class ConfigurationInternalTest { .setAutoDetectionEnabledSetting(false) .build(); assertFalse(config.getAutoDetectionEnabledBehavior()); assertTrue(config.isGeoDetectionExecutionEnabled()); assertFalse(config.isGeoDetectionExecutionEnabled()); assertEquals(DETECTION_MODE_MANUAL, config.getDetectionMode()); } } Loading
services/tests/servicestests/src/com/android/server/timezonedetector/location/LocationTimeZoneProviderControllerTest.java +34 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.service.timezone.TimeZoneProviderStatus.OPERATION_STATUS_O import static android.service.timezone.TimeZoneProviderStatus.OPERATION_STATUS_UNKNOWN; import static com.android.server.timezonedetector.ConfigurationInternal.DETECTION_MODE_MANUAL; import static com.android.server.timezonedetector.ConfigurationInternal.DETECTION_MODE_TELEPHONY; import static com.android.server.timezonedetector.location.LocationTimeZoneProvider.ProviderState.PROVIDER_STATE_DESTROYED; import static com.android.server.timezonedetector.location.LocationTimeZoneProvider.ProviderState.PROVIDER_STATE_PERM_FAILED; import static com.android.server.timezonedetector.location.LocationTimeZoneProvider.ProviderState.PROVIDER_STATE_STARTED_CERTAIN; Loading Loading @@ -1384,6 +1385,37 @@ public class LocationTimeZoneProviderControllerTest { assertFalse(controller.isUncertaintyTimeoutSet()); } /** * A controller-state-only test to prove that "run in background" doesn't enable the * location-based time zone detection algorithm to run when auto detection is disabled. */ @Test public void geoDetectionRunInBackground_obeysAutoDetectionDisabled() { LocationTimeZoneProviderController controller = new LocationTimeZoneProviderController( mTestThreadingDomain, mTestMetricsLogger, mTestPrimaryLocationTimeZoneProvider, mTestSecondaryLocationTimeZoneProvider, false /* recordStateChanges */); // A configuration where the user has auto detection disabled. ConfigurationInternal autoTimeZoneDisabledConfig = new ConfigurationInternal.Builder(USER1_CONFIG_GEO_DETECTION_DISABLED) .setLocationEnabledSetting(true) .setAutoDetectionEnabledSetting(false) .setGeoDetectionEnabledSetting(true) .setGeoDetectionRunInBackgroundEnabled(true) .build(); assertEquals(DETECTION_MODE_MANUAL, autoTimeZoneDisabledConfig.getDetectionMode()); assertFalse(autoTimeZoneDisabledConfig.isGeoDetectionExecutionEnabled()); TestEnvironment testEnvironment = new TestEnvironment( mTestThreadingDomain, controller, autoTimeZoneDisabledConfig); // Initialize and check initial state. controller.initialize(testEnvironment, mTestCallback); assertControllerState(controller, STATE_STOPPED); mTestMetricsLogger.assertStateChangesAndCommit(STATE_PROVIDERS_INITIALIZING, STATE_STOPPED); } /** * A controller-state-only test to prove that "run in background" configuration behaves as * intended. Provider states are well covered by other "enabled" tests. Loading @@ -1398,7 +1430,7 @@ public class LocationTimeZoneProviderControllerTest { ConfigurationInternal runInBackgroundDisabledConfig = new ConfigurationInternal.Builder(USER1_CONFIG_GEO_DETECTION_DISABLED) .setLocationEnabledSetting(true) .setAutoDetectionEnabledSetting(false) .setAutoDetectionEnabledSetting(true) .setGeoDetectionEnabledSetting(false) .setGeoDetectionRunInBackgroundEnabled(false) .build(); Loading @@ -1408,7 +1440,7 @@ public class LocationTimeZoneProviderControllerTest { new ConfigurationInternal.Builder(runInBackgroundDisabledConfig) .setGeoDetectionRunInBackgroundEnabled(true) .build(); assertEquals(DETECTION_MODE_MANUAL, runInBackgroundEnabledConfig.getDetectionMode()); assertEquals(DETECTION_MODE_TELEPHONY, runInBackgroundEnabledConfig.getDetectionMode()); assertTrue(runInBackgroundEnabledConfig.isGeoDetectionExecutionEnabled()); TestEnvironment testEnvironment = new TestEnvironment( Loading