Setting: Developer Option: Adds a low power mode checkbox

Change-Id: I489f74bd3822f64acb8becd6e5eda716d8bd722c
Signed-off-by: Ruchi Kandoi<kandoiruchi@google.com>
This commit is contained in:
Ruchi Kandoi
2014-04-17 17:54:35 -07:00
parent 6f3a760dad
commit 0b1f3fb2c9
3 changed files with 27 additions and 0 deletions

View File

@@ -4421,6 +4421,11 @@
<!-- UI debug setting: force right to left layout summary [CHAR LIMIT=100] --> <!-- UI debug setting: force right to left layout summary [CHAR LIMIT=100] -->
<string name="force_rtl_layout_all_locales_summary">Force screen layout direction to RTL for all locales</string> <string name="force_rtl_layout_all_locales_summary">Force screen layout direction to RTL for all locales</string>
<!-- UI debug setting: start low power mode [CHAR LIMIT=25] -->
<string name="low_power_mode">Low Power Mode</string>
<!-- UI debug setting: start low power mode summary[CHAR LIMIT=50] -->
<string name="low_power_mode_summary">Enable battery saving settings</string>
<!-- UI debug setting: show how CPU is being used? [CHAR LIMIT=25] --> <!-- UI debug setting: show how CPU is being used? [CHAR LIMIT=25] -->
<string name="show_cpu_usage">Show CPU usage</string> <string name="show_cpu_usage">Show CPU usage</string>
<!-- UI debug setting: show cpu usage summary [CHAR LIMIT=50] --> <!-- UI debug setting: show cpu usage summary [CHAR LIMIT=50] -->

View File

@@ -240,6 +240,11 @@
android:title="@string/strict_mode" android:title="@string/strict_mode"
android:summary="@string/strict_mode_summary"/> android:summary="@string/strict_mode_summary"/>
<CheckBoxPreference
android:key="low_power_mode"
android:title="@string/low_power_mode"
android:summary="@string/low_power_mode_summary"/>
<CheckBoxPreference <CheckBoxPreference
android:key="show_cpu_usage" android:key="show_cpu_usage"
android:title="@string/show_cpu_usage" android:title="@string/show_cpu_usage"

View File

@@ -118,6 +118,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String USE_NUPLAYER_KEY = "use_nuplayer"; private static final String USE_NUPLAYER_KEY = "use_nuplayer";
private static final String USE_NUPLAYER_PROPERTY = "persist.sys.media.use-nuplayer"; private static final String USE_NUPLAYER_PROPERTY = "persist.sys.media.use-nuplayer";
private static final String SHOW_CPU_USAGE_KEY = "show_cpu_usage"; private static final String SHOW_CPU_USAGE_KEY = "show_cpu_usage";
private static final String LOW_POWER_MODE_KEY = "low_power_mode";
private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui"; private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui";
private static final String FORCE_MSAA_KEY = "force_msaa"; private static final String FORCE_MSAA_KEY = "force_msaa";
private static final String TRACK_FRAME_TIME_KEY = "track_frame_time"; private static final String TRACK_FRAME_TIME_KEY = "track_frame_time";
@@ -184,6 +185,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private CheckBoxPreference mShowScreenUpdates; private CheckBoxPreference mShowScreenUpdates;
private CheckBoxPreference mDisableOverlays; private CheckBoxPreference mDisableOverlays;
private CheckBoxPreference mShowCpuUsage; private CheckBoxPreference mShowCpuUsage;
private CheckBoxPreference mLowPowerMode;
private CheckBoxPreference mForceHardwareUi; private CheckBoxPreference mForceHardwareUi;
private CheckBoxPreference mForceMsaa; private CheckBoxPreference mForceMsaa;
private CheckBoxPreference mShowHwScreenUpdates; private CheckBoxPreference mShowHwScreenUpdates;
@@ -293,6 +295,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mShowScreenUpdates = findAndInitCheckboxPref(SHOW_SCREEN_UPDATES_KEY); mShowScreenUpdates = findAndInitCheckboxPref(SHOW_SCREEN_UPDATES_KEY);
mDisableOverlays = findAndInitCheckboxPref(DISABLE_OVERLAYS_KEY); mDisableOverlays = findAndInitCheckboxPref(DISABLE_OVERLAYS_KEY);
mShowCpuUsage = findAndInitCheckboxPref(SHOW_CPU_USAGE_KEY); mShowCpuUsage = findAndInitCheckboxPref(SHOW_CPU_USAGE_KEY);
mLowPowerMode = findAndInitCheckboxPref(LOW_POWER_MODE_KEY);
mForceHardwareUi = findAndInitCheckboxPref(FORCE_HARDWARE_UI_KEY); mForceHardwareUi = findAndInitCheckboxPref(FORCE_HARDWARE_UI_KEY);
mForceMsaa = findAndInitCheckboxPref(FORCE_MSAA_KEY); mForceMsaa = findAndInitCheckboxPref(FORCE_MSAA_KEY);
mTrackFrameTime = addListPreference(TRACK_FRAME_TIME_KEY); mTrackFrameTime = addListPreference(TRACK_FRAME_TIME_KEY);
@@ -497,6 +500,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
updateShowTouchesOptions(); updateShowTouchesOptions();
updateFlingerOptions(); updateFlingerOptions();
updateCpuUsageOptions(); updateCpuUsageOptions();
updateLowPowerModeOptions();
updateHardwareUiOptions(); updateHardwareUiOptions();
updateMsaaOptions(); updateMsaaOptions();
updateTrackFrameTimeOptions(); updateTrackFrameTimeOptions();
@@ -1021,11 +1025,22 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mWifiDisplayCertification.isChecked() ? 1 : 0); mWifiDisplayCertification.isChecked() ? 1 : 0);
} }
private void updateLowPowerModeOptions() {
updateCheckBox(mLowPowerMode, Settings.Global.getInt(getActivity().getContentResolver(),
Settings.Global.LOW_POWER_MODE, 0) != 0);
}
private void updateCpuUsageOptions() { private void updateCpuUsageOptions() {
updateCheckBox(mShowCpuUsage, Settings.Global.getInt(getActivity().getContentResolver(), updateCheckBox(mShowCpuUsage, Settings.Global.getInt(getActivity().getContentResolver(),
Settings.Global.SHOW_PROCESSES, 0) != 0); Settings.Global.SHOW_PROCESSES, 0) != 0);
} }
private void writeLowPowerModeOptions() {
boolean value = mLowPowerMode.isChecked();
Settings.Global.putInt(getActivity().getContentResolver(),
Settings.Global.LOW_POWER_MODE, value ? 1 : 0);
}
private void writeCpuUsageOptions() { private void writeCpuUsageOptions() {
boolean value = mShowCpuUsage.isChecked(); boolean value = mShowCpuUsage.isChecked();
Settings.Global.putInt(getActivity().getContentResolver(), Settings.Global.putInt(getActivity().getContentResolver(),
@@ -1286,6 +1301,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
writeShowUpdatesOption(); writeShowUpdatesOption();
} else if (preference == mDisableOverlays) { } else if (preference == mDisableOverlays) {
writeDisableOverlaysOption(); writeDisableOverlaysOption();
} else if (preference == mLowPowerMode) {
writeLowPowerModeOptions();
} else if (preference == mShowCpuUsage) { } else if (preference == mShowCpuUsage) {
writeCpuUsageOptions(); writeCpuUsageOptions();
} else if (preference == mImmediatelyDestroyActivities) { } else if (preference == mImmediatelyDestroyActivities) {