summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-07-14 10:35:55 -0700
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-07-20 10:05:21 -0700
commita7fea271f520082e9bfc6fff8a0bd2c625026a06 (patch)
tree5b2d33779a1819c2cb3418fe6e318873a77bf44e
parent67a87e6e08c5c8f611f65efe9fbc8b69a03f7f20 (diff)
downloadandroid_hardware_lineage_lineagehw-a7fea271f520082e9bfc6fff8a0bd2c625026a06.tar.gz
android_hardware_lineage_lineagehw-a7fea271f520082e9bfc6fff8a0bd2c625026a06.tar.bz2
android_hardware_lineage_lineagehw-a7fea271f520082e9bfc6fff8a0bd2c625026a06.zip
cmhw: Add ColorBalance impl for the LiveDisplay native interface
Change-Id: I34ee71d8b0c23f460434dc13cb997af72f38183e
-rw-r--r--org/cyanogenmod/hardware/ColorBalance.java89
-rw-r--r--org/cyanogenmod/hardware/LiveDisplayVendorImpl.java8
2 files changed, 96 insertions, 1 deletions
diff --git a/org/cyanogenmod/hardware/ColorBalance.java b/org/cyanogenmod/hardware/ColorBalance.java
new file mode 100644
index 0000000..08b1e84
--- /dev/null
+++ b/org/cyanogenmod/hardware/ColorBalance.java
@@ -0,0 +1,89 @@
+/*
+ * 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 org.cyanogenmod.hardware;
+
+/**
+ * Color balance support
+ *
+ * Color balance controls allow direct adjustment of display color temperature
+ * using a range of values. A zero implies no adjustment, negative values
+ * move towards warmer temperatures, and positive values move towards
+ * cool temperatures.
+ */
+public class ColorBalance {
+
+ private static final boolean sHasNativeSupport =
+ LiveDisplayVendorImpl.hasNativeFeature(LiveDisplayVendorImpl.COLOR_BALANCE);
+
+ /**
+ * Whether device supports color balance control
+ *
+ * @return boolean Supported devices must return always true
+ */
+ public static boolean isSupported() {
+ return sHasNativeSupport;
+ }
+
+ /**
+ * This method returns the current color balance value
+ *
+ * @return int Zero when no adjustment is made, negative values move
+ * towards warmer temperatures, positive values move towards cooler temperatures.
+ */
+ public static int getValue() {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_getColorBalance();
+ }
+ return 0;
+ }
+
+ /**
+ * This method allows to set the display color balance
+ *
+ * @param value
+ * @return boolean Must be false if feature is not supported or the operation
+ * failed; true in any other case.
+ */
+ public static boolean setValue(int value) {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_setColorBalance(value);
+ }
+ return false;
+ }
+
+ /**
+ * Get the minimum allowed color adjustment value
+ * @return int
+ */
+ public static int getMinValue() {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_getColorBalanceMin();
+ }
+ return 0;
+ }
+
+ /**
+ * Get the maximum allowed color adjustment value
+ * @return int
+ */
+ public static int getMaxValue() {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_getColorBalanceMax();
+ }
+ return 0;
+ }
+}
diff --git a/org/cyanogenmod/hardware/LiveDisplayVendorImpl.java b/org/cyanogenmod/hardware/LiveDisplayVendorImpl.java
index 7b3709c..8f885d3 100644
--- a/org/cyanogenmod/hardware/LiveDisplayVendorImpl.java
+++ b/org/cyanogenmod/hardware/LiveDisplayVendorImpl.java
@@ -28,7 +28,7 @@ public class LiveDisplayVendorImpl {
public static final String TAG = "LiveDisplayVendorImpl";
public static final int DISPLAY_MODES = 0x1;
- public static final int COLOR_TEMPERATURE = 0x2;
+ public static final int COLOR_BALANCE = 0x2;
public static final int OUTDOOR_MODE = 0x4;
public static final int ADAPTIVE_BACKLIGHT = 0x8;
@@ -67,4 +67,10 @@ public class LiveDisplayVendorImpl {
public static native boolean native_setOutdoorModeEnabled(boolean enabled);
public static native boolean native_isOutdoorModeEnabled();
+
+ public static native int native_getColorBalanceMin();
+ public static native int native_getColorBalanceMax();
+ public static native int native_getColorBalance();
+ public static native boolean native_setColorBalance(int value);
+
}