CMSdk : Add ThermalMonitor

Change-Id: Iafc87cf4c79feac5e2c66bb3d1945da6d0b742da
This commit is contained in:
Danesh M 2015-09-21 17:49:42 -07:00
parent e2daff9588
commit 2acf3ea1c4
4 changed files with 118 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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";
}
}
}
}