From 968127f5323b9838d772368d25105292e0f13a93 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Tue, 8 Dec 2015 04:12:45 -0800 Subject: [PATCH] cmsdk: Add CMHW method to check if SRE is self managed Change-Id: Ia5f644ce0b964a965afa47ea08016167c8b20620 --- .../platform/internal/CMHardwareService.java | 16 ++++++++++++++++ .../cyanogenmod/hardware/CMHardwareManager.java | 13 +++++++++++++ .../cyanogenmod/hardware/ICMHardwareService.aidl | 1 + 3 files changed, 30 insertions(+) diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java index 8f3cccc..8be4b33 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java @@ -83,6 +83,7 @@ public class CMHardwareService extends SystemService implements ThermalUpdateCal public String getSerialNumber(); public boolean requireAdaptiveBacklightForSunlightEnhancement(); + public boolean isSunlightEnhancementSelfManaged(); public DisplayMode[] getDisplayModes(); public DisplayMode getCurrentDisplayMode(); @@ -296,6 +297,10 @@ public class CMHardwareService extends SystemService implements ThermalUpdateCal return SunlightEnhancement.isAdaptiveBacklightRequired(); } + public boolean isSunlightEnhancementSelfManaged() { + return SunlightEnhancement.isSelfManaged(); + } + public DisplayMode[] getDisplayModes() { return DisplayModeControl.getAvailableModes(); } @@ -527,6 +532,17 @@ public class CMHardwareService extends SystemService implements ThermalUpdateCal return mCmHwImpl.requireAdaptiveBacklightForSunlightEnhancement(); } + @Override + public boolean isSunlightEnhancementSelfManaged() { + mContext.enforceCallingOrSelfPermission( + cyanogenmod.platform.Manifest.permission.HARDWARE_ABSTRACTION_ACCESS, null); + if (!isSupported(CMHardwareManager.FEATURE_SUNLIGHT_ENHANCEMENT)) { + Log.e(TAG, "Sunlight enhancement is not supported"); + return false; + } + return mCmHwImpl.isSunlightEnhancementSelfManaged(); + } + @Override public DisplayMode[] getDisplayModes() { mContext.enforceCallingOrSelfPermission( diff --git a/src/java/cyanogenmod/hardware/CMHardwareManager.java b/src/java/cyanogenmod/hardware/CMHardwareManager.java index d27b1fb..c28cb98 100644 --- a/src/java/cyanogenmod/hardware/CMHardwareManager.java +++ b/src/java/cyanogenmod/hardware/CMHardwareManager.java @@ -713,6 +713,19 @@ public final class CMHardwareManager { return false; } + /** + * @return true if this implementation does it's own lux metering + */ + public boolean isSunlightEnhancementSelfManaged() { + try { + if (checkService()) { + return sService.isSunlightEnhancementSelfManaged(); + } + } catch (RemoteException e) { + } + return false; + } + /** * @return a list of available display modes on the devices */ diff --git a/src/java/cyanogenmod/hardware/ICMHardwareService.aidl b/src/java/cyanogenmod/hardware/ICMHardwareService.aidl index 6da7b1f..1cbcfb2 100644 --- a/src/java/cyanogenmod/hardware/ICMHardwareService.aidl +++ b/src/java/cyanogenmod/hardware/ICMHardwareService.aidl @@ -43,6 +43,7 @@ interface ICMHardwareService { String getSerialNumber(); boolean requireAdaptiveBacklightForSunlightEnhancement(); + boolean isSunlightEnhancementSelfManaged(); DisplayMode[] getDisplayModes(); DisplayMode getCurrentDisplayMode();