diff options
author | Dianne Hackborn <hackbod@google.com> | 2012-06-15 17:07:14 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2012-06-15 17:07:14 -0700 |
commit | f34a8d75177f52bffeceaf308b65860015b45d5e (patch) | |
tree | 189a68390ba9b7bee4738f068a8abf22758e0f84 /src | |
parent | 5ea994c552ea72385022c0c81b8b69acbe30a113 (diff) | |
download | packages_apps_settings-f34a8d75177f52bffeceaf308b65860015b45d5e.zip packages_apps_settings-f34a8d75177f52bffeceaf308b65860015b45d5e.tar.gz packages_apps_settings-f34a8d75177f52bffeceaf308b65860015b45d5e.tar.bz2 |
Fix issue #6664140: Time to lock should work even Stay awake...
...in Developer options is on
Disable the stay awake while on option in settings if a lock limit
is being enforced.
Bug: 6664140
Change-Id: I8da1b8c734ceef10662d33392609c35e645315c3
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/DevelopmentSettings.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index 29c58ab..f5789ae 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -25,6 +25,7 @@ import android.app.ActivityThread; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; +import android.app.admin.DevicePolicyManager; import android.app.backup.IBackupManager; import android.content.ContentResolver; import android.content.Context; @@ -61,6 +62,7 @@ import android.widget.CompoundButton; import android.widget.Switch; import java.util.ArrayList; +import java.util.HashSet; /* * Displays preferences for application developers. @@ -108,6 +110,7 @@ public class DevelopmentSettings extends PreferenceFragment private IWindowManager mWindowManager; private IBackupManager mBackupManager; + private DevicePolicyManager mDpm; private Switch mEnabledSwitch; private boolean mLastEnabledState; @@ -148,6 +151,8 @@ public class DevelopmentSettings extends PreferenceFragment private final ArrayList<CheckBoxPreference> mResetCbPrefs = new ArrayList<CheckBoxPreference>(); + private final HashSet<Preference> mDisabledPrefs = new HashSet<Preference>(); + // To track whether a confirmation dialog was clicked. private boolean mDialogClicked; private Dialog mEnableDialog; @@ -160,6 +165,7 @@ public class DevelopmentSettings extends PreferenceFragment mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); mBackupManager = IBackupManager.Stub.asInterface( ServiceManager.getService(Context.BACKUP_SERVICE)); + mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE); addPreferencesFromResource(R.xml.development_prefs); @@ -278,7 +284,8 @@ public class DevelopmentSettings extends PreferenceFragment private void setPrefsEnabledState(boolean enabled) { for (int i = 0; i < mAllPrefs.size(); i++) { - mAllPrefs.get(i).setEnabled(enabled); + Preference pref = mAllPrefs.get(i); + pref.setEnabled(enabled && !mDisabledPrefs.contains(pref)); } updateAllOptions(); } @@ -287,6 +294,16 @@ public class DevelopmentSettings extends PreferenceFragment public void onResume() { super.onResume(); + if (mDpm.getMaximumTimeToLock(null) > 0) { + // A DeviceAdmin has specified a maximum time until the device + // will lock... in this case we can't allow the user to turn + // on "stay awake when plugged in" because that would defeat the + // restriction. + mDisabledPrefs.add(mKeepScreenOn); + } else { + mDisabledPrefs.remove(mKeepScreenOn); + } + final ContentResolver cr = getActivity().getContentResolver(); mLastEnabledState = Settings.Secure.getInt(cr, Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; |