aboutsummaryrefslogtreecommitdiffstats
path: root/sdk
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-03-31 11:23:36 -0700
committerSteve Kondik <shade@chemlab.org>2016-04-13 01:37:08 -0700
commit1dab5a0ca90d877c2f1728e75176e100547192ea (patch)
treef71cc31de251eaf59b5ee307113142667595f3d0 /sdk
parent620b1eb9084c2ea1d15ab20946f4c391588135c2 (diff)
downloadvendor_cmsdk-1dab5a0ca90d877c2f1728e75176e100547192ea.zip
vendor_cmsdk-1dab5a0ca90d877c2f1728e75176e100547192ea.tar.gz
vendor_cmsdk-1dab5a0ca90d877c2f1728e75176e100547192ea.tar.bz2
cmsdk: Refactoring LiveDisplay
* Moving LiveDisplay to CMSDK! * Completely redesigned the feature for future expansion. * No new features in this patch, but a proper API is being designed. Change-Id: Ic8f55678f9141bf3386b2a1cf2fd1e8b3916c278
Diffstat (limited to 'sdk')
-rw-r--r--sdk/src/java/cyanogenmod/app/CMContextConstants.java15
-rw-r--r--sdk/src/java/cyanogenmod/hardware/ILiveDisplayService.aidl50
-rw-r--r--sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.aidl19
-rw-r--r--sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java244
-rw-r--r--sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java415
-rw-r--r--sdk/src/java/cyanogenmod/providers/CMSettings.java34
6 files changed, 773 insertions, 4 deletions
diff --git a/sdk/src/java/cyanogenmod/app/CMContextConstants.java b/sdk/src/java/cyanogenmod/app/CMContextConstants.java
index 98171b8..07a2980 100644
--- a/sdk/src/java/cyanogenmod/app/CMContextConstants.java
+++ b/sdk/src/java/cyanogenmod/app/CMContextConstants.java
@@ -132,6 +132,13 @@ public final class CMContextConstants {
public static final String CM_WEATHER_SERVICE = "cmweather";
/**
+ * Manages display color adjustments
+ *
+ * @hide
+ */
+ public static final String CM_LIVEDISPLAY_SERVICE = "cmlivedisplay";
+
+ /**
* Features supported by the CMSDK.
*/
public static class Features {
@@ -214,5 +221,13 @@ public final class CMContextConstants {
*/
@SdkConstant(SdkConstant.SdkConstantType.FEATURE)
public static final String WEATHER_SERVICES = "org.cyanogenmod.weather";
+
+ /**
+ * Feature for {@link PackageManager#getSystemAvailableFeatures} and
+ * {@link PackageManager#hasSystemFeature}: The device includes the LiveDisplay service
+ * utilized by the cmsdk.
+ */
+ @SdkConstant(SdkConstant.SdkConstantType.FEATURE)
+ public static final String LIVEDISPLAY = "org.cyanogenmod.livedisplay";
}
}
diff --git a/sdk/src/java/cyanogenmod/hardware/ILiveDisplayService.aidl b/sdk/src/java/cyanogenmod/hardware/ILiveDisplayService.aidl
new file mode 100644
index 0000000..68e2b86
--- /dev/null
+++ b/sdk/src/java/cyanogenmod/hardware/ILiveDisplayService.aidl
@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2016, 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cyanogenmod.hardware;
+
+import cyanogenmod.hardware.LiveDisplayConfig;
+
+/** @hide */
+interface ILiveDisplayService {
+ LiveDisplayConfig getConfig();
+
+ int getMode();
+ boolean setMode(int mode);
+
+ float[] getColorAdjustment();
+ boolean setColorAdjustment(in float[] adj);
+
+ boolean isAutoContrastEnabled();
+ boolean setAutoContrastEnabled(boolean enabled);
+
+ boolean isCABCEnabled();
+ boolean setCABCEnabled(boolean enabled);
+
+ boolean isColorEnhancementEnabled();
+ boolean setColorEnhancementEnabled(boolean enabled);
+
+ int getDayColorTemperature();
+ boolean setDayColorTemperature(int temperature);
+
+ int getNightColorTemperature();
+ boolean setNightColorTemperature(int temperature);
+
+ int getColorTemperature();
+
+ boolean isAutomaticOutdoorModeEnabled();
+ boolean setAutomaticOutdoorModeEnabled(boolean enabled);
+}
diff --git a/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.aidl b/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.aidl
new file mode 100644
index 0000000..326e298
--- /dev/null
+++ b/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cyanogenmod.hardware;
+
+parcelable LiveDisplayConfig;
diff --git a/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java b/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java
new file mode 100644
index 0000000..0a569d3
--- /dev/null
+++ b/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cyanogenmod.hardware;
+
+import static cyanogenmod.hardware.LiveDisplayManager.FEATURE_FIRST;
+import static cyanogenmod.hardware.LiveDisplayManager.FEATURE_LAST;
+import static cyanogenmod.hardware.LiveDisplayManager.MODE_FIRST;
+import static cyanogenmod.hardware.LiveDisplayManager.MODE_LAST;
+import static cyanogenmod.hardware.LiveDisplayManager.MODE_OFF;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.BitSet;
+
+import cyanogenmod.os.Build;
+import cyanogenmod.os.Concierge;
+import cyanogenmod.os.Concierge.ParcelInfo;
+
+/**
+ * Holder class for LiveDisplay static configuration.
+ *
+ * This class holds various defaults and hardware capabilities
+ * which are involved with LiveDisplay.
+ */
+public class LiveDisplayConfig implements Parcelable {
+
+ private final BitSet mCapabilities;
+ private final int mDefaultDayTemperature;
+ private final int mDefaultNightTemperature;
+ private final int mDefaultMode;
+
+ private final boolean mDefaultAutoContrast;
+ private final boolean mDefaultAutoOutdoorMode;
+ private final boolean mDefaultCABC;
+ private final boolean mDefaultColorEnhancement;
+
+ public LiveDisplayConfig(BitSet capabilities, int defaultMode,
+ int defaultDayTemperature, int defaultNightTemperature,
+ boolean defaultAutoOutdoorMode, boolean defaultAutoContrast,
+ boolean defaultCABC, boolean defaultColorEnhancement) {
+ super();
+ mCapabilities = (BitSet) capabilities.clone();
+ mDefaultMode = defaultMode;
+ mDefaultDayTemperature = defaultDayTemperature;
+ mDefaultNightTemperature = defaultNightTemperature;
+ mDefaultAutoContrast = defaultAutoContrast;
+ mDefaultAutoOutdoorMode = defaultAutoOutdoorMode;
+ mDefaultCABC = defaultCABC;
+ mDefaultColorEnhancement = defaultColorEnhancement;
+ }
+
+ private LiveDisplayConfig(Parcel parcel) {
+ // Read parcelable version via the Concierge
+ ParcelInfo parcelInfo = Concierge.receiveParcel(parcel);
+ int parcelableVersion = parcelInfo.getParcelVersion();
+
+ // temp vars
+ long capabilities = 0;
+ int defaultMode = 0;
+ int defaultDayTemperature = -1;
+ int defaultNightTemperature = -1;
+ boolean defaultAutoContrast = false;
+ boolean defaultAutoOutdoorMode = false;
+ boolean defaultCABC = false;
+ boolean defaultColorEnhancement = false;
+
+ if (parcelableVersion >= Build.CM_VERSION_CODES.FIG) {
+ capabilities = parcel.readLong();
+ defaultMode = parcel.readInt();
+ defaultDayTemperature = parcel.readInt();
+ defaultNightTemperature = parcel.readInt();
+ defaultAutoContrast = parcel.readInt() == 1;
+ defaultAutoOutdoorMode = parcel.readInt() == 1;
+ defaultCABC = parcel.readInt() == 1;
+ defaultColorEnhancement = parcel.readInt() == 1;
+ }
+
+ // set temps
+ mCapabilities = BitSet.valueOf(new long[] { capabilities });
+ mDefaultMode = defaultMode;
+ mDefaultDayTemperature = defaultDayTemperature;
+ mDefaultNightTemperature = defaultNightTemperature;
+ mDefaultAutoContrast = defaultAutoContrast;
+ mDefaultAutoOutdoorMode = defaultAutoOutdoorMode;
+ mDefaultCABC = defaultCABC;
+ mDefaultColorEnhancement = defaultColorEnhancement;
+
+ // Complete parcel info for the concierge
+ parcelInfo.complete();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("capabilities=").append(mCapabilities.toString());
+ sb.append(" defaultMode=").append(mDefaultMode);
+ sb.append(" defaultDayTemperature=").append(mDefaultDayTemperature);
+ sb.append(" defaultNightTemperature=").append(mDefaultNightTemperature);
+ sb.append(" defaultAutoOutdoorMode=").append(mDefaultAutoOutdoorMode);
+ sb.append(" defaultAutoContrast=").append(mDefaultAutoContrast);
+ sb.append(" defaultCABC=").append(mDefaultCABC);
+ sb.append(" defaultColorEnhancement=").append(mDefaultColorEnhancement);
+ return sb.toString();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ // Tell the concierge to prepare the parcel
+ ParcelInfo parcelInfo = Concierge.prepareParcel(out);
+
+ // ==== FIG =====
+ out.writeLong(mCapabilities.toLongArray()[0]);
+ out.writeInt(mDefaultMode);
+ out.writeInt(mDefaultDayTemperature);
+ out.writeInt(mDefaultNightTemperature);
+ out.writeInt(mDefaultAutoContrast ? 1 : 0);
+ out.writeInt(mDefaultAutoOutdoorMode ? 1 : 0);
+ out.writeInt(mDefaultCABC ? 1 : 0);
+ out.writeInt(mDefaultColorEnhancement ? 1 : 0);
+
+ // Complete the parcel info for the concierge
+ parcelInfo.complete();
+ }
+
+ /**
+ * Checks if a particular feature or mode is supported by the system.
+ *
+ * @param feature
+ * @return true if capable
+ */
+ public boolean hasFeature(int feature) {
+ return ((feature >= MODE_FIRST && feature <= MODE_LAST) ||
+ (feature >= FEATURE_FIRST && feature <= FEATURE_LAST)) &&
+ (feature == MODE_OFF || mCapabilities.get(feature));
+ }
+
+ /**
+ * Checks if LiveDisplay is available for use on this device.
+ *
+ * @return true if any feature is enabled
+ */
+ public boolean isAvailable() {
+ return !mCapabilities.isEmpty();
+ }
+
+ /**
+ * Gets the default color temperature to use in the daytime. This is typically
+ * set to 6500K, however this may not be entirely accurate. Use this value for
+ * resetting controls to the default.
+ *
+ * @return the default day temperature in K
+ */
+ public int getDefaultDayTemperature() {
+ return mDefaultDayTemperature;
+ }
+
+ /**
+ * Gets the default color temperature to use at night. This is typically set
+ * to 4500K, but this may not be entirely accurate. Use this value for resetting
+ * controls to defaults.
+ *
+ * @return the default night color temperature
+ */
+ public int getDefaultNightTemperature() {
+ return mDefaultNightTemperature;
+ }
+
+ /**
+ * Get the default adaptive mode.
+ *
+ * @return the default mode
+ */
+ public int getDefaultMode() {
+ return mDefaultMode;
+ }
+
+ /**
+ * Get the default value for auto contrast
+ *
+ * @return true if enabled
+ */
+ public boolean getDefaultAutoContrast() {
+ return mDefaultAutoContrast;
+ }
+
+ /**
+ * Get the default value for automatic outdoor mode
+ *
+ * @return true if enabled
+ */
+ public boolean getDefaultAutoOutdoorMode() {
+ return mDefaultAutoOutdoorMode;
+ }
+
+ /**
+ * Get the default value for CABC
+ *
+ * @return true if enabled
+ */
+ public boolean getDefaultCABC() {
+ return mDefaultCABC;
+ }
+
+ /**
+ * Get the default value for color enhancement
+ *
+ * @return true if enabled
+ */
+ public boolean getDefaultColorEnhancement() {
+ return mDefaultColorEnhancement;
+ }
+
+ /** @hide */
+ public static final Parcelable.Creator<LiveDisplayConfig> CREATOR =
+ new Parcelable.Creator<LiveDisplayConfig>() {
+ public LiveDisplayConfig createFromParcel(Parcel in) {
+ return new LiveDisplayConfig(in);
+ }
+
+ @Override
+ public LiveDisplayConfig[] newArray(int size) {
+ return new LiveDisplayConfig[size];
+ }
+ };
+}
diff --git a/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java b/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java
new file mode 100644
index 0000000..0e4f7a1
--- /dev/null
+++ b/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java
@@ -0,0 +1,415 @@
+/*
+ * Copyright (C) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cyanogenmod.hardware;
+
+import android.content.Context;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
+
+import cyanogenmod.app.CMContextConstants;
+
+/**
+ * LiveDisplay is an advanced set of features for improving
+ * display quality under various ambient conditions.
+ *
+ * The backend service is constructed with a set of LiveDisplayFeatures
+ * which provide capabilities such as outdoor mode, night mode,
+ * and calibration. It interacts with CMHardwareService to relay
+ * changes down to the lower layers.
+ *
+ * Multiple adaptive modes are supported, and various hardware
+ * features such as CABC, ACO and color enhancement are also
+ * managed by LiveDisplay.
+ */
+public class LiveDisplayManager {
+
+ /**
+ * Disable all LiveDisplay adaptive features
+ */
+ public static final int MODE_OFF = 0;
+
+ /**
+ * Change color temperature to night mode
+ */
+ public static final int MODE_NIGHT = 1;
+
+ /**
+ * Enable automatic detection of appropriate mode
+ */
+ public static final int MODE_AUTO = 2;
+
+ /**
+ * Increase brightness/contrast/saturation for sunlight
+ */
+ public static final int MODE_OUTDOOR = 3;
+
+ /**
+ * Change color temperature to day mode, and allow
+ * detection of outdoor conditions
+ */
+ public static final int MODE_DAY = 4;
+
+ /** @hide */
+ public static final int MODE_FIRST = MODE_OFF;
+ /** @hide */
+ public static final int MODE_LAST = MODE_DAY;
+
+ /**
+ * Content adaptive backlight control, adjust images to
+ * increase brightness in order to reduce backlight level
+ */
+ public static final int FEATURE_CABC = 10;
+
+ /**
+ * Adjust images to increase contrast
+ */
+ public static final int FEATURE_AUTO_CONTRAST = 11;
+
+ /**
+ * Adjust image to improve saturation and color
+ */
+ public static final int FEATURE_COLOR_ENHANCEMENT = 12;
+
+ /**
+ * Capable of adjusting RGB levels
+ */
+ public static final int FEATURE_COLOR_ADJUSTMENT = 13;
+
+ /**
+ * System supports outdoor mode, but environmental sensing
+ * is done by an external application.
+ */
+ public static final int FEATURE_MANAGED_OUTDOOR_MODE = 14;
+
+ /**
+ * System supports multiple display calibrations
+ * for different viewing intents.
+ */
+ public static final int FEATURE_DISPLAY_MODES = 15;
+
+ /** @hide */
+ public static final int FEATURE_FIRST = FEATURE_CABC;
+ /** @hide */
+ public static final int FEATURE_LAST = FEATURE_DISPLAY_MODES;
+
+ private static final String TAG = "LiveDisplay";
+
+ private final Context mContext;
+ private final LiveDisplayConfig mConfig;
+
+ private static LiveDisplayManager sInstance;
+ private static ILiveDisplayService sService;
+
+ /**
+ * @hide to prevent subclassing from outside of the framework
+ */
+ private LiveDisplayManager(Context context) {
+ Context appContext = context.getApplicationContext();
+ if (appContext != null) {
+ mContext = appContext;
+ } else {
+ mContext = context;
+ }
+ sService = getService();
+
+ if (context.getPackageManager().hasSystemFeature(
+ CMContextConstants.Features.LIVEDISPLAY) && !checkService()) {
+ throw new RuntimeException("Unable to get LiveDisplayService. The service either" +
+ " crashed, was not started, or the interface has been called to early in" +
+ " SystemServer init");
+ }
+
+ try {
+ mConfig = sService.getConfig();
+ } catch (RemoteException e) {
+ throw new RuntimeException("Unable to fetch LiveDisplay configuration!", e);
+ }
+ }
+
+ /**
+ * Get or create an instance of the {@link cyanogenmod.hardware.LiveDisplayManager}
+ * @param context
+ * @return {@link LiveDisplayManager}
+ */
+ public synchronized static LiveDisplayManager getInstance(Context context) {
+ if (sInstance == null) {
+ sInstance = new LiveDisplayManager(context);
+ }
+ return sInstance;
+ }
+
+ /** @hide */
+ public static ILiveDisplayService getService() {
+ if (sService != null) {
+ return sService;
+ }
+ IBinder b = ServiceManager.getService(CMContextConstants.CM_LIVEDISPLAY_SERVICE);
+ if (b != null) {
+ sService = ILiveDisplayService.Stub.asInterface(b);
+ return sService;
+ }
+ return null;
+ }
+
+ /**
+ * @return true if service is valid
+ */
+ private boolean checkService() {
+ if (sService == null) {
+ Log.w(TAG, "not connected to CMHardwareManagerService");
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Gets the static configuration and settings.
+ *
+ * @return the configuration
+ */
+ public LiveDisplayConfig getConfig() {
+ return mConfig;
+ }
+
+ /**
+ * Returns the current adaptive mode.
+ *
+ * @return id of the selected mode
+ */
+ public int getMode() {
+ try {
+ return checkService() ? sService.getMode() : MODE_OFF;
+ } catch (RemoteException e) {
+ return MODE_OFF;
+ }
+ }
+
+ /**
+ * Selects a new adaptive mode.
+ *
+ * @param mode
+ * @return true if the mode was selected
+ */
+ public boolean setMode(int mode) {
+ try {
+ return checkService() && sService.setMode(mode);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Checks if the auto contrast optimization feature is enabled.
+ *
+ * @return true if enabled
+ */
+ public boolean isAutoContrastEnabled() {
+ try {
+ return checkService() && sService.isAutoContrastEnabled();
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Sets the state of auto contrast optimization
+ *
+ * @param enabled
+ * @return true if state was changed
+ */
+ public boolean setAutoContrastEnabled(boolean enabled) {
+ try {
+ return checkService() && sService.setAutoContrastEnabled(enabled);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Checks if the CABC feature is enabled
+ *
+ * @return true if enabled
+ */
+ public boolean isCABCEnabled() {
+ try {
+ return checkService() && sService.isCABCEnabled();
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Sets the state of CABC
+ *
+ * @param enabled
+ * @return true if state was changed
+ */
+ public boolean setCABCEnabled(boolean enabled) {
+ try {
+ return checkService() && sService.setCABCEnabled(enabled);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Checks if the color enhancement feature is enabled
+ *
+ * @return true if enabled
+ */
+ public boolean isColorEnhancementEnabled() {
+ try {
+ return checkService() && sService.isColorEnhancementEnabled();
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Sets the state of color enhancement
+ *
+ * @param enabled
+ * @return true if state was changed
+ */
+ public boolean setColorEnhancementEnabled(boolean enabled) {
+ try {
+ return checkService() && sService.setColorEnhancementEnabled(enabled);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Gets the user-specified color temperature to use in the daytime.
+ *
+ * @return the day color temperature
+ */
+ public int getDayColorTemperature() {
+ try {
+ return checkService() ? sService.getDayColorTemperature() : -1;
+ } catch (RemoteException e) {
+ return -1;
+ }
+ }
+
+ /**
+ * Sets the color temperature to use in the daytime.
+ *
+ * @param temperature
+ * @return true if state was changed
+ */
+ public boolean setDayColorTemperature(int temperature) {
+ try {
+ return checkService() && sService.setDayColorTemperature(temperature);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Gets the user-specified color temperature to use at night.
+ *
+ * @return the night color temperature
+ */
+ public int getNightColorTemperature() {
+ try {
+ return checkService() ? sService.getNightColorTemperature() : -1;
+ } catch (RemoteException e) {
+ return -1;
+ }
+ }
+
+ /**
+ * Sets the color temperature to use at night.
+ *
+ * @param temperature
+ * @return true if state was changed
+ */
+ public boolean setNightColorTemperature(int temperature) {
+ try {
+ return checkService() && sService.setNightColorTemperature(temperature);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Checks if outdoor mode should be enabled automatically when under extremely high
+ * ambient light. This is typically around 12000 lux.
+ *
+ * @return if outdoor conditions should be detected
+ */
+ public boolean isAutomaticOutdoorModeEnabled() {
+ try {
+ return checkService() && sService.isAutomaticOutdoorModeEnabled();
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Enables automatic detection of outdoor conditions. Outdoor mode is triggered
+ * when high ambient light is detected and it's not night.
+ *
+ * @param enabled
+ * @return true if state was changed
+ */
+ public boolean setAutomaticOutdoorModeEnabled(boolean enabled) {
+ try {
+ return checkService() && sService.setAutomaticOutdoorModeEnabled(enabled);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Gets the current RGB triplet which is applied as a color adjustment.
+ * The values are floats between 0 and 1. A setting of { 1.0, 1.0, 1.0 }
+ * means that no adjustment is made.
+ *
+ * @return array of { R, G, B } offsets
+ */
+ public float[] getColorAdjustment() {
+ try {
+ if (checkService()) {
+ return sService.getColorAdjustment();
+ }
+ } catch (RemoteException e) {
+ }
+ return new float[] { 1.0f, 1.0f, 1.0f };
+ }
+
+ /**
+ * Sets the color adjustment to use. This can be set by the user to calibrate
+ * their screen. This should be sent in the format { R, G, B } as floats from
+ * 0 to 1. A setting of { 1.0, 1.0, 1.0 } means that no adjustment is made.
+ * The hardware implementation may refuse certain values which make the display
+ * unreadable, such as { 0, 0, 0 }. This calibration will be combined with other
+ * internal adjustments, such as night mode, if necessary.
+ *
+ * @param array of { R, G, B } offsets
+ * @return true if state was changed
+ */
+ public boolean setColorAdjustment(float[] adj) {
+ try {
+ return checkService() && sService.setColorAdjustment(adj);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+}
diff --git a/sdk/src/java/cyanogenmod/providers/CMSettings.java b/sdk/src/java/cyanogenmod/providers/CMSettings.java
index 47cc524..2b3b07a 100644
--- a/sdk/src/java/cyanogenmod/providers/CMSettings.java
+++ b/sdk/src/java/cyanogenmod/providers/CMSettings.java
@@ -68,6 +68,16 @@ public final class CMSettings {
*/
public static final String ACTION_DATA_USAGE = "cyanogenmod.settings.ACTION_DATA_USAGE";
+ /**
+ * Activity Action: Show LiveDisplay settings
+ * <p>
+ * Input: Nothing.
+ * <p>
+ * Output: Nothing.
+ */
+ public static final String ACTION_LIVEDISPLAY_SETTINGS =
+ "cyanogenmod.settings.LIVEDISPLAY_SETTINGS";
+
// region Call Methods
/**
@@ -1318,10 +1328,15 @@ public final class CMSettings {
* Use display power saving features such as CABC or CABL
* 0 = 0ff, 1 = on
*/
- public static final String DISPLAY_LOW_POWER = "display_low_power";
+ public static final String DISPLAY_CABC = "display_low_power";
+
+ /**
+ * @deprecated
+ */
+ public static final String DISPLAY_LOW_POWER = DISPLAY_CABC;
/** @hide */
- public static final Validator DISPLAY_LOW_POWER_VALIDATOR =
+ public static final Validator DISPLAY_CABC_VALIDATOR =
sBooleanValidator;
/**
@@ -1335,6 +1350,16 @@ public final class CMSettings {
sBooleanValidator;
/**
+ * Use auto contrast optimization feature of display
+ * 0 = 0ff, 1 = on
+ */
+ public static final String DISPLAY_AUTO_CONTRAST = "display_auto_contrast";
+
+ /** @hide */
+ public static final Validator DISPLAY_AUTO_CONTRAST_VALIDATOR =
+ sBooleanValidator;
+
+ /**
* Manual display color adjustments (RGB values as floats, separated by spaces)
*/
public static final String DISPLAY_COLOR_ADJUSTMENT = "display_color_adjustment";
@@ -1827,7 +1852,7 @@ public final class CMSettings {
CMSettings.System.DISPLAY_TEMPERATURE_NIGHT,
CMSettings.System.DISPLAY_TEMPERATURE_MODE,
CMSettings.System.DISPLAY_AUTO_OUTDOOR_MODE,
- CMSettings.System.DISPLAY_LOW_POWER,
+ CMSettings.System.DISPLAY_CABC,
CMSettings.System.DISPLAY_COLOR_ENHANCE,
CMSettings.System.DISPLAY_COLOR_ADJUSTMENT,
CMSettings.System.LIVE_DISPLAY_HINTED,
@@ -1965,8 +1990,9 @@ public final class CMSettings {
VALIDATORS.put(DISPLAY_TEMPERATURE_DAY, DISPLAY_TEMPERATURE_DAY_VALIDATOR);
VALIDATORS.put(DISPLAY_TEMPERATURE_NIGHT, DISPLAY_TEMPERATURE_NIGHT_VALIDATOR);
VALIDATORS.put(DISPLAY_TEMPERATURE_MODE, DISPLAY_TEMPERATURE_MODE_VALIDATOR);
+ VALIDATORS.put(DISPLAY_AUTO_CONTRAST, DISPLAY_AUTO_CONTRAST_VALIDATOR);
VALIDATORS.put(DISPLAY_AUTO_OUTDOOR_MODE, DISPLAY_AUTO_OUTDOOR_MODE_VALIDATOR);
- VALIDATORS.put(DISPLAY_LOW_POWER, DISPLAY_LOW_POWER_VALIDATOR);
+ VALIDATORS.put(DISPLAY_CABC, DISPLAY_CABC_VALIDATOR);
VALIDATORS.put(DISPLAY_COLOR_ENHANCE, DISPLAY_COLOR_ENHANCE_VALIDATOR);
VALIDATORS.put(DISPLAY_COLOR_ADJUSTMENT, DISPLAY_COLOR_ADJUSTMENT_VALIDATOR);
VALIDATORS.put(LIVE_DISPLAY_HINTED, LIVE_DISPLAY_HINTED_VALIDATOR);