Support showing "Cold" battery health.

The Linux kernel supports reporting "cold" battery health to sysfs.
Android framework has not implemented this and it defaults to "unknown"
This adds handling the cold battery health.

Change-Id: Idcc156aae6aabce73391081143f79d052edf332e
This commit is contained in:
Imre Sunyi
2010-09-20 18:02:50 +02:00
committed by Jean-Baptiste Queru
parent bd1454f500
commit 9239612870
3 changed files with 17 additions and 0 deletions

View File

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