diff options
author | Danny Baumann <dannybaumann@web.de> | 2013-11-07 10:43:02 +0100 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-29 17:36:29 -0700 |
commit | a284b34f11b3ad22084232950d81fb1bc68f21ce (patch) | |
tree | 24a6b7f480465209bb128d3d3fa4e36fd85c3250 /src/com/android/settings/DisplaySettings.java | |
parent | af88d809c0354ef2551050b2ea74cb85dc8ef056 (diff) | |
download | packages_apps_Settings-a284b34f11b3ad22084232950d81fb1bc68f21ce.zip packages_apps_Settings-a284b34f11b3ad22084232950d81fb1bc68f21ce.tar.gz packages_apps_Settings-a284b34f11b3ad22084232950d81fb1bc68f21ce.tar.bz2 |
settings: Squashed commit of CMHW features
Add hardware tunables (gamma, color, vibration strength).
Change-Id: I44e3e4e6cb444498a7c56048618cd92a0e2b8e59
Settings: restore hardware tunable values on boot
Change-Id: I9d2720947d615cab6a7ab9b596b24b8033dd0b4f
Settings: Add default value for display color control (2/2)
Change-Id: I50b684abe504c21ef49492f99b18873d75509697
settings: Move headset option, hide MoreDeviceSettings if empty
* This option fits much better in the sound menu under "automation
and effects", and on many devices it's the only option in the
"More..." menu under Tap & Pay.
* Move it, and remove the MoreDeviceSettings top-level category if
there's nothing else in it.
Change-Id: Idd82f582a1ba54f8b45fbd4fbe631057e9515f86
Remove 'More device settings' menu
Change-Id: I86cd84f6f6c408b26c04d92529e9a031c4fed1f7
DisplayColor: Properly handle a minValue
* Previously setting anything as a minValue would cause the
percentages to get out of whack. For instance, setting it to 35
would cause the maximum percentage to climb above 100% as well
as still allowing the value to be set lower than the min.
* This makes the maximum for the slider the max value minus the min
(so we get the proper spread for min to max) and then adds the min
back on before setting so we can't possibly go below the min.
Change-Id: I8dcdc422f54847940351fae10c74af6301d1e1be
Settings: AdaptiveBacklight support
Add support for adaptive backlight technologies like NVIDIA SmartDimmer, QCOM CABL or Samsung CABC.
Patchset 2: Use internal shared prefs to store the smardimmer setting
Patchset 3: Rename to AdaptiveBacklight
Patchset 4: Reorganize settings and strings to follow design guidelines
Patchset 5: CleanUp
Patchset 6: Added suggestions
Patchset 7: Sync default value. CleanUp.
Depends on http://review.cyanogenmod.org/#/c/48465/
Change-Id: I52cb990f36593b265a00b46a5f63590515822ea5
settings: Add support for SRE
* Add support for sunlight readability enhancement
* Optionally depends on adaptive backlight, depending on HAL
Change-Id: I9ca388ffd68080f0e497edb81d5f8616c194ea1d
Cleanup.
Now that button and keyboard backlight don't use the HW framework
anymore, there's no point in having an abstraction for a single use case.
Change-Id: Ib66b2a29a105d53e3ba4273abb06977b132c1fc8
Diffstat (limited to 'src/com/android/settings/DisplaySettings.java')
-rw-r--r-- | src/com/android/settings/DisplaySettings.java | 137 |
1 files changed, 136 insertions, 1 deletions
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java index 66af458..13c1b28 100644 --- a/src/com/android/settings/DisplaySettings.java +++ b/src/com/android/settings/DisplaySettings.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2014 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +49,7 @@ import android.os.RemoteException; import android.os.SystemProperties; import android.preference.ListPreference; import android.preference.Preference; +import android.preference.PreferenceManager; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceCategory; import android.preference.PreferenceManager; @@ -58,10 +60,17 @@ import android.provider.Settings; import android.text.TextUtils; import android.util.Log; + import java.util.ArrayList; import java.util.List; import com.android.settings.Utils; +import com.android.settings.hardware.DisplayColor; +import com.android.settings.hardware.DisplayGamma; + +import org.cyanogenmod.hardware.AdaptiveBacklight; +import org.cyanogenmod.hardware.ColorEnhancement; +import org.cyanogenmod.hardware.SunlightEnhancement; import org.cyanogenmod.hardware.TapToWake; public class DisplaySettings extends SettingsPreferenceFragment implements @@ -80,11 +89,16 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness"; private static final String KEY_AUTO_ROTATE = "auto_rotate"; private static final String KEY_NIGHT_MODE = "night_mode"; + private static final String KEY_ADAPTIVE_BACKLIGHT = "adaptive_backlight"; + private static final String KEY_SUNLIGHT_ENHANCEMENT = "sunlight_enhancement"; + private static final String KEY_COLOR_ENHANCEMENT = "color_enhancement"; private static final String KEY_TAP_TO_WAKE = "double_tap_wake_gesture"; private static final String KEY_PROXIMITY_WAKE = "proximity_on_wake"; private static final String KEY_WAKE_WHEN_PLUGGED_OR_UNPLUGGED = "wake_when_plugged_or_unplugged"; private static final String CATEGORY_ADVANCED = "advanced_display_prefs"; + private static final String KEY_DISPLAY_COLOR = "color_calibration"; + private static final String KEY_DISPLAY_GAMMA = "gamma_tuning"; private static final int DLG_GLOBAL_CHANGE_WARNING = 1; @@ -102,6 +116,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private SwitchPreference mTapToWake; private SwitchPreference mWakeWhenPluggedOrUnplugged; + private SwitchPreference mAdaptiveBacklight; + private SwitchPreference mSunlightEnhancement; + private SwitchPreference mColorEnhancement; + @Override protected int getMetricsCategory() { return MetricsLogger.DISPLAY; @@ -148,6 +166,33 @@ public class DisplaySettings extends SettingsPreferenceFragment implements removePreference(KEY_LIFT_TO_WAKE); } + PreferenceCategory advancedPrefs = (PreferenceCategory) findPreference(CATEGORY_ADVANCED); + + mAdaptiveBacklight = (SwitchPreference) findPreference(KEY_ADAPTIVE_BACKLIGHT); + if (!isAdaptiveBacklightSupported()) { + advancedPrefs.removePreference(mAdaptiveBacklight); + mAdaptiveBacklight = null; + } + + mSunlightEnhancement = (SwitchPreference) findPreference(KEY_SUNLIGHT_ENHANCEMENT); + if (!isSunlightEnhancementSupported()) { + advancedPrefs.removePreference(mSunlightEnhancement); + mSunlightEnhancement = null; + } + + mColorEnhancement = (SwitchPreference) findPreference(KEY_COLOR_ENHANCEMENT); + if (!isColorEnhancementSupported()) { + advancedPrefs.removePreference(mColorEnhancement); + mColorEnhancement = null; + } + + if (!DisplayColor.isSupported()) { + advancedPrefs.removePreference(findPreference(KEY_DISPLAY_COLOR)); + } + if (!DisplayGamma.isSupported()) { + advancedPrefs.removePreference(findPreference(KEY_DISPLAY_GAMMA)); + } + mDozePreference = (SwitchPreference) findPreference(KEY_DOZE); if (mDozePreference != null && Utils.isDozeAvailable(activity)) { mDozePreference.setOnPreferenceChangeListener(this); @@ -208,7 +253,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements mNightModePreference.setValue(String.valueOf(currentNightMode)); mNightModePreference.setOnPreferenceChangeListener(this); } - PreferenceCategory advancedPrefs = (PreferenceCategory) findPreference(CATEGORY_ADVANCED); mTapToWake = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE); if (!isTapToWakeSupported()) { @@ -316,6 +360,23 @@ public class DisplaySettings extends SettingsPreferenceFragment implements public void onResume() { super.onResume(); + if (mAdaptiveBacklight != null) { + mAdaptiveBacklight.setChecked(AdaptiveBacklight.isEnabled()); + } + + if (mSunlightEnhancement != null) { + if (SunlightEnhancement.isAdaptiveBacklightRequired() && + !AdaptiveBacklight.isEnabled()) { + mSunlightEnhancement.setEnabled(false); + } else { + mSunlightEnhancement.setChecked(SunlightEnhancement.isEnabled()); + } + } + + if (mColorEnhancement != null) { + mColorEnhancement.setChecked(ColorEnhancement.isEnabled()); + } + if (mTapToWake != null) { mTapToWake.setChecked(TapToWake.isEnabled()); } @@ -420,6 +481,16 @@ public class DisplaySettings extends SettingsPreferenceFragment implements public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference == mTapToWake) { return TapToWake.setEnabled(mTapToWake.isChecked()); + } else if (preference == mAdaptiveBacklight) { + if (mSunlightEnhancement != null && + SunlightEnhancement.isAdaptiveBacklightRequired()) { + mSunlightEnhancement.setEnabled(mAdaptiveBacklight.isChecked()); + } + return AdaptiveBacklight.setEnabled(mAdaptiveBacklight.isChecked()); + } else if (preference == mSunlightEnhancement) { + return SunlightEnhancement.setEnabled(mSunlightEnhancement.isChecked()); + } else if (preference == mColorEnhancement) { + return ColorEnhancement.setEnabled(mColorEnhancement.isChecked()); } else if (preference == mWakeWhenPluggedOrUnplugged) { Settings.Global.putInt(getContentResolver(), Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED, @@ -502,12 +573,76 @@ public class DisplaySettings extends SettingsPreferenceFragment implements if (isTapToWakeSupported()) { final boolean enabled = prefs.getBoolean(KEY_TAP_TO_WAKE, TapToWake.isEnabled()); + if (!TapToWake.setEnabled(enabled)) { Log.e(TAG, "Failed to restore tap-to-wake settings."); } else { Log.d(TAG, "Tap-to-wake settings restored."); } } + + if (isAdaptiveBacklightSupported()) { + final boolean enabled = prefs.getBoolean(KEY_ADAPTIVE_BACKLIGHT, + AdaptiveBacklight.isEnabled()); + if (!AdaptiveBacklight.setEnabled(enabled)) { + Log.e(TAG, "Failed to restore adaptive backlight settings."); + } else { + Log.d(TAG, "Adaptive backlight settings restored."); + } + } + + if (isSunlightEnhancementSupported()) { + final boolean enabled = prefs.getBoolean(KEY_SUNLIGHT_ENHANCEMENT, + SunlightEnhancement.isEnabled()); + if (SunlightEnhancement.isAdaptiveBacklightRequired() && + !AdaptiveBacklight.isEnabled()) { + SunlightEnhancement.setEnabled(false); + Log.d(TAG, "SRE requires CABC, disabled"); + } else { + if (!SunlightEnhancement.setEnabled(enabled)) { + Log.e(TAG, "Failed to restore SRE settings."); + } else { + Log.d(TAG, "SRE settings restored."); + } + } + } + + if (isColorEnhancementSupported()) { + final boolean enabled = prefs.getBoolean(KEY_COLOR_ENHANCEMENT, + ColorEnhancement.isEnabled()); + if (!ColorEnhancement.setEnabled(enabled)) { + Log.e(TAG, "Failed to restore color enhancement settings."); + } else { + Log.d(TAG, "Color enhancement settings restored."); + } + } + } + + private static boolean isAdaptiveBacklightSupported() { + try { + return AdaptiveBacklight.isSupported(); + } catch (NoClassDefFoundError e) { + // Hardware abstraction framework not installed + return false; + } + } + + private static boolean isSunlightEnhancementSupported() { + try { + return SunlightEnhancement.isSupported(); + } catch (NoClassDefFoundError e) { + // Hardware abstraction framework not installed + return false; + } + } + + private static boolean isColorEnhancementSupported() { + try { + return ColorEnhancement.isSupported(); + } catch (NoClassDefFoundError e) { + // Hardware abstraction framework not installed + return false; + } } public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = |