summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/DisplaySettings.java
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2015-02-18 03:44:31 -0800
committerAdnan Begovic <adnan@cyngn.com>2015-10-29 17:36:30 -0700
commite65f2833df18e755c847bc86376253a4b96e73f9 (patch)
treee61b573057968f05218a0ad697dd38183bf81149 /src/com/android/settings/DisplaySettings.java
parent8f57a61603b7bc2fca99a510cb6c8188fb9612d2 (diff)
downloadpackages_apps_Settings-e65f2833df18e755c847bc86376253a4b96e73f9.zip
packages_apps_Settings-e65f2833df18e755c847bc86376253a4b96e73f9.tar.gz
packages_apps_Settings-e65f2833df18e755c847bc86376253a4b96e73f9.tar.bz2
livedisplay: Add LiveDisplay settings
* Add preference for LiveDisplay mode, and additional supporting options for auto mode. * CABC, SRE, CE are all under this umbrella now. * Manual RGB tweaking is now handled here and the requirement for CMHW has been removed as it will go thru RenderEngine. * Moved all related code into the livedisplay package. Change-Id: I0b00f2bfd8f8227d64ad271bbe0f004f0b4bcf9d
Diffstat (limited to 'src/com/android/settings/DisplaySettings.java')
-rw-r--r--src/com/android/settings/DisplaySettings.java185
1 files changed, 7 insertions, 178 deletions
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 718f03d..6340c4e 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -18,6 +18,8 @@
package com.android.settings;
import com.android.internal.logging.MetricsLogger;
import android.preference.CheckBoxPreference;
+
+import android.os.UserHandle;
import com.android.internal.view.RotationPolicy;
import com.android.settings.DropDownPreference.Callback;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -68,12 +70,7 @@ import java.util.ArrayList;
import java.util.List;
import com.android.settings.Utils;
import com.android.settings.cyanogenmod.DisplayRotation;
-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
@@ -92,24 +89,17 @@ 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_DISPLAY_ROTATION = "display_rotation";
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 String KEY_SCREEN_COLOR_SETTINGS = "screencolor_settings";
private static final int DLG_GLOBAL_CHANGE_WARNING = 1;
private FontDialogPreference mFontSizePref;
private PreferenceScreen mDisplayRotationPreference;
- private PreferenceScreen mScreenColorSettings;
private final Configuration mCurConfig = new Configuration();
@@ -123,10 +113,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
private SwitchPreference mTapToWake;
private SwitchPreference mWakeWhenPluggedOrUnplugged;
- private SwitchPreference mAdaptiveBacklight;
- private SwitchPreference mSunlightEnhancement;
- private SwitchPreference mColorEnhancement;
-
private ContentObserver mAccelerometerRotationObserver =
new ContentObserver(new Handler()) {
@Override
@@ -153,7 +139,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
super.onCreate(savedInstanceState);
final Activity activity = getActivity();
final ContentResolver resolver = activity.getContentResolver();
-
addPreferencesFromResource(R.xml.display_settings);
mDisplayRotationPreference = (PreferenceScreen) findPreference(KEY_DISPLAY_ROTATION);
@@ -182,8 +167,8 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
if (mAutoBrightnessPreference != null && isAutomaticBrightnessAvailable(getResources())) {
mAutoBrightnessPreference.setOnPreferenceChangeListener(this);
} else {
- if (displayPrefs != null && mAutoBrightnessPreference != null) {
- displayPrefs.removePreference(mAutoBrightnessPreference);
+ if (mAutoBrightnessPreference != null) {
+ removePreference(mAutoBrightnessPreference);
mAutoBrightnessPreference = null;
}
}
@@ -192,39 +177,12 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
if (mLiftToWakePreference != null && isLiftToWakeAvailable(activity)) {
mLiftToWakePreference.setOnPreferenceChangeListener(this);
} else {
- if (displayPrefs != null && mLiftToWakePreference != null) {
- displayPrefs.removePreference(mLiftToWakePreference);
+ if (mLiftToWakePreference != null) {
+ removePreference(mLiftToWakePreference);
mLiftToWakePreference = null;
}
}
-
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);
@@ -263,11 +221,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
mWakeWhenPluggedOrUnplugged =
(SwitchPreference) findPreference(KEY_WAKE_WHEN_PLUGGED_OR_UNPLUGGED);
-
- mScreenColorSettings = (PreferenceScreen) findPreference(KEY_SCREEN_COLOR_SETTINGS);
- if (!isPostProcessingSupported()) {
- getPreferenceScreen().removePreference(mScreenColorSettings);
- }
}
private static boolean allowAllRotations(Context context) {
@@ -407,22 +360,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
public void onResume() {
super.onResume();
updateDisplayRotationPreferenceDescription();
- 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());
@@ -438,10 +375,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true,
mAccelerometerRotationObserver);
- if (mAdaptiveBacklight != null) {
- mAdaptiveBacklight.setChecked(AdaptiveBacklight.isEnabled());
- }
-
// Default value for wake-on-plug behavior from config.xml
boolean wakeUpWhenPluggedOrUnpluggedConfig = getResources().getBoolean(
com.android.internal.R.bool.config_unplugTurnsOnScreen);
@@ -553,16 +486,6 @@ 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,
@@ -652,95 +575,15 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
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 isPostProcessingSupported(Context context) {
- boolean ret = true;
- final PackageManager pm = context.getPackageManager();
- try {
- pm.getPackageInfo("com.qualcomm.display", PackageManager.GET_META_DATA);
- } catch (NameNotFoundException e) {
- ret = false;
- }
- return ret;
- }
-
- 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 =
new BaseSearchIndexProvider() {
private boolean mHasTapToWake;
- private boolean mHasSunlightEnhancement, mHasColorEnhancement;
- private boolean mHasDisplayGamma, mHasDisplayColor;
@Override
public void prepare() {
mHasTapToWake = isTapToWakeSupported();
- mHasSunlightEnhancement = isSunlightEnhancementSupported();
- mHasColorEnhancement = isColorEnhancementSupported();
- mHasDisplayGamma = DisplayGamma.isSupported();
- mHasDisplayColor = DisplayColor.isSupported();
}
@Override
@@ -770,21 +613,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
if (!mHasTapToWake) {
result.add(KEY_TAP_TO_WAKE);
}
- if (!mHasSunlightEnhancement) {
- result.add(KEY_SUNLIGHT_ENHANCEMENT);
- }
- if (!mHasColorEnhancement) {
- result.add(KEY_COLOR_ENHANCEMENT);
- }
- if (!isPostProcessingSupported(context)) {
- result.add(KEY_SCREEN_COLOR_SETTINGS);
- }
- if (!mHasDisplayColor) {
- result.add(KEY_DISPLAY_COLOR);
- }
- if (!mHasDisplayGamma) {
- result.add(KEY_DISPLAY_GAMMA);
- }
+
if (!isAutomaticBrightnessAvailable(context.getResources())) {
result.add(KEY_AUTO_BRIGHTNESS);
}