Refactorings to clarify settings code
Refactorings to make what config comes from settings more obvious. Minor other fixes. No significant functional changes intended. Test: TBD Bug: 200279201 Change-Id: I7a1a104eb1d798794ce14b5bb6ee7f0743f1da17
This commit is contained in:
@@ -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;
|
||||
@@ -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()),
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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. */
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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. */
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +117,7 @@ public final class ConfigurationInternal {
|
||||
public boolean getGeoDetectionEnabledBehavior() {
|
||||
return getAutoDetectionEnabledBehavior()
|
||||
&& isGeoDetectionSupported()
|
||||
&& isLocationEnabled()
|
||||
&& getLocationEnabledSetting()
|
||||
&& getGeoDetectionEnabledSetting();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
@@ -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. */
|
||||
@@ -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;
|
||||
}
|
||||
@@ -281,6 +275,7 @@ public final class MetricsTimeZoneDetectorState {
|
||||
return new MetricsTimeZoneSuggestion(null);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static MetricsTimeZoneSuggestion createCertain(
|
||||
@NonNull int[] zoneIdOrdinals) {
|
||||
return new MetricsTimeZoneSuggestion(zoneIdOrdinals);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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).
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
@@ -79,7 +79,7 @@ public class ConfigurationInternalTest {
|
||||
|
||||
{
|
||||
ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig)
|
||||
.setAutoDetectionEnabled(false)
|
||||
.setAutoDetectionEnabledSetting(false)
|
||||
.build();
|
||||
assertFalse(autoOffConfig.getAutoDetectionEnabledSetting());
|
||||
assertTrue(autoOffConfig.getGeoDetectionEnabledSetting());
|
||||
@@ -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());
|
||||
@@ -142,7 +142,7 @@ public class ConfigurationInternalTest {
|
||||
|
||||
{
|
||||
ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig)
|
||||
.setAutoDetectionEnabled(false)
|
||||
.setAutoDetectionEnabledSetting(false)
|
||||
.build();
|
||||
assertFalse(autoOffConfig.getAutoDetectionEnabledSetting());
|
||||
assertTrue(autoOffConfig.getGeoDetectionEnabledSetting());
|
||||
@@ -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());
|
||||
@@ -203,7 +203,7 @@ public class ConfigurationInternalTest {
|
||||
}
|
||||
{
|
||||
ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig)
|
||||
.setAutoDetectionEnabled(false)
|
||||
.setAutoDetectionEnabledSetting(false)
|
||||
.build();
|
||||
assertFalse(autoOffConfig.getAutoDetectionEnabledSetting());
|
||||
assertTrue(autoOffConfig.getGeoDetectionEnabledSetting());
|
||||
@@ -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());
|
||||
@@ -266,7 +266,7 @@ public class ConfigurationInternalTest {
|
||||
}
|
||||
{
|
||||
ConfigurationInternal autoOffConfig = new ConfigurationInternal.Builder(baseConfig)
|
||||
.setAutoDetectionEnabled(false)
|
||||
.setAutoDetectionEnabledSetting(false)
|
||||
.build();
|
||||
assertFalse(autoOffConfig.getAutoDetectionEnabledSetting());
|
||||
assertTrue(autoOffConfig.getGeoDetectionEnabledSetting());
|
||||
|
||||
@@ -369,16 +369,16 @@ public class TimeZoneDetectorServiceTest {
|
||||
}
|
||||
|
||||
private static ConfigurationInternal createConfigurationInternal(boolean autoDetectionEnabled) {
|
||||
// Default geo detection settings from auto detection settings - they are not important to
|
||||
// the tests.
|
||||
// Default geo detection settings from the auto detection setting - they are not important
|
||||
// to the tests.
|
||||
final boolean geoDetectionEnabled = autoDetectionEnabled;
|
||||
return new ConfigurationInternal.Builder(ARBITRARY_USER_ID)
|
||||
.setTelephonyDetectionFeatureSupported(true)
|
||||
.setGeoDetectionFeatureSupported(true)
|
||||
.setUserConfigAllowed(true)
|
||||
.setAutoDetectionEnabled(autoDetectionEnabled)
|
||||
.setLocationEnabled(geoDetectionEnabled)
|
||||
.setGeoDetectionEnabled(geoDetectionEnabled)
|
||||
.setAutoDetectionEnabledSetting(autoDetectionEnabled)
|
||||
.setLocationEnabledSetting(geoDetectionEnabled)
|
||||
.setGeoDetectionEnabledSetting(geoDetectionEnabled)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,9 @@ public class TimeZoneDetectorStrategyImplTest {
|
||||
.setUserConfigAllowed(false)
|
||||
.setTelephonyDetectionFeatureSupported(true)
|
||||
.setGeoDetectionFeatureSupported(true)
|
||||
.setAutoDetectionEnabled(false)
|
||||
.setLocationEnabled(true)
|
||||
.setGeoDetectionEnabled(false)
|
||||
.setAutoDetectionEnabledSetting(false)
|
||||
.setLocationEnabledSetting(true)
|
||||
.setGeoDetectionEnabledSetting(false)
|
||||
.build();
|
||||
|
||||
private static final ConfigurationInternal CONFIG_USER_RESTRICTED_AUTO_ENABLED =
|
||||
@@ -99,9 +99,9 @@ public class TimeZoneDetectorStrategyImplTest {
|
||||
.setUserConfigAllowed(false)
|
||||
.setTelephonyDetectionFeatureSupported(true)
|
||||
.setGeoDetectionFeatureSupported(true)
|
||||
.setAutoDetectionEnabled(true)
|
||||
.setLocationEnabled(true)
|
||||
.setGeoDetectionEnabled(true)
|
||||
.setAutoDetectionEnabledSetting(true)
|
||||
.setLocationEnabledSetting(true)
|
||||
.setGeoDetectionEnabledSetting(true)
|
||||
.build();
|
||||
|
||||
private static final ConfigurationInternal CONFIG_AUTO_DETECT_NOT_SUPPORTED =
|
||||
@@ -109,9 +109,9 @@ public class TimeZoneDetectorStrategyImplTest {
|
||||
.setUserConfigAllowed(true)
|
||||
.setTelephonyDetectionFeatureSupported(false)
|
||||
.setGeoDetectionFeatureSupported(false)
|
||||
.setAutoDetectionEnabled(false)
|
||||
.setLocationEnabled(true)
|
||||
.setGeoDetectionEnabled(false)
|
||||
.setAutoDetectionEnabledSetting(false)
|
||||
.setLocationEnabledSetting(true)
|
||||
.setGeoDetectionEnabledSetting(false)
|
||||
.build();
|
||||
|
||||
private static final ConfigurationInternal CONFIG_AUTO_DISABLED_GEO_DISABLED =
|
||||
@@ -119,9 +119,9 @@ public class TimeZoneDetectorStrategyImplTest {
|
||||
.setUserConfigAllowed(true)
|
||||
.setTelephonyDetectionFeatureSupported(true)
|
||||
.setGeoDetectionFeatureSupported(true)
|
||||
.setAutoDetectionEnabled(false)
|
||||
.setLocationEnabled(true)
|
||||
.setGeoDetectionEnabled(false)
|
||||
.setAutoDetectionEnabledSetting(false)
|
||||
.setLocationEnabledSetting(true)
|
||||
.setGeoDetectionEnabledSetting(false)
|
||||
.build();
|
||||
|
||||
private static final ConfigurationInternal CONFIG_AUTO_ENABLED_GEO_DISABLED =
|
||||
@@ -129,9 +129,9 @@ public class TimeZoneDetectorStrategyImplTest {
|
||||
.setTelephonyDetectionFeatureSupported(true)
|
||||
.setGeoDetectionFeatureSupported(true)
|
||||
.setUserConfigAllowed(true)
|
||||
.setAutoDetectionEnabled(true)
|
||||
.setLocationEnabled(true)
|
||||
.setGeoDetectionEnabled(false)
|
||||
.setAutoDetectionEnabledSetting(true)
|
||||
.setLocationEnabledSetting(true)
|
||||
.setGeoDetectionEnabledSetting(false)
|
||||
.build();
|
||||
|
||||
private static final ConfigurationInternal CONFIG_AUTO_ENABLED_GEO_ENABLED =
|
||||
@@ -139,9 +139,9 @@ public class TimeZoneDetectorStrategyImplTest {
|
||||
.setTelephonyDetectionFeatureSupported(true)
|
||||
.setGeoDetectionFeatureSupported(true)
|
||||
.setUserConfigAllowed(true)
|
||||
.setAutoDetectionEnabled(true)
|
||||
.setLocationEnabled(true)
|
||||
.setGeoDetectionEnabled(true)
|
||||
.setAutoDetectionEnabledSetting(true)
|
||||
.setLocationEnabledSetting(true)
|
||||
.setGeoDetectionEnabledSetting(true)
|
||||
.build();
|
||||
|
||||
private TimeZoneDetectorStrategyImpl mTimeZoneDetectorStrategy;
|
||||
@@ -531,7 +531,7 @@ public class TimeZoneDetectorStrategyImplTest {
|
||||
boolean geoDetectionEnabled) {
|
||||
ConfigurationInternal geoTzEnabledConfig =
|
||||
new ConfigurationInternal.Builder(CONFIG_AUTO_ENABLED_GEO_DISABLED)
|
||||
.setGeoDetectionEnabled(geoDetectionEnabled)
|
||||
.setGeoDetectionEnabledSetting(geoDetectionEnabled)
|
||||
.build();
|
||||
Script script = new Script()
|
||||
.initializeTimeZoneSetting(ARBITRARY_TIME_ZONE_ID)
|
||||
@@ -792,8 +792,8 @@ public class TimeZoneDetectorStrategyImplTest {
|
||||
|
||||
// Update the config and confirm that the config metrics state updates also.
|
||||
expectedInternalConfig = new ConfigurationInternal.Builder(expectedInternalConfig)
|
||||
.setAutoDetectionEnabled(true)
|
||||
.setGeoDetectionEnabled(true)
|
||||
.setAutoDetectionEnabledSetting(true)
|
||||
.setGeoDetectionEnabledSetting(true)
|
||||
.build();
|
||||
|
||||
expectedDeviceTimeZoneId = geolocationTimeZoneSuggestion.getZoneIds().get(0);
|
||||
@@ -963,7 +963,7 @@ public class TimeZoneDetectorStrategyImplTest {
|
||||
Script simulateSetAutoMode(boolean autoDetectionEnabled) {
|
||||
ConfigurationInternal newConfig = new ConfigurationInternal.Builder(
|
||||
mFakeEnvironment.getCurrentUserConfigurationInternal())
|
||||
.setAutoDetectionEnabled(autoDetectionEnabled)
|
||||
.setAutoDetectionEnabledSetting(autoDetectionEnabled)
|
||||
.build();
|
||||
simulateConfigurationInternalChange(newConfig);
|
||||
return this;
|
||||
@@ -975,7 +975,7 @@ public class TimeZoneDetectorStrategyImplTest {
|
||||
Script simulateSetGeoDetectionEnabled(boolean geoDetectionEnabled) {
|
||||
ConfigurationInternal newConfig = new ConfigurationInternal.Builder(
|
||||
mFakeEnvironment.getCurrentUserConfigurationInternal())
|
||||
.setGeoDetectionEnabled(geoDetectionEnabled)
|
||||
.setGeoDetectionEnabledSetting(geoDetectionEnabled)
|
||||
.build();
|
||||
simulateConfigurationInternalChange(newConfig);
|
||||
return this;
|
||||
|
||||
@@ -41,14 +41,14 @@ final class TestSupport {
|
||||
}
|
||||
|
||||
private static ConfigurationInternal createUserConfig(
|
||||
@UserIdInt int userId, boolean geoDetectionEnabled) {
|
||||
@UserIdInt int userId, boolean geoDetectionEnabledSetting) {
|
||||
return new ConfigurationInternal.Builder(userId)
|
||||
.setUserConfigAllowed(true)
|
||||
.setTelephonyDetectionFeatureSupported(true)
|
||||
.setGeoDetectionFeatureSupported(true)
|
||||
.setAutoDetectionEnabled(true)
|
||||
.setLocationEnabled(true)
|
||||
.setGeoDetectionEnabled(geoDetectionEnabled)
|
||||
.setAutoDetectionEnabledSetting(true)
|
||||
.setLocationEnabledSetting(true)
|
||||
.setGeoDetectionEnabledSetting(geoDetectionEnabledSetting)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user