Updated toggles in Date and time settings page
Design doc: go/dd-android-settings-time-2024 Changes: - toggling off "automatic time zone" now sets "use location" off and makes it unmodifiable - removing "use locale default" for time format Bug: 296835792 Test: on-device and atest Flag: com.android.settings.flags.revamp_toggles Change-Id: I31744f104fed06ee9980a6a0160501325175a02d
This commit is contained in:
@@ -40,12 +40,17 @@ import android.app.time.TimeZoneConfiguration;
|
||||
import android.app.time.TimeZoneDetectorStatus;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.flags.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -57,6 +62,9 @@ import org.robolectric.RuntimeEnvironment;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AutoTimeZonePreferenceControllerTest {
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
@Mock
|
||||
private UpdateTimeAndDateCallback mCallback;
|
||||
private Context mContext;
|
||||
@@ -238,8 +246,53 @@ public class AutoTimeZonePreferenceControllerTest {
|
||||
mContext.getString(R.string.auto_zone_requires_location_summary));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags({Flags.FLAG_REVAMP_TOGGLES})
|
||||
public void toggleOff_revampFlagOn_shouldToggleOffUseLocation() {
|
||||
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig = createCapabilitiesAndConfig(
|
||||
/* autoSupported= */ true,
|
||||
/* autoEnabled= */ true,
|
||||
/* telephonySupported= */ true,
|
||||
/* locationSupported= */ true);
|
||||
when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
|
||||
|
||||
mController.setChecked(false);
|
||||
|
||||
TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
|
||||
.setAutoDetectionEnabled(false)
|
||||
.setGeoDetectionEnabled(false)
|
||||
.build();
|
||||
|
||||
verify(mTimeManager).updateTimeZoneConfiguration(configuration);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags({Flags.FLAG_REVAMP_TOGGLES})
|
||||
public void toggleOff_revampFlagOff_shouldToggleOffUseLocation() {
|
||||
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig = createCapabilitiesAndConfig(
|
||||
/* autoSupported= */ true,
|
||||
/* autoEnabled= */ true,
|
||||
/* telephonySupported= */ true,
|
||||
/* locationSupported= */ true);
|
||||
when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
|
||||
|
||||
mController.setChecked(false);
|
||||
|
||||
TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
|
||||
.setAutoDetectionEnabled(false)
|
||||
.build();
|
||||
|
||||
verify(mTimeManager).updateTimeZoneConfiguration(configuration);
|
||||
}
|
||||
|
||||
private static TimeZoneCapabilitiesAndConfig createCapabilitiesAndConfig(
|
||||
boolean autoSupported, boolean autoEnabled, boolean telephonySupported) {
|
||||
return createCapabilitiesAndConfig(autoSupported, autoEnabled, telephonySupported, false);
|
||||
}
|
||||
|
||||
private static TimeZoneCapabilitiesAndConfig createCapabilitiesAndConfig(
|
||||
boolean autoSupported, boolean autoEnabled, boolean telephonySupported,
|
||||
boolean locationSupported) {
|
||||
TimeZoneDetectorStatus status = new TimeZoneDetectorStatus(DETECTOR_STATUS_RUNNING,
|
||||
new TelephonyTimeZoneAlgorithmStatus(
|
||||
telephonySupported ? DETECTION_ALGORITHM_STATUS_RUNNING
|
||||
@@ -253,12 +306,14 @@ public class AutoTimeZonePreferenceControllerTest {
|
||||
TimeZoneCapabilities capabilities = new TimeZoneCapabilities.Builder(UserHandle.SYSTEM)
|
||||
.setConfigureAutoDetectionEnabledCapability(configureAutoDetectionEnabledCapability)
|
||||
.setUseLocationEnabled(true)
|
||||
.setConfigureGeoDetectionEnabledCapability(Capabilities.CAPABILITY_NOT_SUPPORTED)
|
||||
.setConfigureGeoDetectionEnabledCapability(
|
||||
locationSupported ? Capabilities.CAPABILITY_POSSESSED
|
||||
: Capabilities.CAPABILITY_NOT_SUPPORTED)
|
||||
.setSetManualTimeZoneCapability(Capabilities.CAPABILITY_POSSESSED)
|
||||
.build();
|
||||
TimeZoneConfiguration config = new TimeZoneConfiguration.Builder()
|
||||
.setAutoDetectionEnabled(autoEnabled)
|
||||
.setGeoDetectionEnabled(false)
|
||||
.setGeoDetectionEnabled(locationSupported)
|
||||
.build();
|
||||
return new TimeZoneCapabilitiesAndConfig(status, capabilities, config);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user