From a7fea271f520082e9bfc6fff8a0bd2c625026a06 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Thu, 14 Jul 2016 10:35:55 -0700 Subject: cmhw: Add ColorBalance impl for the LiveDisplay native interface Change-Id: I34ee71d8b0c23f460434dc13cb997af72f38183e --- org/cyanogenmod/hardware/ColorBalance.java | 89 ++++++++++++++++++++++ .../hardware/LiveDisplayVendorImpl.java | 8 +- 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 org/cyanogenmod/hardware/ColorBalance.java 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); + } -- cgit v1.2.3