Fix maximum time to lock
Changes
* Restore previous timeout behaviour. This
behaviour was modified in Android S and
was previously working on Android R.
* If the selected timeout is less than
the max timeout set by the admin, select
the largest possible timeout.
* If there are no possible timeouts for the
user, disable the preference.
Manual testing steps
* Download CtsVerifier and CtsEmptyDeviceOwner apks
* Set device owner
* Run Policy transparency test > set max time to lock
* Set max time to lock and verify correct value is
shown in Settings. Compare behaviour with Android R.
Bug: 184104507
Test: manual testing
atest com.android.settings.display.ScreenTimeoutSettingsTest
Change-Id: I8d0e66ccce14cca244bcd380fd225a31df0b8999
This commit is contained in:
@@ -145,6 +145,16 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
||||
screen.addPreference(pref);
|
||||
}
|
||||
|
||||
final long selectedTimeout = Long.parseLong(defaultKey);
|
||||
final long maxTimeout = getMaxScreenTimeout(getContext());
|
||||
if (!candidateList.isEmpty() && (selectedTimeout > maxTimeout)) {
|
||||
// The selected time out value is longer than the max timeout allowed by the admin.
|
||||
// Select the largest value from the list by default.
|
||||
final RadioButtonPreference preferenceWithLargestTimeout =
|
||||
(RadioButtonPreference) screen.getPreference(candidateList.size() - 1);
|
||||
preferenceWithLargestTimeout.setChecked(true);
|
||||
}
|
||||
|
||||
if (isScreenAttentionAvailable(getContext())) {
|
||||
mAdaptiveSleepPermissionController.addToScreen(screen);
|
||||
mAdaptiveSleepController.addToScreen(screen);
|
||||
|
||||
Reference in New Issue
Block a user