aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/cyanogenmod/hardware
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2015-09-21 17:49:42 -0700
committerDanesh M <daneshm90@gmail.com>2015-09-24 11:42:35 -0700
commit2acf3ea1c42aa2faf103c2527249ea916fbdbc33 (patch)
tree98b9867f0344d77b263ec2c69b9423b04fb94ec7 /src/java/cyanogenmod/hardware
parente2daff958878d78eba0547f7dd757350c4d9b8a0 (diff)
downloadvendor_cmsdk-2acf3ea1c42aa2faf103c2527249ea916fbdbc33.zip
vendor_cmsdk-2acf3ea1c42aa2faf103c2527249ea916fbdbc33.tar.gz
vendor_cmsdk-2acf3ea1c42aa2faf103c2527249ea916fbdbc33.tar.bz2
CMSdk : Add ThermalMonitor
Change-Id: Iafc87cf4c79feac5e2c66bb3d1945da6d0b742da
Diffstat (limited to 'src/java/cyanogenmod/hardware')
-rw-r--r--src/java/cyanogenmod/hardware/CMHardwareManager.java49
-rw-r--r--src/java/cyanogenmod/hardware/ICMHardwareService.aidl5
-rw-r--r--src/java/cyanogenmod/hardware/IThermalListenerCallback.aidl21
-rw-r--r--src/java/cyanogenmod/hardware/ThermalListenerCallback.java44
4 files changed, 118 insertions, 1 deletions
diff --git a/src/java/cyanogenmod/hardware/CMHardwareManager.java b/src/java/cyanogenmod/hardware/CMHardwareManager.java
index 12f3854..d27b1fb 100644
--- a/src/java/cyanogenmod/hardware/CMHardwareManager.java
+++ b/src/java/cyanogenmod/hardware/CMHardwareManager.java
@@ -119,6 +119,11 @@ public final class CMHardwareManager {
*/
public static final int FEATURE_PERSISTENT_STORAGE = 0x4000;
+ /**
+ * Thermal change monitor
+ */
+ public static final int FEATURE_THERMAL_MONITOR = 0x8000;
+
private static final List<Integer> BOOLEAN_FEATURES = Arrays.asList(
FEATURE_ADAPTIVE_BACKLIGHT,
FEATURE_COLOR_ENHANCEMENT,
@@ -127,7 +132,8 @@ public final class CMHardwareManager {
FEATURE_SUNLIGHT_ENHANCEMENT,
FEATURE_TAP_TO_WAKE,
FEATURE_TOUCH_HOVERING,
- FEATURE_AUTO_CONTRAST
+ FEATURE_AUTO_CONTRAST,
+ FEATURE_THERMAL_MONITOR
);
private static CMHardwareManager sCMHardwareManagerInstance;
@@ -769,4 +775,45 @@ public final class CMHardwareManager {
}
return true;
}
+
+ /**
+ * @return current thermal {@link cyanogenmod.hardware.ThermalListenerCallback.State}
+ */
+ public int getThermalState() {
+ try {
+ if (checkService()) {
+ return sService.getThermalState();
+ }
+ } catch (RemoteException e) {
+ }
+ return ThermalListenerCallback.State.STATE_UNKNOWN;
+ }
+
+ /**
+ * Register a callback to be notified of thermal state changes
+ * @return boolean indicating whether register succeeded or failed
+ */
+ public boolean registerThermalListener(ThermalListenerCallback thermalCallback) {
+ try {
+ if (checkService()) {
+ return sService.registerThermalListener(thermalCallback);
+ }
+ } catch (RemoteException e) {
+ }
+ return false;
+ }
+
+ /**
+ * Unregister a callback previously registered to be notified of thermal state changes
+ * @return boolean indicating whether un-registering succeeded or failed
+ */
+ public boolean unRegisterThermalListener(ThermalListenerCallback thermalCallback) {
+ try {
+ if (checkService()) {
+ return sService.unRegisterThermalListener(thermalCallback);
+ }
+ } catch (RemoteException e) {
+ }
+ return false;
+ }
}
diff --git a/src/java/cyanogenmod/hardware/ICMHardwareService.aidl b/src/java/cyanogenmod/hardware/ICMHardwareService.aidl
index edb1b1d..6da7b1f 100644
--- a/src/java/cyanogenmod/hardware/ICMHardwareService.aidl
+++ b/src/java/cyanogenmod/hardware/ICMHardwareService.aidl
@@ -17,6 +17,7 @@
package cyanogenmod.hardware;
import cyanogenmod.hardware.DisplayMode;
+import cyanogenmod.hardware.IThermalListenerCallback;
/** @hide */
interface ICMHardwareService {
@@ -50,4 +51,8 @@ interface ICMHardwareService {
boolean writePersistentBytes(String key, in byte[] bytes);
byte[] readPersistentBytes(String key);
+
+ int getThermalState();
+ boolean registerThermalListener(IThermalListenerCallback callback);
+ boolean unRegisterThermalListener(IThermalListenerCallback callback);
}
diff --git a/src/java/cyanogenmod/hardware/IThermalListenerCallback.aidl b/src/java/cyanogenmod/hardware/IThermalListenerCallback.aidl
new file mode 100644
index 0000000..1a53af2
--- /dev/null
+++ b/src/java/cyanogenmod/hardware/IThermalListenerCallback.aidl
@@ -0,0 +1,21 @@
+/**
+ * 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;
+
+interface IThermalListenerCallback {
+ void onThermalChanged(int state);
+}
diff --git a/src/java/cyanogenmod/hardware/ThermalListenerCallback.java b/src/java/cyanogenmod/hardware/ThermalListenerCallback.java
new file mode 100644
index 0000000..d534674
--- /dev/null
+++ b/src/java/cyanogenmod/hardware/ThermalListenerCallback.java
@@ -0,0 +1,44 @@
+/**
+ * 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;
+
+/**
+ * Callback class to register for thermal state changes
+ */
+public abstract class ThermalListenerCallback extends IThermalListenerCallback.Stub {
+ public static final class State {
+ public static final int STATE_UNKNOWN = -1;
+ public static final int STATE_COOL = 0;
+ public static final int STATE_NORMAL = 1;
+ public static final int STATE_HIGH = 2;
+ public static final int STATE_EXTREME = 3;
+ public static final String toString(int state) {
+ switch (state) {
+ case STATE_COOL:
+ return "STATE_COOL";
+ case STATE_NORMAL:
+ return "STATE_NORMAL";
+ case STATE_HIGH:
+ return "STATE_HIGH";
+ case STATE_EXTREME:
+ return "STATE_EXTREME";
+ default:
+ return "STATE_UNKNOWN";
+ }
+ }
+ }
+}