summaryrefslogtreecommitdiffstats
path: root/services/jni/com_android_server_BatteryService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/jni/com_android_server_BatteryService.cpp')
-rw-r--r--services/jni/com_android_server_BatteryService.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/services/jni/com_android_server_BatteryService.cpp b/services/jni/com_android_server_BatteryService.cpp
index 8e7cadc..d4513e9 100644
--- a/services/jni/com_android_server_BatteryService.cpp
+++ b/services/jni/com_android_server_BatteryService.cpp
@@ -67,6 +67,7 @@ struct BatteryManagerConstants {
jint healthDead;
jint healthOverVoltage;
jint healthUnspecifiedFailure;
+ jint healthCold;
};
static BatteryManagerConstants gConstants;
@@ -104,6 +105,7 @@ static jint getBatteryStatus(const char* status)
static jint getBatteryHealth(const char* status)
{
switch (status[0]) {
+ case 'C': return gConstants.healthCold; // Cold
case 'D': return gConstants.healthDead; // Dead
case 'G': return gConstants.healthGood; // Good
case 'O': {
@@ -162,7 +164,7 @@ static void setBooleanField(JNIEnv* env, jobject obj, const char* path, jfieldID
jboolean value = false;
if (readFromFile(path, buf, SIZE) > 0) {
- if (buf[0] == '1') {
+ if (buf[0] != '0') {
value = true;
}
}
@@ -390,6 +392,9 @@ int register_android_server_BatteryService(JNIEnv* env)
gConstants.healthUnspecifiedFailure = env->GetStaticIntField(clazz,
env->GetStaticFieldID(clazz, "BATTERY_HEALTH_UNSPECIFIED_FAILURE", "I"));
+ gConstants.healthCold = env->GetStaticIntField(clazz,
+ env->GetStaticFieldID(clazz, "BATTERY_HEALTH_COLD", "I"));
+
return jniRegisterNativeMethods(env, "com/android/server/BatteryService", sMethods, NELEM(sMethods));
}