If no battery stats are found, return status_unknown

If the battery files can't be found return status_unkown instead of an
error.  On systems where we haven't brought up battery stats yet they
assume the battery is dead and turn off as soon as the runtime starts

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
This commit is contained in:
Rebecca Schultz Zavin
2009-04-28 17:24:47 -07:00
parent ef65477523
commit e7e6fa3fbf

View File

@@ -186,6 +186,9 @@ static void android_server_BatteryService_update(JNIEnv* env, jobject obj)
if (readFromFile(BATTERY_STATUS_PATH, buf, SIZE) > 0)
env->SetIntField(obj, gFieldIds.mBatteryStatus, getBatteryStatus(buf));
else
env->SetIntField(obj, gFieldIds.mBatteryStatus,
gConstants.statusUnknown);
if (readFromFile(BATTERY_HEALTH_PATH, buf, SIZE) > 0)
env->SetIntField(obj, gFieldIds.mBatteryHealth, getBatteryHealth(buf));