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
This commit is contained in:
Steve Pfetsch
2016-01-13 17:07:35 -08:00
parent 8440469960
commit b3fef371be
3 changed files with 38 additions and 0 deletions

View File

@@ -35,4 +35,7 @@
<!-- Carrier_enabled editable --> <!-- Carrier_enabled editable -->
<bool name="config_allow_edit_carrier_enabled" translatable="false">false</bool> <bool name="config_allow_edit_carrier_enabled" translatable="false">false</bool>
<!-- When true enable color temperature setting. -->
<bool name="config_enableColorTemperature">false</bool>
</resources> </resources>

View File

@@ -86,6 +86,12 @@
android:dialogTitle="@string/select_webview_provider_dialog_title" android:dialogTitle="@string/select_webview_provider_dialog_title"
android:summary="%s" /> 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" <PreferenceCategory android:key="debug_debugging_category"
android:title="@string/debug_debugging_category"> android:title="@string/debug_debugging_category">

View File

@@ -124,6 +124,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private static final String BUGREPORT_IN_POWER_KEY = "bugreport_in_power"; 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 OPENGL_TRACES_PROPERTY = "debug.egl.trace";
private static final String TUNER_UI_KEY = "tuner_ui"; 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 DEBUG_APP_KEY = "debug_app";
private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger"; private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
@@ -177,6 +178,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private static final String KEY_COLOR_MODE = "color_mode"; private static final String KEY_COLOR_MODE = "color_mode";
private static final String FORCE_RESIZABLE_KEY = "force_resizable_activities"; 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 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"; private static final String INACTIVE_APPS_KEY = "inactive_apps";
@@ -285,6 +287,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private SwitchPreference mEnableFreeformSupport; private SwitchPreference mEnableFreeformSupport;
private SwitchPreference mColorTemperaturePreference;
private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>(); private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
private final ArrayList<SwitchPreference> mResetSwitchPrefs private final ArrayList<SwitchPreference> mResetSwitchPrefs
@@ -480,6 +484,15 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
mColorModePreference = null; mColorModePreference = null;
} }
updateWebViewProviderOptions(); 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) { private ListPreference addListPreference(String prefKey) {
@@ -690,6 +703,9 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
updateForceResizableOptions(); updateForceResizableOptions();
updateEnableFreeformWindowsSupportOptions(); updateEnableFreeformWindowsSupportOptions();
updateWebViewProviderOptions(); updateWebViewProviderOptions();
if (mColorTemperaturePreference != null) {
updateColorTemperature();
}
} }
private void resetDangerousOptions() { private void resetDangerousOptions() {
@@ -1257,6 +1273,17 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
} }
} }
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() { private void updateUSBAudioOptions() {
updateSwitchPreference(mUSBAudio, Settings.Secure.getInt(getContentResolver(), updateSwitchPreference(mUSBAudio, Settings.Secure.getInt(getContentResolver(),
Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0); Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0);
@@ -1830,6 +1857,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
writeLegacyDhcpClientOptions(); writeLegacyDhcpClientOptions();
} else if (preference == mMobileDataAlwaysOn) { } else if (preference == mMobileDataAlwaysOn) {
writeMobileDataAlwaysOnOptions(); writeMobileDataAlwaysOnOptions();
} else if (preference == mColorTemperaturePreference) {
writeColorTemperature();
} else if (preference == mUSBAudio) { } else if (preference == mUSBAudio) {
writeUSBAudioOptions(); writeUSBAudioOptions();
} else if (preference == mForceResizable) { } else if (preference == mForceResizable) {