diff options
author | Tao Bao <tbao@google.com> | 2019-10-07 17:37:00 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-10-07 17:37:00 +0200 |
commit | 58b5a5a5500fe9cd6f5ca2bced59fc19885269fa (patch) | |
tree | 3a9222aa6884312558b4d88f3f3814613f208134 /minadbd/minadbd_services.cpp | |
parent | Merge "Moving recovery resources from /system to /vendor" (diff) | |
parent | Merge "minadbd: Return battery level via getprop." (diff) | |
download | android_bootable_recovery-58b5a5a5500fe9cd6f5ca2bced59fc19885269fa.tar android_bootable_recovery-58b5a5a5500fe9cd6f5ca2bced59fc19885269fa.tar.gz android_bootable_recovery-58b5a5a5500fe9cd6f5ca2bced59fc19885269fa.tar.bz2 android_bootable_recovery-58b5a5a5500fe9cd6f5ca2bced59fc19885269fa.tar.lz android_bootable_recovery-58b5a5a5500fe9cd6f5ca2bced59fc19885269fa.tar.xz android_bootable_recovery-58b5a5a5500fe9cd6f5ca2bced59fc19885269fa.tar.zst android_bootable_recovery-58b5a5a5500fe9cd6f5ca2bced59fc19885269fa.zip |
Diffstat (limited to '')
-rw-r--r-- | minadbd/minadbd_services.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index cabcdaa09..eb91fb3e4 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -44,6 +44,7 @@ #include "fuse_adb_provider.h" #include "fuse_sideload.h" #include "minadbd/types.h" +#include "recovery_utils/battery_utils.h" #include "services.h" #include "sysdeps.h" @@ -160,7 +161,10 @@ static void RescueInstallHostService(unique_fd sfd, const std::string& args) { // If given an empty string, dumps all the supported properties (analogous to `adb shell getprop`) // in lines, e.g. "[prop]: [value]". static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) { + constexpr const char* kRescueBatteryLevelProp = "rescue.battery_level"; static const std::set<std::string> kGetpropAllowedProps = { + // clang-format off + kRescueBatteryLevelProp, "ro.build.date.utc", "ro.build.fingerprint", "ro.build.flavor", @@ -170,18 +174,28 @@ static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) { "ro.build.version.incremental", "ro.product.device", "ro.product.vendor.device", + // clang-format on }; + + auto query_prop = [](const std::string& key) { + if (key == kRescueBatteryLevelProp) { + auto battery_info = GetBatteryInfo(); + return std::to_string(battery_info.capacity); + } + return android::base::GetProperty(key, ""); + }; + std::string result; if (prop.empty()) { for (const auto& key : kGetpropAllowedProps) { - auto value = android::base::GetProperty(key, ""); + auto value = query_prop(key); if (value.empty()) { continue; } result += "[" + key + "]: [" + value + "]\n"; } } else if (kGetpropAllowedProps.find(prop) != kGetpropAllowedProps.end()) { - result = android::base::GetProperty(prop, "") + "\n"; + result = query_prop(prop) + "\n"; } if (result.empty()) { result = "\n"; |