diff options
author | Brandon McAnsh <brandon.mcansh@gmail.com> | 2015-06-22 09:26:25 -0400 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2015-11-03 11:56:04 -0800 |
commit | e06cbb57173c3c8206db74a3fdf26553c52ae969 (patch) | |
tree | 028fccf19cc25be0379c0610ef8ea6689581b73e /src | |
parent | 4705f54afbe860337ef1dd9745d3ba9b889d04e3 (diff) | |
download | packages_apps_Settings-e06cbb57173c3c8206db74a3fdf26553c52ae969.zip packages_apps_Settings-e06cbb57173c3c8206db74a3fdf26553c52ae969.tar.gz packages_apps_Settings-e06cbb57173c3c8206db74a3fdf26553c52ae969.tar.bz2 |
Development: Add choices to 'Stay Awake' preference
* Per a request on Google+ for Google Engineers to add to M, the stay awake values
can now be never, while usb debugging, and always.
* Keep them pixels awake.
Change-Id: I7f43200bab0f000dc7547cc3142c4cacda2f4732
Signed-off-by: Brandon McAnsh <brandon.mcansh@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/DevelopmentSettings.java | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index 0c55cb3..916788d 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -110,7 +110,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private static final String ADB_TCPIP = "adb_over_network"; private static final String CLEAR_ADB_KEYS = "clear_adb_keys"; private static final String ENABLE_TERMINAL = "enable_terminal"; - private static final String KEEP_SCREEN_ON = "keep_screen_on"; + private static final String KEEP_SCREEN_ON_MODES = "keep_screen_on_modes"; private static final String BT_HCI_SNOOP_LOG = "bt_hci_snoop_log"; private static final String ENABLE_OEM_UNLOCK = "oem_unlock_enable"; private static final String HDCP_CHECKING_KEY = "hdcp_checking"; @@ -212,7 +212,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private SwitchPreference mEnableTerminal; private Preference mBugreport; private SwitchPreference mBugreportInPower; - private SwitchPreference mKeepScreenOn; + private ListPreference mKeepScreenOn; private SwitchPreference mBtHciSnoopLog; private SwitchPreference mEnableOemUnlock; private SwitchPreference mDebugViewAttributes; @@ -334,7 +334,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment mBugreport = findPreference(BUGREPORT); mBugreportInPower = findAndInitSwitchPref(BUGREPORT_IN_POWER_KEY); - mKeepScreenOn = findAndInitSwitchPref(KEEP_SCREEN_ON); + mKeepScreenOn = addListPreference(KEEP_SCREEN_ON_MODES); mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG); mEnableOemUnlock = findAndInitSwitchPref(ENABLE_OEM_UNLOCK); if (!showEnableOemUnlockPreference()) { @@ -602,8 +602,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment } updateSwitchPreference(mBugreportInPower, Settings.Secure.getInt(cr, Settings.Secure.BUGREPORT_IN_POWER_MENU, 0) != 0); - updateSwitchPreference(mKeepScreenOn, Settings.Global.getInt(cr, - Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0) != 0); + updateStayAwakeOptions(); updateSwitchPreference(mBtHciSnoopLog, Settings.Secure.getInt(cr, Settings.Secure.BLUETOOTH_HCI_LOG, 0) != 0); if (mEnableOemUnlock != null) { @@ -749,6 +748,23 @@ public class DevelopmentSettings extends SettingsPreferenceFragment updateRootAccessOptions(); } + private void updateStayAwakeOptions() { + int index = Settings.Global.getInt(getActivity().getContentResolver(), + Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0); + final String[] values = getResources().getStringArray(R.array.keep_screen_on_values); + final String[] summaries = getResources().getStringArray(R.array.keep_screen_on_titles); + // The old value contained 0 (disable) or 3 (BATTERY_PLUGGED_AC|BATTERY_PLUGGED_USB) + // Currently only have 3 values (0: Not enabled; 1: debugging over usb; >2: charging) + // NOTE: If we have newer values, then we need to migrate + // this property + if (index >= values.length) { + index = values.length - 1; + } + mKeepScreenOn.setValue(values[index]); + mKeepScreenOn.setSummary(summaries[index]); + mKeepScreenOn.setOnPreferenceChangeListener(this); + } + private void updateHdcpValues() { ListPreference hdcpChecking = (ListPreference) findPreference(HDCP_CHECKING_KEY); if (hdcpChecking != null) { @@ -1145,6 +1161,13 @@ public class DevelopmentSettings extends SettingsPreferenceFragment mShowNonRectClip.setSummary(mShowNonRectClip.getEntries()[0]); } + private void writeStayAwakeOptions(Object newValue) { + int val = Integer.parseInt((String) newValue); + Settings.Global.putInt(getActivity().getContentResolver(), + Settings.Global.STAY_ON_WHILE_PLUGGED_IN, val); + updateStayAwakeOptions(); + } + private void writeShowNonRectClipOptions(Object newValue) { SystemProperties.set(HardwareRenderer.DEBUG_SHOW_NON_RECTANGULAR_CLIP_PROPERTY, newValue == null ? "" : newValue.toString()); @@ -1750,11 +1773,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment Settings.Secure.putInt(getActivity().getContentResolver(), Settings.Secure.BUGREPORT_IN_POWER_MENU, mBugreportInPower.isChecked() ? 1 : 0); - } else if (preference == mKeepScreenOn) { - Settings.Global.putInt(getActivity().getContentResolver(), - Settings.Global.STAY_ON_WHILE_PLUGGED_IN, - mKeepScreenOn.isChecked() ? - (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0); } else if (preference == mBtHciSnoopLog) { writeBtHciSnoopLogOptions(); } else if (preference == mEnableOemUnlock) { @@ -1911,6 +1929,9 @@ public class DevelopmentSettings extends SettingsPreferenceFragment writeRootAccessOptions(newValue); } return true; + } else if (preference == mKeepScreenOn) { + writeStayAwakeOptions(newValue); + return true; } return false; } |