OSDN Git Service

BatteryService: Fix detection of missing sysfs attributes
authorTodd Poynor <toddpoynor@google.com>
Fri, 19 Apr 2013 19:57:09 +0000 (12:57 -0700)
committerTodd Poynor <toddpoynor@google.com>
Tue, 23 Apr 2013 01:16:16 +0000 (18:16 -0700)
Recent conversion from char* to String8 broke these.

Change-Id: I4528c3e4b90614cddbc173ee996c7fc1febb2cf5

services/jni/com_android_server_BatteryService.cpp

index 485c289..089ba4b 100644 (file)
@@ -144,7 +144,7 @@ static jint getBatteryHealth(const char* status)
 
 static int readFromFile(const String8& path, char* buf, size_t size)
 {
-    if (!path)
+    if (path.isEmpty())
         return -1;
     int fd = open(path.string(), O_RDONLY, 0);
     if (fd == -1) {
@@ -378,19 +378,19 @@ int register_android_server_BatteryService(JNIEnv* env)
 
     if (!gChargerNames.size())
         ALOGE("No charger supplies found");
-    if (!gPaths.batteryStatusPath)
+    if (gPaths.batteryStatusPath.isEmpty())
         ALOGE("batteryStatusPath not found");
-    if (!gPaths.batteryHealthPath)
+    if (gPaths.batteryHealthPath.isEmpty())
         ALOGE("batteryHealthPath not found");
-    if (!gPaths.batteryPresentPath)
+    if (gPaths.batteryPresentPath.isEmpty())
         ALOGE("batteryPresentPath not found");
-    if (!gPaths.batteryCapacityPath)
+    if (gPaths.batteryCapacityPath.isEmpty())
         ALOGE("batteryCapacityPath not found");
-    if (!gPaths.batteryVoltagePath)
+    if (gPaths.batteryVoltagePath.isEmpty())
         ALOGE("batteryVoltagePath not found");
-    if (!gPaths.batteryTemperaturePath)
+    if (gPaths.batteryTemperaturePath.isEmpty())
         ALOGE("batteryTemperaturePath not found");
-    if (!gPaths.batteryTechnologyPath)
+    if (gPaths.batteryTechnologyPath.isEmpty())
         ALOGE("batteryTechnologyPath not found");
 
     jclass clazz = env->FindClass("com/android/server/BatteryService");