summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-06-08 17:42:18 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-08 17:42:20 +0000
commitce1590dac98619fcedadf441ddc02c88fc431aa1 (patch)
tree1c04a2069452fd8838e11cbaeb4bba6e4d24e519
parent25bb4553f379c70244f52d4864eab18530aa0a2e (diff)
parent6b0331a03025f2ea8c966bf9406dd5788ffa176e (diff)
downloadframeworks_base-ce1590dac98619fcedadf441ddc02c88fc431aa1.zip
frameworks_base-ce1590dac98619fcedadf441ddc02c88fc431aa1.tar.gz
frameworks_base-ce1590dac98619fcedadf441ddc02c88fc431aa1.tar.bz2
Merge "Wait for wakeup_reasons on first init" into mnc-dev
-rw-r--r--services/core/jni/com_android_server_am_BatteryStatsService.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/services/core/jni/com_android_server_am_BatteryStatsService.cpp b/services/core/jni/com_android_server_am_BatteryStatsService.cpp
index da4cc48..3b9cc9d 100644
--- a/services/core/jni/com_android_server_am_BatteryStatsService.cpp
+++ b/services/core/jni/com_android_server_am_BatteryStatsService.cpp
@@ -62,8 +62,6 @@ static void wakeup_callback(void)
static jint nativeWaitWakeup(JNIEnv *env, jobject clazz, jintArray outIrqs,
jobjectArray outReasons)
{
- bool first_time = false;
-
if (outIrqs == NULL || outReasons == NULL) {
jniThrowException(env, "java/lang/NullPointerException", "null argument");
return -1;
@@ -83,19 +81,17 @@ static jint nativeWaitWakeup(JNIEnv *env, jobject clazz, jintArray outIrqs,
}
ALOGV("Registering callback...");
set_wakeup_callback(&wakeup_callback);
- // First time through, we will just drain the current wakeup reasons.
- first_time = true;
- } else {
- // On following calls, we need to wait for wakeup.
- ALOGV("Waiting for wakeup...");
- int ret = sem_wait(&wakeup_sem);
- if (ret < 0) {
- char buf[80];
- strerror_r(errno, buf, sizeof(buf));
- ALOGE("Error waiting on semaphore: %s\n", buf);
- // Return 0 here to let it continue looping but not return results.
- return 0;
- }
+ }
+
+ // Wait for wakeup.
+ ALOGV("Waiting for wakeup...");
+ int ret = sem_wait(&wakeup_sem);
+ if (ret < 0) {
+ char buf[80];
+ strerror_r(errno, buf, sizeof(buf));
+ ALOGE("Error waiting on semaphore: %s\n", buf);
+ // Return 0 here to let it continue looping but not return results.
+ return 0;
}
FILE *fp = fopen(LAST_RESUME_REASON, "r");
@@ -169,9 +165,6 @@ static jint nativeWaitWakeup(JNIEnv *env, jobject clazz, jintArray outIrqs,
}
ALOGV("Got %d reasons", i);
- if (first_time) {
- i = 0;
- }
if (i > 0) {
irqs[0] = firstirq;
*mergedreasonpos = 0;
@@ -185,7 +178,7 @@ static jint nativeWaitWakeup(JNIEnv *env, jobject clazz, jintArray outIrqs,
return -1;
}
- return first_time ? 0 : i;
+ return i;
}
static JNINativeMethod method_table[] = {