Merge "GetBatteryInfo() also reads AIDL health HAL." am: d33b067f04 am: 9113d57446
Original change: https://android-review.googlesource.com/c/platform/bootable/recovery/+/1906334
Change-Id: I46ab2529c774cd5563b9568a9d6eed52e4ca7676
diff --git a/minui/events.cpp b/minui/events.cpp
index 87f8112..863ac74 100644
--- a/minui/events.cpp
+++ b/minui/events.cpp
@@ -29,7 +29,9 @@
#include <functional>
#include <memory>
+#include <string>
+#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include "minui/minui.h"
@@ -118,12 +120,12 @@
}
offset += sizeof(inotify_event) + pevent->len;
- pevent->name[pevent->len] = '\0';
- if (strncmp(pevent->name, "event", 5)) {
+ std::string event_name(pevent->name, pevent->len);
+ if (!android::base::StartsWith(event_name, "event")) {
continue;
}
- android::base::unique_fd dfd(openat(dirfd(dir.get()), pevent->name, O_RDONLY));
+ android::base::unique_fd dfd(openat(dirfd(dir.get()), event_name.c_str(), O_RDONLY));
if (dfd == -1) {
break;
}