Enable color temperature developer setting
Manual merge from mnc-dr1.5-dev.
Add a switch in Developer Settings to enable "cool" color temperature mode.
Bug: 26110238
Change-Id: Id0ab3283c1ee3208287c8dca11298a4bc367b314
diff --git a/res/values/config.xml b/res/values/config.xml
index f96662c..3f25fc6 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -35,4 +35,7 @@
<!-- Carrier_enabled editable -->
<bool name="config_allow_edit_carrier_enabled" translatable="false">false</bool>
+ <!-- When true enable color temperature setting. -->
+ <bool name="config_enableColorTemperature">false</bool>
+
</resources>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index ea4750e..6335c4e 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -86,6 +86,12 @@
android:dialogTitle="@string/select_webview_provider_dialog_title"
android:summary="%s" />
+ <SwitchPreference
+ android:key="color_temperature"
+ android:title="@string/color_temperature"
+ android:summary="@string/color_temperature_desc"
+ android:persistent="false" />
+
<PreferenceCategory android:key="debug_debugging_category"
android:title="@string/debug_debugging_category">
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 34bf00e..a719a0b 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -124,6 +124,7 @@
private static final String BUGREPORT_IN_POWER_KEY = "bugreport_in_power";
private static final String OPENGL_TRACES_PROPERTY = "debug.egl.trace";
private static final String TUNER_UI_KEY = "tuner_ui";
+ private static final String COLOR_TEMPERATURE_PROPERTY = "persist.sys.debug.color_temp";
private static final String DEBUG_APP_KEY = "debug_app";
private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
@@ -177,6 +178,7 @@
private static final String KEY_COLOR_MODE = "color_mode";
private static final String FORCE_RESIZABLE_KEY = "force_resizable_activities";
private static final String ENABLE_FREEFORM_SUPPORT_KEY = "enable_freeform_support";
+ private static final String COLOR_TEMPERATURE_KEY = "color_temperature";
private static final String INACTIVE_APPS_KEY = "inactive_apps";
@@ -285,6 +287,8 @@
private SwitchPreference mEnableFreeformSupport;
+ private SwitchPreference mColorTemperaturePreference;
+
private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
private final ArrayList<SwitchPreference> mResetSwitchPrefs
@@ -480,6 +484,15 @@
mColorModePreference = null;
}
updateWebViewProviderOptions();
+
+ mColorTemperaturePreference = (SwitchPreference) findPreference(COLOR_TEMPERATURE_KEY);
+ if (getResources().getBoolean(R.bool.config_enableColorTemperature)) {
+ mAllPrefs.add(mColorTemperaturePreference);
+ mResetSwitchPrefs.add(mColorTemperaturePreference);
+ } else {
+ removePreference(COLOR_TEMPERATURE_KEY);
+ mColorTemperaturePreference = null;
+ }
}
private ListPreference addListPreference(String prefKey) {
@@ -690,6 +703,9 @@
updateForceResizableOptions();
updateEnableFreeformWindowsSupportOptions();
updateWebViewProviderOptions();
+ if (mColorTemperaturePreference != null) {
+ updateColorTemperature();
+ }
}
private void resetDangerousOptions() {
@@ -1257,6 +1273,17 @@
}
}
+ private void updateColorTemperature() {
+ updateSwitchPreference(mColorTemperaturePreference,
+ SystemProperties.getBoolean(COLOR_TEMPERATURE_PROPERTY, false));
+ }
+
+ private void writeColorTemperature() {
+ SystemProperties.set(COLOR_TEMPERATURE_PROPERTY,
+ mColorTemperaturePreference.isChecked() ? "1" : "0");
+ pokeSystemProperties();
+ }
+
private void updateUSBAudioOptions() {
updateSwitchPreference(mUSBAudio, Settings.Secure.getInt(getContentResolver(),
Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0);
@@ -1830,6 +1857,8 @@
writeLegacyDhcpClientOptions();
} else if (preference == mMobileDataAlwaysOn) {
writeMobileDataAlwaysOnOptions();
+ } else if (preference == mColorTemperaturePreference) {
+ writeColorTemperature();
} else if (preference == mUSBAudio) {
writeUSBAudioOptions();
} else if (preference == mForceResizable) {