cmsdk: Add initial DisplayMode and AutoContrast support to CMHW
Change-Id: I71f3599c64c03efc4b090ea71e583c942d0c03c2
This commit is contained in:
parent
5ee87cbf06
commit
e18f6d8b1c
@ -25,13 +25,16 @@ import com.android.server.SystemService;
|
||||
import cyanogenmod.app.CMContextConstants;
|
||||
import cyanogenmod.hardware.ICMHardwareService;
|
||||
import cyanogenmod.hardware.CMHardwareManager;
|
||||
import cyanogenmod.hardware.DisplayMode;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.cyanogenmod.hardware.AdaptiveBacklight;
|
||||
import org.cyanogenmod.hardware.AutoContrast;
|
||||
import org.cyanogenmod.hardware.ColorEnhancement;
|
||||
import org.cyanogenmod.hardware.DisplayColorCalibration;
|
||||
import org.cyanogenmod.hardware.DisplayGammaCalibration;
|
||||
import org.cyanogenmod.hardware.DisplayModeControl;
|
||||
import org.cyanogenmod.hardware.HighTouchSensitivity;
|
||||
import org.cyanogenmod.hardware.KeyDisabler;
|
||||
import org.cyanogenmod.hardware.LongTermOrbits;
|
||||
@ -71,6 +74,11 @@ public class CMHardwareService extends SystemService {
|
||||
public String getSerialNumber();
|
||||
|
||||
public boolean requireAdaptiveBacklightForSunlightEnhancement();
|
||||
|
||||
public DisplayMode[] getDisplayModes();
|
||||
public DisplayMode getCurrentDisplayMode();
|
||||
public DisplayMode getDefaultDisplayMode();
|
||||
public boolean setDisplayMode(DisplayMode mode);
|
||||
}
|
||||
|
||||
private class LegacyCMHardware implements CMHardwareInterface {
|
||||
@ -102,6 +110,10 @@ public class CMHardwareService extends SystemService {
|
||||
mSupportedFeatures |= CMHardwareManager.FEATURE_VIBRATOR;
|
||||
if (TouchscreenHovering.isSupported())
|
||||
mSupportedFeatures |= CMHardwareManager.FEATURE_TOUCH_HOVERING;
|
||||
if (AutoContrast.isSupported())
|
||||
mSupportedFeatures |= CMHardwareManager.FEATURE_AUTO_CONTRAST;
|
||||
if (DisplayModeControl.isSupported())
|
||||
mSupportedFeatures |= CMHardwareManager.FEATURE_DISPLAY_MODES;
|
||||
}
|
||||
|
||||
public int getSupportedFeatures() {
|
||||
@ -124,6 +136,8 @@ public class CMHardwareService extends SystemService {
|
||||
return TapToWake.isEnabled();
|
||||
case CMHardwareManager.FEATURE_TOUCH_HOVERING:
|
||||
return TouchscreenHovering.isEnabled();
|
||||
case CMHardwareManager.FEATURE_AUTO_CONTRAST:
|
||||
return AutoContrast.isEnabled();
|
||||
default:
|
||||
Log.e(TAG, "feature " + feature + " is not a boolean feature");
|
||||
return false;
|
||||
@ -146,6 +160,8 @@ public class CMHardwareService extends SystemService {
|
||||
return TapToWake.setEnabled(enable);
|
||||
case CMHardwareManager.FEATURE_TOUCH_HOVERING:
|
||||
return TouchscreenHovering.setEnabled(enable);
|
||||
case CMHardwareManager.FEATURE_AUTO_CONTRAST:
|
||||
return AutoContrast.setEnabled(enable);
|
||||
default:
|
||||
Log.e(TAG, "feature " + feature + " is not a boolean feature");
|
||||
return false;
|
||||
@ -261,6 +277,22 @@ public class CMHardwareService extends SystemService {
|
||||
public boolean requireAdaptiveBacklightForSunlightEnhancement() {
|
||||
return SunlightEnhancement.isAdaptiveBacklightRequired();
|
||||
}
|
||||
|
||||
public DisplayMode[] getDisplayModes() {
|
||||
return DisplayModeControl.getAvailableModes();
|
||||
}
|
||||
|
||||
public DisplayMode getCurrentDisplayMode() {
|
||||
return DisplayModeControl.getCurrentMode();
|
||||
}
|
||||
|
||||
public DisplayMode getDefaultDisplayMode() {
|
||||
return DisplayModeControl.getDefaultMode();
|
||||
}
|
||||
|
||||
public boolean setDisplayMode(DisplayMode mode) {
|
||||
return DisplayModeControl.setMode(mode, true);
|
||||
}
|
||||
}
|
||||
|
||||
private CMHardwareInterface getImpl(Context context) {
|
||||
@ -448,5 +480,49 @@ public class CMHardwareService extends SystemService {
|
||||
}
|
||||
return mCmHwImpl.requireAdaptiveBacklightForSunlightEnhancement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayMode[] getDisplayModes() {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
cyanogenmod.platform.Manifest.permission.HARDWARE_ABSTRACTION_ACCESS, null);
|
||||
if (!isSupported(CMHardwareManager.FEATURE_DISPLAY_MODES)) {
|
||||
Log.e(TAG, "Display modes are not supported");
|
||||
return null;
|
||||
}
|
||||
return mCmHwImpl.getDisplayModes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayMode getCurrentDisplayMode() {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
cyanogenmod.platform.Manifest.permission.HARDWARE_ABSTRACTION_ACCESS, null);
|
||||
if (!isSupported(CMHardwareManager.FEATURE_DISPLAY_MODES)) {
|
||||
Log.e(TAG, "Display modes are not supported");
|
||||
return null;
|
||||
}
|
||||
return mCmHwImpl.getCurrentDisplayMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayMode getDefaultDisplayMode() {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
cyanogenmod.platform.Manifest.permission.HARDWARE_ABSTRACTION_ACCESS, null);
|
||||
if (!isSupported(CMHardwareManager.FEATURE_DISPLAY_MODES)) {
|
||||
Log.e(TAG, "Display modes are not supported");
|
||||
return null;
|
||||
}
|
||||
return mCmHwImpl.getDefaultDisplayMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setDisplayMode(DisplayMode mode) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
cyanogenmod.platform.Manifest.permission.HARDWARE_ABSTRACTION_ACCESS, null);
|
||||
if (!isSupported(CMHardwareManager.FEATURE_DISPLAY_MODES)) {
|
||||
Log.e(TAG, "Display modes are not supported");
|
||||
return false;
|
||||
}
|
||||
return mCmHwImpl.setDisplayMode(mode);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -100,6 +100,16 @@ public final class CMHardwareManager {
|
||||
*/
|
||||
public static final int FEATURE_TOUCH_HOVERING = 0x800;
|
||||
|
||||
/**
|
||||
* Auto contrast
|
||||
*/
|
||||
public static final int FEATURE_AUTO_CONTRAST = 0x1000;
|
||||
|
||||
/**
|
||||
* Display modes
|
||||
*/
|
||||
public static final int FEATURE_DISPLAY_MODES = 0x2000;
|
||||
|
||||
private static final List<Integer> BOOLEAN_FEATURES = Arrays.asList(
|
||||
FEATURE_ADAPTIVE_BACKLIGHT,
|
||||
FEATURE_COLOR_ENHANCEMENT,
|
||||
@ -108,6 +118,7 @@ public final class CMHardwareManager {
|
||||
FEATURE_SUNLIGHT_ENHANCEMENT,
|
||||
FEATURE_TAP_TO_WAKE,
|
||||
FEATURE_TOUCH_HOVERING,
|
||||
FEATURE_AUTO_CONTRAST
|
||||
);
|
||||
|
||||
private static CMHardwareManager sCMHardwareManagerInstance;
|
||||
@ -417,6 +428,7 @@ public final class CMHardwareManager {
|
||||
/**
|
||||
* @return the number of RGB controls the device supports
|
||||
*/
|
||||
@Deprecated
|
||||
public int getNumGammaControls() {
|
||||
try {
|
||||
return getService().getNumGammaControls();
|
||||
@ -430,6 +442,7 @@ public final class CMHardwareManager {
|
||||
*
|
||||
* @return the current RGB gamma calibration for the given control
|
||||
*/
|
||||
@Deprecated
|
||||
public int[] getDisplayGammaCalibration(int idx) {
|
||||
int[] arr = getDisplayGammaCalibrationArray(idx);
|
||||
if (arr == null || arr.length < 3) {
|
||||
@ -441,6 +454,7 @@ public final class CMHardwareManager {
|
||||
/**
|
||||
* @return the minimum value for all colors
|
||||
*/
|
||||
@Deprecated
|
||||
public int getDisplayGammaCalibrationMin() {
|
||||
return getArrayValue(getDisplayGammaCalibrationArray(0), GAMMA_CALIBRATION_MIN_INDEX, 0);
|
||||
}
|
||||
@ -448,6 +462,7 @@ public final class CMHardwareManager {
|
||||
/**
|
||||
* @return the maximum value for all colors
|
||||
*/
|
||||
@Deprecated
|
||||
public int getDisplayGammaCalibrationMax() {
|
||||
return getArrayValue(getDisplayGammaCalibrationArray(0), GAMMA_CALIBRATION_MAX_INDEX, 0);
|
||||
}
|
||||
@ -462,6 +477,7 @@ public final class CMHardwareManager {
|
||||
*
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean setDisplayGammaCalibration(int idx, int[] rgb) {
|
||||
try {
|
||||
return getService().setDisplayGammaCalibration(idx, rgb);
|
||||
@ -525,4 +541,48 @@ public final class CMHardwareManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of available display modes on the devices
|
||||
*/
|
||||
public DisplayMode[] getDisplayModes() {
|
||||
try {
|
||||
return getService().getDisplayModes();
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the currently active display mode
|
||||
*/
|
||||
public DisplayMode getCurrentDisplayMode() {
|
||||
try {
|
||||
return getService().getCurrentDisplayMode();
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the default display mode to be set on boot
|
||||
*/
|
||||
public DisplayMode getDefaultDisplayMode() {
|
||||
try {
|
||||
return getService().getDefaultDisplayMode();
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if setting the mode was successful
|
||||
*/
|
||||
public boolean setDisplayMode(DisplayMode mode) {
|
||||
try {
|
||||
return getService().setDisplayMode(mode);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
19
src/java/cyanogenmod/hardware/DisplayMode.aidl
Normal file
19
src/java/cyanogenmod/hardware/DisplayMode.aidl
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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 DisplayMode;
|
68
src/java/cyanogenmod/hardware/DisplayMode.java
Normal file
68
src/java/cyanogenmod/hardware/DisplayMode.java
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/*
|
||||
* Display Modes API
|
||||
*
|
||||
* A device may implement a list of preset display modes for different
|
||||
* viewing intents, such as movies, photos, or extra vibrance. These
|
||||
* modes may have multiple components such as gamma correction, white
|
||||
* point adjustment, etc, but are activated by a single control point.
|
||||
*
|
||||
* This API provides support for enumerating and selecting the
|
||||
* modes supported by the hardware.
|
||||
*
|
||||
* A DisplayMode is referenced by it's identifier and carries an
|
||||
* associated name (up to the user to translate this value).
|
||||
*/
|
||||
public class DisplayMode implements Parcelable {
|
||||
public final int id;
|
||||
public final String name;
|
||||
|
||||
public DisplayMode(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeInt(id);
|
||||
out.writeString(name);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public static final Parcelable.Creator<DisplayMode> CREATOR = new Parcelable.Creator<DisplayMode>() {
|
||||
public DisplayMode createFromParcel(Parcel in) {
|
||||
return new DisplayMode(in.readInt(), in.readString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayMode[] newArray(int size) {
|
||||
return new DisplayMode[size];
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@ -16,6 +16,8 @@
|
||||
|
||||
package cyanogenmod.hardware;
|
||||
|
||||
import cyanogenmod.hardware.DisplayMode;
|
||||
|
||||
/** @hide */
|
||||
interface ICMHardwareService {
|
||||
|
||||
@ -40,4 +42,9 @@ interface ICMHardwareService {
|
||||
String getSerialNumber();
|
||||
|
||||
boolean requireAdaptiveBacklightForSunlightEnhancement();
|
||||
|
||||
DisplayMode[] getDisplayModes();
|
||||
DisplayMode getCurrentDisplayMode();
|
||||
DisplayMode getDefaultDisplayMode();
|
||||
boolean setDisplayMode(in DisplayMode mode);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user