summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalesh Singh <kaleshsingh@google.com>2022-03-18 19:55:36 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-03-18 19:55:36 +0000
commitecce139c533f9339ccf49c7ed2a722f2337c4c3d (patch)
tree4e52cf8ea2a4a31167a0a1eedb45cdf03a806284
parent671d96ddecdd83eb61dfea033035fc93d6da0551 (diff)
parent2e32e07e7287c22c5642a1b5155db8c0a00763fc (diff)
downloadinterfaces-ecce139c533f9339ccf49c7ed2a722f2337c4c3d.tar.gz
Merge "system suspend: Handle unexpected wakelock stat value format" am: 2e32e07e72
Original change: https://android-review.googlesource.com/c/platform/system/hardware/interfaces/+/2030852 Change-Id: I6f331c076a2a8d4f9adb41f653e0ec30f607bf9e
-rw-r--r--suspend/1.0/default/WakeLockEntryList.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/suspend/1.0/default/WakeLockEntryList.cpp b/suspend/1.0/default/WakeLockEntryList.cpp
index d0bb1ce..a5b1de5 100644
--- a/suspend/1.0/default/WakeLockEntryList.cpp
+++ b/suspend/1.0/default/WakeLockEntryList.cpp
@@ -18,10 +18,15 @@
#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/parseint.h>
+#include <android-base/stringprintf.h>
#include <iomanip>
+using android::base::ParseInt;
using android::base::ReadFdToString;
+using android::base::Readlink;
+using android::base::StringPrintf;
namespace android {
namespace system {
@@ -258,7 +263,17 @@ WakeLockInfo WakeLockEntryList::createKernelEntry(const std::string& kwlId) cons
continue;
}
- int64_t statVal = std::stoll(valStr);
+ int64_t statVal;
+ if (!ParseInt(valStr, &statVal)) {
+ std::string path;
+ if (Readlink(StringPrintf("/proc/self/fd/%d", statFd.get()), &path)) {
+ LOG(ERROR) << "Unexpected format for wakelock stat value (" << valStr
+ << ") from file: " << path;
+ } else {
+ LOG(ERROR) << "Unexpected format for wakelock stat value (" << valStr << ")";
+ }
+ continue;
+ }
if (statName == "active_count") {
info.activeCount = statVal;