Loading services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +3 −2 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import static com.android.internal.util.FrameworkStatsLog.DATA_USAGE_BYTES_TRANS import static com.android.internal.util.FrameworkStatsLog.TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__GEO; import static com.android.internal.util.FrameworkStatsLog.TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__MANUAL; import static com.android.internal.util.FrameworkStatsLog.TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__TELEPHONY; import static com.android.internal.util.FrameworkStatsLog.TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__UNKNOWN; import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem; import static com.android.server.stats.pull.IonMemoryUtil.readProcessSystemIonHeapSizesFromDebugfs; import static com.android.server.stats.pull.IonMemoryUtil.readSystemIonHeapSizeFromDebugfs; Loading Loading @@ -3407,7 +3408,7 @@ public class StatsPullAtomService extends SystemService { pulledData.add(FrameworkStatsLog.buildStatsEvent(atomTag, metricsState.isTelephonyDetectionSupported(), metricsState.isGeoDetectionSupported(), metricsState.isUserLocationEnabled(), metricsState.getUserLocationEnabledSetting(), metricsState.getAutoDetectionEnabledSetting(), metricsState.getGeoDetectionEnabledSetting(), convertToMetricsDetectionMode(metricsState.getDetectionMode()), Loading @@ -3434,7 +3435,7 @@ public class StatsPullAtomService extends SystemService { case MetricsTimeZoneDetectorState.DETECTION_MODE_TELEPHONY: return TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__TELEPHONY; default: throw new IllegalArgumentException("" + detectionMode); return TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__UNKNOWN; } } Loading services/core/java/com/android/server/timezonedetector/ConfigurationInternal.java +35 −35 Original line number Diff line number Diff line Loading @@ -39,21 +39,21 @@ public final class ConfigurationInternal { private final boolean mTelephonyDetectionSupported; private final boolean mGeoDetectionSupported; private final boolean mAutoDetectionEnabled; private final boolean mAutoDetectionEnabledSetting; private final @UserIdInt int mUserId; private final boolean mUserConfigAllowed; private final boolean mLocationEnabled; private final boolean mGeoDetectionEnabled; private final boolean mLocationEnabledSetting; private final boolean mGeoDetectionEnabledSetting; private ConfigurationInternal(Builder builder) { mTelephonyDetectionSupported = builder.mTelephonyDetectionSupported; mGeoDetectionSupported = builder.mGeoDetectionSupported; mAutoDetectionEnabled = builder.mAutoDetectionEnabled; mAutoDetectionEnabledSetting = builder.mAutoDetectionEnabledSetting; mUserId = builder.mUserId; mUserConfigAllowed = builder.mUserConfigAllowed; mLocationEnabled = builder.mLocationEnabled; mGeoDetectionEnabled = builder.mGeoDetectionEnabled; mLocationEnabledSetting = builder.mLocationEnabledSetting; mGeoDetectionEnabledSetting = builder.mGeoDetectionEnabledSetting; } /** Returns true if the device supports any form of auto time zone detection. */ Loading @@ -73,7 +73,7 @@ public final class ConfigurationInternal { /** Returns the value of the auto time zone detection enabled setting. */ public boolean getAutoDetectionEnabledSetting() { return mAutoDetectionEnabled; return mAutoDetectionEnabledSetting; } /** Loading @@ -81,7 +81,7 @@ public final class ConfigurationInternal { * from the raw setting value. */ public boolean getAutoDetectionEnabledBehavior() { return isAutoDetectionSupported() && mAutoDetectionEnabled; return isAutoDetectionSupported() && mAutoDetectionEnabledSetting; } /** Returns the ID of the user this configuration is associated with. */ Loading @@ -101,13 +101,13 @@ public final class ConfigurationInternal { } /** Returns true if user's location can be used generally. */ public boolean isLocationEnabled() { return mLocationEnabled; public boolean getLocationEnabledSetting() { return mLocationEnabledSetting; } /** Returns the value of the geolocation time zone detection enabled setting. */ public boolean getGeoDetectionEnabledSetting() { return mGeoDetectionEnabled; return mGeoDetectionEnabledSetting; } /** Loading @@ -117,7 +117,7 @@ public final class ConfigurationInternal { public boolean getGeoDetectionEnabledBehavior() { return getAutoDetectionEnabledBehavior() && isGeoDetectionSupported() && isLocationEnabled() && getLocationEnabledSetting() && getGeoDetectionEnabledSetting(); } Loading Loading @@ -154,7 +154,7 @@ public final class ConfigurationInternal { final int configureGeolocationDetectionEnabledCapability; if (!deviceHasLocationTimeZoneDetection) { configureGeolocationDetectionEnabledCapability = CAPABILITY_NOT_SUPPORTED; } else if (!mAutoDetectionEnabled || !isLocationEnabled()) { } else if (!mAutoDetectionEnabledSetting || !getLocationEnabledSetting()) { configureGeolocationDetectionEnabledCapability = CAPABILITY_NOT_APPLICABLE; } else { configureGeolocationDetectionEnabledCapability = CAPABILITY_POSSESSED; Loading Loading @@ -195,10 +195,10 @@ public final class ConfigurationInternal { public ConfigurationInternal merge(TimeZoneConfiguration newConfiguration) { Builder builder = new Builder(this); if (newConfiguration.hasIsAutoDetectionEnabled()) { builder.setAutoDetectionEnabled(newConfiguration.isAutoDetectionEnabled()); builder.setAutoDetectionEnabledSetting(newConfiguration.isAutoDetectionEnabled()); } if (newConfiguration.hasIsGeoDetectionEnabled()) { builder.setGeoDetectionEnabled(newConfiguration.isGeoDetectionEnabled()); builder.setGeoDetectionEnabledSetting(newConfiguration.isGeoDetectionEnabled()); } return builder.build(); } Loading @@ -216,16 +216,16 @@ public final class ConfigurationInternal { && mUserConfigAllowed == that.mUserConfigAllowed && mTelephonyDetectionSupported == that.mTelephonyDetectionSupported && mGeoDetectionSupported == that.mGeoDetectionSupported && mAutoDetectionEnabled == that.mAutoDetectionEnabled && mLocationEnabled == that.mLocationEnabled && mGeoDetectionEnabled == that.mGeoDetectionEnabled; && mAutoDetectionEnabledSetting == that.mAutoDetectionEnabledSetting && mLocationEnabledSetting == that.mLocationEnabledSetting && mGeoDetectionEnabledSetting == that.mGeoDetectionEnabledSetting; } @Override public int hashCode() { return Objects.hash(mUserId, mUserConfigAllowed, mTelephonyDetectionSupported, mGeoDetectionSupported, mAutoDetectionEnabled, mLocationEnabled, mGeoDetectionEnabled); mGeoDetectionSupported, mAutoDetectionEnabledSetting, mLocationEnabledSetting, mGeoDetectionEnabledSetting); } @Override Loading @@ -235,9 +235,9 @@ public final class ConfigurationInternal { + ", mUserConfigAllowed=" + mUserConfigAllowed + ", mTelephonyDetectionSupported=" + mTelephonyDetectionSupported + ", mGeoDetectionSupported=" + mGeoDetectionSupported + ", mAutoDetectionEnabled=" + mAutoDetectionEnabled + ", mLocationEnabled=" + mLocationEnabled + ", mGeoDetectionEnabled=" + mGeoDetectionEnabled + ", mAutoDetectionEnabledSetting=" + mAutoDetectionEnabledSetting + ", mLocationEnabledSetting=" + mLocationEnabledSetting + ", mGeoDetectionEnabledSetting=" + mGeoDetectionEnabledSetting + '}'; } Loading @@ -251,9 +251,9 @@ public final class ConfigurationInternal { private boolean mUserConfigAllowed; private boolean mTelephonyDetectionSupported; private boolean mGeoDetectionSupported; private boolean mAutoDetectionEnabled; private boolean mLocationEnabled; private boolean mGeoDetectionEnabled; private boolean mAutoDetectionEnabledSetting; private boolean mLocationEnabledSetting; private boolean mGeoDetectionEnabledSetting; /** * Creates a new Builder with only the userId set. Loading @@ -270,9 +270,9 @@ public final class ConfigurationInternal { this.mUserConfigAllowed = toCopy.mUserConfigAllowed; this.mTelephonyDetectionSupported = toCopy.mTelephonyDetectionSupported; this.mGeoDetectionSupported = toCopy.mGeoDetectionSupported; this.mAutoDetectionEnabled = toCopy.mAutoDetectionEnabled; this.mLocationEnabled = toCopy.mLocationEnabled; this.mGeoDetectionEnabled = toCopy.mGeoDetectionEnabled; this.mAutoDetectionEnabledSetting = toCopy.mAutoDetectionEnabledSetting; this.mLocationEnabledSetting = toCopy.mLocationEnabledSetting; this.mGeoDetectionEnabledSetting = toCopy.mGeoDetectionEnabledSetting; } /** Loading Loading @@ -302,24 +302,24 @@ public final class ConfigurationInternal { /** * Sets the value of the automatic time zone detection enabled setting for this device. */ public Builder setAutoDetectionEnabled(boolean enabled) { mAutoDetectionEnabled = enabled; public Builder setAutoDetectionEnabledSetting(boolean enabled) { mAutoDetectionEnabledSetting = enabled; return this; } /** * Sets the value of the location mode setting for this user. */ public Builder setLocationEnabled(boolean enabled) { mLocationEnabled = enabled; public Builder setLocationEnabledSetting(boolean enabled) { mLocationEnabledSetting = enabled; return this; } /** * Sets the value of the geolocation time zone detection setting for this user. */ public Builder setGeoDetectionEnabled(boolean enabled) { mGeoDetectionEnabled = enabled; public Builder setGeoDetectionEnabledSetting(boolean enabled) { mGeoDetectionEnabledSetting = enabled; return this; } Loading services/core/java/com/android/server/timezonedetector/MetricsTimeZoneDetectorState.java +7 −12 Original line number Diff line number Diff line Loading @@ -56,16 +56,11 @@ public final class MetricsTimeZoneDetectorState { public static final @DetectionMode int DETECTION_MODE_GEO = 1; public static final @DetectionMode int DETECTION_MODE_TELEPHONY = 2; @NonNull private final ConfigurationInternal mConfigurationInternal; @NonNull @NonNull private final ConfigurationInternal mConfigurationInternal; private final int mDeviceTimeZoneIdOrdinal; @Nullable private final MetricsTimeZoneSuggestion mLatestManualSuggestion; @Nullable private final MetricsTimeZoneSuggestion mLatestTelephonySuggestion; @Nullable private final MetricsTimeZoneSuggestion mLatestGeolocationSuggestion; @Nullable private final MetricsTimeZoneSuggestion mLatestManualSuggestion; @Nullable private final MetricsTimeZoneSuggestion mLatestTelephonySuggestion; @Nullable private final MetricsTimeZoneSuggestion mLatestGeolocationSuggestion; private MetricsTimeZoneDetectorState( @NonNull ConfigurationInternal configurationInternal, Loading Loading @@ -117,8 +112,8 @@ public final class MetricsTimeZoneDetectorState { } /** Returns true if user's location can be used generally. */ public boolean isUserLocationEnabled() { return mConfigurationInternal.isLocationEnabled(); public boolean getUserLocationEnabledSetting() { return mConfigurationInternal.getLocationEnabledSetting(); } /** Returns the value of the geolocation time zone detection enabled setting. */ Loading Loading @@ -149,7 +144,6 @@ public final class MetricsTimeZoneDetectorState { * Returns the ordinal for the device's currently set time zone ID. * See {@link MetricsTimeZoneDetectorState} for information about ordinals. */ @NonNull public int getDeviceTimeZoneIdOrdinal() { return mDeviceTimeZoneIdOrdinal; } Loading Loading @@ -281,6 +275,7 @@ public final class MetricsTimeZoneDetectorState { return new MetricsTimeZoneSuggestion(null); } @NonNull public static MetricsTimeZoneSuggestion createCertain( @NonNull int[] zoneIdOrdinals) { return new MetricsTimeZoneSuggestion(zoneIdOrdinals); Loading services/core/java/com/android/server/timezonedetector/ServiceConfigAccessorImpl.java +11 −11 Original line number Diff line number Diff line Loading @@ -281,8 +281,8 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { // later releases that start to support geo detection on the same hardware. if (!getGeoDetectionSettingEnabledOverride().isPresent() && isGeoTimeZoneDetectionFeatureSupported()) { final boolean geoTzDetectionEnabled = configuration.isGeoDetectionEnabled(); setGeoDetectionEnabledIfRequired(userId, geoTzDetectionEnabled); final boolean geoDetectionEnabledSetting = configuration.isGeoDetectionEnabled(); setGeoDetectionEnabledSettingIfRequired(userId, geoDetectionEnabledSetting); } } } Loading @@ -294,10 +294,10 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { .setTelephonyDetectionFeatureSupported( isTelephonyTimeZoneDetectionFeatureSupported()) .setGeoDetectionFeatureSupported(isGeoTimeZoneDetectionFeatureSupported()) .setAutoDetectionEnabled(isAutoDetectionEnabled()) .setAutoDetectionEnabledSetting(getAutoDetectionEnabledSetting()) .setUserConfigAllowed(isUserConfigAllowed(userId)) .setLocationEnabled(isLocationEnabled(userId)) .setGeoDetectionEnabled(isGeoDetectionEnabled(userId)) .setLocationEnabledSetting(getLocationEnabledSetting(userId)) .setGeoDetectionEnabledSetting(getGeoDetectionEnabledSetting(userId)) .build(); } Loading @@ -306,12 +306,12 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { // a ConfigurationChangeListener callback triggering due to ContentObserver's still // triggering *sometimes* for no-op updates. Because callbacks are async this is necessary // for stable behavior during tests. if (isAutoDetectionEnabled() != enabled) { if (getAutoDetectionEnabledSetting() != enabled) { Settings.Global.putInt(mCr, Settings.Global.AUTO_TIME_ZONE, enabled ? 1 : 0); } } private boolean isLocationEnabled(@UserIdInt int userId) { private boolean getLocationEnabledSetting(@UserIdInt int userId) { return mLocationManager.isLocationEnabledForUser(UserHandle.of(userId)); } Loading @@ -320,11 +320,11 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { return !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_DATE_TIME, userHandle); } private boolean isAutoDetectionEnabled() { private boolean getAutoDetectionEnabledSetting() { return Settings.Global.getInt(mCr, Settings.Global.AUTO_TIME_ZONE, 1 /* default */) > 0; } private boolean isGeoDetectionEnabled(@UserIdInt int userId) { private boolean getGeoDetectionEnabledSetting(@UserIdInt int userId) { // We may never use this, but it gives us a way to force location-based time zone detection // on/off for testers (but only where their other settings would allow them to turn it on // for themselves). Loading @@ -339,9 +339,9 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { (geoDetectionEnabledByDefault ? 1 : 0) /* defaultValue */, userId) != 0; } private void setGeoDetectionEnabledIfRequired(@UserIdInt int userId, boolean enabled) { private void setGeoDetectionEnabledSettingIfRequired(@UserIdInt int userId, boolean enabled) { // See comment in setAutoDetectionEnabledIfRequired. http://b/171953500 if (isGeoDetectionEnabled(userId) != enabled) { if (getGeoDetectionEnabledSetting(userId) != enabled) { Settings.Secure.putIntForUser(mCr, Settings.Secure.LOCATION_TIME_ZONE_DETECTION_ENABLED, enabled ? 1 : 0, userId); } Loading services/tests/servicestests/src/com/android/server/timezonedetector/ConfigurationInternalTest.java +20 −20 Original line number Diff line number Diff line Loading @@ -48,13 +48,13 @@ public class ConfigurationInternalTest { .setUserConfigAllowed(true) .setTelephonyDetectionFeatureSupported(true) .setGeoDetectionFeatureSupported(true) .setAutoDetectionEnabled(true) .setLocationEnabled(true) .setGeoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .setLocationEnabledSetting(true) .setGeoDetectionEnabledSetting(true) .build(); { ConfigurationInternal autoOnConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .build(); assertTrue(autoOnConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOnConfig.getGeoDetectionEnabledSetting()); Loading @@ -79,7 +79,7 @@ public class ConfigurationInternalTest { { ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(false) .setAutoDetectionEnabledSetting(false) .build(); assertFalse(autoOffConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOffConfig.getGeoDetectionEnabledSetting()); Loading Loading @@ -110,13 +110,13 @@ public class ConfigurationInternalTest { .setUserConfigAllowed(false) .setTelephonyDetectionFeatureSupported(true) .setGeoDetectionFeatureSupported(true) .setAutoDetectionEnabled(true) .setLocationEnabled(true) .setGeoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .setLocationEnabledSetting(true) .setGeoDetectionEnabledSetting(true) .build(); { ConfigurationInternal autoOnConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .build(); assertTrue(autoOnConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOnConfig.getGeoDetectionEnabledSetting()); Loading @@ -142,7 +142,7 @@ public class ConfigurationInternalTest { { ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(false) .setAutoDetectionEnabledSetting(false) .build(); assertFalse(autoOffConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOffConfig.getGeoDetectionEnabledSetting()); Loading Loading @@ -174,13 +174,13 @@ public class ConfigurationInternalTest { .setUserConfigAllowed(true) .setTelephonyDetectionFeatureSupported(false) .setGeoDetectionFeatureSupported(false) .setAutoDetectionEnabled(true) .setLocationEnabled(true) .setGeoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .setLocationEnabledSetting(true) .setGeoDetectionEnabledSetting(true) .build(); { ConfigurationInternal autoOnConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .build(); assertTrue(autoOnConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOnConfig.getGeoDetectionEnabledSetting()); Loading @@ -203,7 +203,7 @@ public class ConfigurationInternalTest { } { ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(false) .setAutoDetectionEnabledSetting(false) .build(); assertFalse(autoOffConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOffConfig.getGeoDetectionEnabledSetting()); Loading Loading @@ -236,13 +236,13 @@ public class ConfigurationInternalTest { .setUserConfigAllowed(true) .setTelephonyDetectionFeatureSupported(true) .setGeoDetectionFeatureSupported(false) .setAutoDetectionEnabled(true) .setLocationEnabled(true) .setGeoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .setLocationEnabledSetting(true) .setGeoDetectionEnabledSetting(true) .build(); { ConfigurationInternal autoOnConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .build(); assertTrue(autoOnConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOnConfig.getGeoDetectionEnabledSetting()); Loading @@ -266,7 +266,7 @@ public class ConfigurationInternalTest { } { ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(false) .setAutoDetectionEnabledSetting(false) .build(); assertFalse(autoOffConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOffConfig.getGeoDetectionEnabledSetting()); Loading Loading
services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +3 −2 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import static com.android.internal.util.FrameworkStatsLog.DATA_USAGE_BYTES_TRANS import static com.android.internal.util.FrameworkStatsLog.TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__GEO; import static com.android.internal.util.FrameworkStatsLog.TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__MANUAL; import static com.android.internal.util.FrameworkStatsLog.TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__TELEPHONY; import static com.android.internal.util.FrameworkStatsLog.TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__UNKNOWN; import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem; import static com.android.server.stats.pull.IonMemoryUtil.readProcessSystemIonHeapSizesFromDebugfs; import static com.android.server.stats.pull.IonMemoryUtil.readSystemIonHeapSizeFromDebugfs; Loading Loading @@ -3407,7 +3408,7 @@ public class StatsPullAtomService extends SystemService { pulledData.add(FrameworkStatsLog.buildStatsEvent(atomTag, metricsState.isTelephonyDetectionSupported(), metricsState.isGeoDetectionSupported(), metricsState.isUserLocationEnabled(), metricsState.getUserLocationEnabledSetting(), metricsState.getAutoDetectionEnabledSetting(), metricsState.getGeoDetectionEnabledSetting(), convertToMetricsDetectionMode(metricsState.getDetectionMode()), Loading @@ -3434,7 +3435,7 @@ public class StatsPullAtomService extends SystemService { case MetricsTimeZoneDetectorState.DETECTION_MODE_TELEPHONY: return TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__TELEPHONY; default: throw new IllegalArgumentException("" + detectionMode); return TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__UNKNOWN; } } Loading
services/core/java/com/android/server/timezonedetector/ConfigurationInternal.java +35 −35 Original line number Diff line number Diff line Loading @@ -39,21 +39,21 @@ public final class ConfigurationInternal { private final boolean mTelephonyDetectionSupported; private final boolean mGeoDetectionSupported; private final boolean mAutoDetectionEnabled; private final boolean mAutoDetectionEnabledSetting; private final @UserIdInt int mUserId; private final boolean mUserConfigAllowed; private final boolean mLocationEnabled; private final boolean mGeoDetectionEnabled; private final boolean mLocationEnabledSetting; private final boolean mGeoDetectionEnabledSetting; private ConfigurationInternal(Builder builder) { mTelephonyDetectionSupported = builder.mTelephonyDetectionSupported; mGeoDetectionSupported = builder.mGeoDetectionSupported; mAutoDetectionEnabled = builder.mAutoDetectionEnabled; mAutoDetectionEnabledSetting = builder.mAutoDetectionEnabledSetting; mUserId = builder.mUserId; mUserConfigAllowed = builder.mUserConfigAllowed; mLocationEnabled = builder.mLocationEnabled; mGeoDetectionEnabled = builder.mGeoDetectionEnabled; mLocationEnabledSetting = builder.mLocationEnabledSetting; mGeoDetectionEnabledSetting = builder.mGeoDetectionEnabledSetting; } /** Returns true if the device supports any form of auto time zone detection. */ Loading @@ -73,7 +73,7 @@ public final class ConfigurationInternal { /** Returns the value of the auto time zone detection enabled setting. */ public boolean getAutoDetectionEnabledSetting() { return mAutoDetectionEnabled; return mAutoDetectionEnabledSetting; } /** Loading @@ -81,7 +81,7 @@ public final class ConfigurationInternal { * from the raw setting value. */ public boolean getAutoDetectionEnabledBehavior() { return isAutoDetectionSupported() && mAutoDetectionEnabled; return isAutoDetectionSupported() && mAutoDetectionEnabledSetting; } /** Returns the ID of the user this configuration is associated with. */ Loading @@ -101,13 +101,13 @@ public final class ConfigurationInternal { } /** Returns true if user's location can be used generally. */ public boolean isLocationEnabled() { return mLocationEnabled; public boolean getLocationEnabledSetting() { return mLocationEnabledSetting; } /** Returns the value of the geolocation time zone detection enabled setting. */ public boolean getGeoDetectionEnabledSetting() { return mGeoDetectionEnabled; return mGeoDetectionEnabledSetting; } /** Loading @@ -117,7 +117,7 @@ public final class ConfigurationInternal { public boolean getGeoDetectionEnabledBehavior() { return getAutoDetectionEnabledBehavior() && isGeoDetectionSupported() && isLocationEnabled() && getLocationEnabledSetting() && getGeoDetectionEnabledSetting(); } Loading Loading @@ -154,7 +154,7 @@ public final class ConfigurationInternal { final int configureGeolocationDetectionEnabledCapability; if (!deviceHasLocationTimeZoneDetection) { configureGeolocationDetectionEnabledCapability = CAPABILITY_NOT_SUPPORTED; } else if (!mAutoDetectionEnabled || !isLocationEnabled()) { } else if (!mAutoDetectionEnabledSetting || !getLocationEnabledSetting()) { configureGeolocationDetectionEnabledCapability = CAPABILITY_NOT_APPLICABLE; } else { configureGeolocationDetectionEnabledCapability = CAPABILITY_POSSESSED; Loading Loading @@ -195,10 +195,10 @@ public final class ConfigurationInternal { public ConfigurationInternal merge(TimeZoneConfiguration newConfiguration) { Builder builder = new Builder(this); if (newConfiguration.hasIsAutoDetectionEnabled()) { builder.setAutoDetectionEnabled(newConfiguration.isAutoDetectionEnabled()); builder.setAutoDetectionEnabledSetting(newConfiguration.isAutoDetectionEnabled()); } if (newConfiguration.hasIsGeoDetectionEnabled()) { builder.setGeoDetectionEnabled(newConfiguration.isGeoDetectionEnabled()); builder.setGeoDetectionEnabledSetting(newConfiguration.isGeoDetectionEnabled()); } return builder.build(); } Loading @@ -216,16 +216,16 @@ public final class ConfigurationInternal { && mUserConfigAllowed == that.mUserConfigAllowed && mTelephonyDetectionSupported == that.mTelephonyDetectionSupported && mGeoDetectionSupported == that.mGeoDetectionSupported && mAutoDetectionEnabled == that.mAutoDetectionEnabled && mLocationEnabled == that.mLocationEnabled && mGeoDetectionEnabled == that.mGeoDetectionEnabled; && mAutoDetectionEnabledSetting == that.mAutoDetectionEnabledSetting && mLocationEnabledSetting == that.mLocationEnabledSetting && mGeoDetectionEnabledSetting == that.mGeoDetectionEnabledSetting; } @Override public int hashCode() { return Objects.hash(mUserId, mUserConfigAllowed, mTelephonyDetectionSupported, mGeoDetectionSupported, mAutoDetectionEnabled, mLocationEnabled, mGeoDetectionEnabled); mGeoDetectionSupported, mAutoDetectionEnabledSetting, mLocationEnabledSetting, mGeoDetectionEnabledSetting); } @Override Loading @@ -235,9 +235,9 @@ public final class ConfigurationInternal { + ", mUserConfigAllowed=" + mUserConfigAllowed + ", mTelephonyDetectionSupported=" + mTelephonyDetectionSupported + ", mGeoDetectionSupported=" + mGeoDetectionSupported + ", mAutoDetectionEnabled=" + mAutoDetectionEnabled + ", mLocationEnabled=" + mLocationEnabled + ", mGeoDetectionEnabled=" + mGeoDetectionEnabled + ", mAutoDetectionEnabledSetting=" + mAutoDetectionEnabledSetting + ", mLocationEnabledSetting=" + mLocationEnabledSetting + ", mGeoDetectionEnabledSetting=" + mGeoDetectionEnabledSetting + '}'; } Loading @@ -251,9 +251,9 @@ public final class ConfigurationInternal { private boolean mUserConfigAllowed; private boolean mTelephonyDetectionSupported; private boolean mGeoDetectionSupported; private boolean mAutoDetectionEnabled; private boolean mLocationEnabled; private boolean mGeoDetectionEnabled; private boolean mAutoDetectionEnabledSetting; private boolean mLocationEnabledSetting; private boolean mGeoDetectionEnabledSetting; /** * Creates a new Builder with only the userId set. Loading @@ -270,9 +270,9 @@ public final class ConfigurationInternal { this.mUserConfigAllowed = toCopy.mUserConfigAllowed; this.mTelephonyDetectionSupported = toCopy.mTelephonyDetectionSupported; this.mGeoDetectionSupported = toCopy.mGeoDetectionSupported; this.mAutoDetectionEnabled = toCopy.mAutoDetectionEnabled; this.mLocationEnabled = toCopy.mLocationEnabled; this.mGeoDetectionEnabled = toCopy.mGeoDetectionEnabled; this.mAutoDetectionEnabledSetting = toCopy.mAutoDetectionEnabledSetting; this.mLocationEnabledSetting = toCopy.mLocationEnabledSetting; this.mGeoDetectionEnabledSetting = toCopy.mGeoDetectionEnabledSetting; } /** Loading Loading @@ -302,24 +302,24 @@ public final class ConfigurationInternal { /** * Sets the value of the automatic time zone detection enabled setting for this device. */ public Builder setAutoDetectionEnabled(boolean enabled) { mAutoDetectionEnabled = enabled; public Builder setAutoDetectionEnabledSetting(boolean enabled) { mAutoDetectionEnabledSetting = enabled; return this; } /** * Sets the value of the location mode setting for this user. */ public Builder setLocationEnabled(boolean enabled) { mLocationEnabled = enabled; public Builder setLocationEnabledSetting(boolean enabled) { mLocationEnabledSetting = enabled; return this; } /** * Sets the value of the geolocation time zone detection setting for this user. */ public Builder setGeoDetectionEnabled(boolean enabled) { mGeoDetectionEnabled = enabled; public Builder setGeoDetectionEnabledSetting(boolean enabled) { mGeoDetectionEnabledSetting = enabled; return this; } Loading
services/core/java/com/android/server/timezonedetector/MetricsTimeZoneDetectorState.java +7 −12 Original line number Diff line number Diff line Loading @@ -56,16 +56,11 @@ public final class MetricsTimeZoneDetectorState { public static final @DetectionMode int DETECTION_MODE_GEO = 1; public static final @DetectionMode int DETECTION_MODE_TELEPHONY = 2; @NonNull private final ConfigurationInternal mConfigurationInternal; @NonNull @NonNull private final ConfigurationInternal mConfigurationInternal; private final int mDeviceTimeZoneIdOrdinal; @Nullable private final MetricsTimeZoneSuggestion mLatestManualSuggestion; @Nullable private final MetricsTimeZoneSuggestion mLatestTelephonySuggestion; @Nullable private final MetricsTimeZoneSuggestion mLatestGeolocationSuggestion; @Nullable private final MetricsTimeZoneSuggestion mLatestManualSuggestion; @Nullable private final MetricsTimeZoneSuggestion mLatestTelephonySuggestion; @Nullable private final MetricsTimeZoneSuggestion mLatestGeolocationSuggestion; private MetricsTimeZoneDetectorState( @NonNull ConfigurationInternal configurationInternal, Loading Loading @@ -117,8 +112,8 @@ public final class MetricsTimeZoneDetectorState { } /** Returns true if user's location can be used generally. */ public boolean isUserLocationEnabled() { return mConfigurationInternal.isLocationEnabled(); public boolean getUserLocationEnabledSetting() { return mConfigurationInternal.getLocationEnabledSetting(); } /** Returns the value of the geolocation time zone detection enabled setting. */ Loading Loading @@ -149,7 +144,6 @@ public final class MetricsTimeZoneDetectorState { * Returns the ordinal for the device's currently set time zone ID. * See {@link MetricsTimeZoneDetectorState} for information about ordinals. */ @NonNull public int getDeviceTimeZoneIdOrdinal() { return mDeviceTimeZoneIdOrdinal; } Loading Loading @@ -281,6 +275,7 @@ public final class MetricsTimeZoneDetectorState { return new MetricsTimeZoneSuggestion(null); } @NonNull public static MetricsTimeZoneSuggestion createCertain( @NonNull int[] zoneIdOrdinals) { return new MetricsTimeZoneSuggestion(zoneIdOrdinals); Loading
services/core/java/com/android/server/timezonedetector/ServiceConfigAccessorImpl.java +11 −11 Original line number Diff line number Diff line Loading @@ -281,8 +281,8 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { // later releases that start to support geo detection on the same hardware. if (!getGeoDetectionSettingEnabledOverride().isPresent() && isGeoTimeZoneDetectionFeatureSupported()) { final boolean geoTzDetectionEnabled = configuration.isGeoDetectionEnabled(); setGeoDetectionEnabledIfRequired(userId, geoTzDetectionEnabled); final boolean geoDetectionEnabledSetting = configuration.isGeoDetectionEnabled(); setGeoDetectionEnabledSettingIfRequired(userId, geoDetectionEnabledSetting); } } } Loading @@ -294,10 +294,10 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { .setTelephonyDetectionFeatureSupported( isTelephonyTimeZoneDetectionFeatureSupported()) .setGeoDetectionFeatureSupported(isGeoTimeZoneDetectionFeatureSupported()) .setAutoDetectionEnabled(isAutoDetectionEnabled()) .setAutoDetectionEnabledSetting(getAutoDetectionEnabledSetting()) .setUserConfigAllowed(isUserConfigAllowed(userId)) .setLocationEnabled(isLocationEnabled(userId)) .setGeoDetectionEnabled(isGeoDetectionEnabled(userId)) .setLocationEnabledSetting(getLocationEnabledSetting(userId)) .setGeoDetectionEnabledSetting(getGeoDetectionEnabledSetting(userId)) .build(); } Loading @@ -306,12 +306,12 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { // a ConfigurationChangeListener callback triggering due to ContentObserver's still // triggering *sometimes* for no-op updates. Because callbacks are async this is necessary // for stable behavior during tests. if (isAutoDetectionEnabled() != enabled) { if (getAutoDetectionEnabledSetting() != enabled) { Settings.Global.putInt(mCr, Settings.Global.AUTO_TIME_ZONE, enabled ? 1 : 0); } } private boolean isLocationEnabled(@UserIdInt int userId) { private boolean getLocationEnabledSetting(@UserIdInt int userId) { return mLocationManager.isLocationEnabledForUser(UserHandle.of(userId)); } Loading @@ -320,11 +320,11 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { return !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_DATE_TIME, userHandle); } private boolean isAutoDetectionEnabled() { private boolean getAutoDetectionEnabledSetting() { return Settings.Global.getInt(mCr, Settings.Global.AUTO_TIME_ZONE, 1 /* default */) > 0; } private boolean isGeoDetectionEnabled(@UserIdInt int userId) { private boolean getGeoDetectionEnabledSetting(@UserIdInt int userId) { // We may never use this, but it gives us a way to force location-based time zone detection // on/off for testers (but only where their other settings would allow them to turn it on // for themselves). Loading @@ -339,9 +339,9 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { (geoDetectionEnabledByDefault ? 1 : 0) /* defaultValue */, userId) != 0; } private void setGeoDetectionEnabledIfRequired(@UserIdInt int userId, boolean enabled) { private void setGeoDetectionEnabledSettingIfRequired(@UserIdInt int userId, boolean enabled) { // See comment in setAutoDetectionEnabledIfRequired. http://b/171953500 if (isGeoDetectionEnabled(userId) != enabled) { if (getGeoDetectionEnabledSetting(userId) != enabled) { Settings.Secure.putIntForUser(mCr, Settings.Secure.LOCATION_TIME_ZONE_DETECTION_ENABLED, enabled ? 1 : 0, userId); } Loading
services/tests/servicestests/src/com/android/server/timezonedetector/ConfigurationInternalTest.java +20 −20 Original line number Diff line number Diff line Loading @@ -48,13 +48,13 @@ public class ConfigurationInternalTest { .setUserConfigAllowed(true) .setTelephonyDetectionFeatureSupported(true) .setGeoDetectionFeatureSupported(true) .setAutoDetectionEnabled(true) .setLocationEnabled(true) .setGeoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .setLocationEnabledSetting(true) .setGeoDetectionEnabledSetting(true) .build(); { ConfigurationInternal autoOnConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .build(); assertTrue(autoOnConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOnConfig.getGeoDetectionEnabledSetting()); Loading @@ -79,7 +79,7 @@ public class ConfigurationInternalTest { { ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(false) .setAutoDetectionEnabledSetting(false) .build(); assertFalse(autoOffConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOffConfig.getGeoDetectionEnabledSetting()); Loading Loading @@ -110,13 +110,13 @@ public class ConfigurationInternalTest { .setUserConfigAllowed(false) .setTelephonyDetectionFeatureSupported(true) .setGeoDetectionFeatureSupported(true) .setAutoDetectionEnabled(true) .setLocationEnabled(true) .setGeoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .setLocationEnabledSetting(true) .setGeoDetectionEnabledSetting(true) .build(); { ConfigurationInternal autoOnConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .build(); assertTrue(autoOnConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOnConfig.getGeoDetectionEnabledSetting()); Loading @@ -142,7 +142,7 @@ public class ConfigurationInternalTest { { ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(false) .setAutoDetectionEnabledSetting(false) .build(); assertFalse(autoOffConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOffConfig.getGeoDetectionEnabledSetting()); Loading Loading @@ -174,13 +174,13 @@ public class ConfigurationInternalTest { .setUserConfigAllowed(true) .setTelephonyDetectionFeatureSupported(false) .setGeoDetectionFeatureSupported(false) .setAutoDetectionEnabled(true) .setLocationEnabled(true) .setGeoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .setLocationEnabledSetting(true) .setGeoDetectionEnabledSetting(true) .build(); { ConfigurationInternal autoOnConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .build(); assertTrue(autoOnConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOnConfig.getGeoDetectionEnabledSetting()); Loading @@ -203,7 +203,7 @@ public class ConfigurationInternalTest { } { ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(false) .setAutoDetectionEnabledSetting(false) .build(); assertFalse(autoOffConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOffConfig.getGeoDetectionEnabledSetting()); Loading Loading @@ -236,13 +236,13 @@ public class ConfigurationInternalTest { .setUserConfigAllowed(true) .setTelephonyDetectionFeatureSupported(true) .setGeoDetectionFeatureSupported(false) .setAutoDetectionEnabled(true) .setLocationEnabled(true) .setGeoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .setLocationEnabledSetting(true) .setGeoDetectionEnabledSetting(true) .build(); { ConfigurationInternal autoOnConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(true) .setAutoDetectionEnabledSetting(true) .build(); assertTrue(autoOnConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOnConfig.getGeoDetectionEnabledSetting()); Loading @@ -266,7 +266,7 @@ public class ConfigurationInternalTest { } { ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig) .setAutoDetectionEnabled(false) .setAutoDetectionEnabledSetting(false) .build(); assertFalse(autoOffConfig.getAutoDetectionEnabledSetting()); assertTrue(autoOffConfig.getGeoDetectionEnabledSetting()); Loading