OSDN Git Service

BatteryService: fix logic errors
authorChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 23 Jul 2013 05:52:11 +0000 (13:52 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 25 Sep 2013 02:45:43 +0000 (10:45 +0800)
(!String8_instance) doesn't mean an empty string. The object is
implicitly casted to const char *. Therefore it just means
(!String8_instance.string()) which is always false.

services/jni/com_android_server_BatteryService.cpp

index 433950d..2d2621b 100644 (file)
@@ -376,22 +376,14 @@ int register_android_server_BatteryService(JNIEnv* env)
         closedir(dir);
     }
 
-    if (!gChargerNames.size())
-        ALOGE("No charger supplies found");
-    if (!gPaths.batteryStatusPath)
-        ALOGE("batteryStatusPath not found");
-    if (!gPaths.batteryHealthPath)
-        ALOGE("batteryHealthPath not found");
-    if (!gPaths.batteryPresentPath)
-        ALOGE("batteryPresentPath not found");
-    if (!gPaths.batteryCapacityPath)
-        ALOGE("batteryCapacityPath not found");
-    if (!gPaths.batteryVoltagePath)
-        ALOGE("batteryVoltagePath not found");
-    if (!gPaths.batteryTemperaturePath)
-        ALOGE("batteryTemperaturePath not found");
-    if (!gPaths.batteryTechnologyPath)
-        ALOGE("batteryTechnologyPath not found");
+    ALOGE_IF(gChargerNames.isEmpty(), "No charger supplies found");
+    ALOGE_IF(gPaths.batteryStatusPath.isEmpty(), "batteryStatusPath not found");
+    ALOGE_IF(gPaths.batteryHealthPath.isEmpty(), "batteryHealthPath not found");
+    ALOGE_IF(gPaths.batteryPresentPath.isEmpty(), "batteryPresentPath not found");
+    ALOGE_IF(gPaths.batteryCapacityPath.isEmpty(), "batteryCapacityPath not found");
+    ALOGE_IF(gPaths.batteryVoltagePath.isEmpty(), "batteryVoltagePath not found");
+    ALOGE_IF(gPaths.batteryTemperaturePath.isEmpty(), "batteryTemperaturePath not found");
+    ALOGE_IF(gPaths.batteryTechnologyPath.isEmpty(), "batteryTechnologyPath not found");
 
     jclass clazz = env->FindClass("com/android/server/BatteryService");