diff options
| author | Jim Miller <jaggies@google.com> | 2010-04-13 15:31:41 -0700 |
|---|---|---|
| committer | Jim Miller <jaggies@google.com> | 2010-04-13 15:31:41 -0700 |
| commit | fc5a02225e8bca21f07543f55e1b51a33670c501 (patch) | |
| tree | fb49303a8a2b1db1fa556335b29e78c0e989e6fc | |
| parent | fced126829a74c9cbe9cbe993a3c54d1ff015a73 (diff) | |
| download | packages_apps_Settings-fc5a02225e8bca21f07543f55e1b51a33670c501.zip packages_apps_Settings-fc5a02225e8bca21f07543f55e1b51a33670c501.tar.gz packages_apps_Settings-fc5a02225e8bca21f07543f55e1b51a33670c501.tar.bz2 | |
Fix 2582241: Update selection based on user setting instead.
When the user adds a DPM, Settings removes all display
timeout options with t > maxTimeout. It was incorrectly
setting the preference to maxTimeout.
The corrected code picks the user's preference if less
than maxTimeout or nothing otherwise.
Change-Id: I5a47fdce89f4cf216fd76bb585c3c0120b39db92
| -rw-r--r-- | src/com/android/settings/DisplaySettings.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java index 813df00..fbb07c1 100644 --- a/src/com/android/settings/DisplaySettings.java +++ b/src/com/android/settings/DisplaySettings.java @@ -74,9 +74,9 @@ public class DisplaySettings extends PreferenceActivity implements } private void disableUnusableTimeouts(ListPreference screenTimeoutPreference) { - DevicePolicyManager dpm = + final DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); - long maxTimeout = dpm != null ? dpm.getMaximumTimeToLock(null) : 0; + final long maxTimeout = dpm != null ? dpm.getMaximumTimeToLock(null) : 0; if (maxTimeout == 0) { return; // policy not enforced } @@ -96,7 +96,14 @@ public class DisplaySettings extends PreferenceActivity implements revisedEntries.toArray(new CharSequence[revisedEntries.size()])); screenTimeoutPreference.setEntryValues( revisedValues.toArray(new CharSequence[revisedValues.size()])); - screenTimeoutPreference.setValue(String.valueOf(maxTimeout)); + final int userPreference = Integer.valueOf(screenTimeoutPreference.getValue()); + if (userPreference <= maxTimeout) { + screenTimeoutPreference.setValue(String.valueOf(userPreference)); + } else { + // There will be no highlighted selection since nothing in the list matches + // maxTimeout. The user can still select anything less than maxTimeout. + // TODO: maybe append maxTimeout to the list and mark selected. + } } screenTimeoutPreference.setEnabled(revisedEntries.size() > 0); } |
