summaryrefslogtreecommitdiffstats
path: root/minadbd
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2019-10-01 01:16:07 +0200
committerTao Bao <tbao@google.com>2019-10-05 00:33:27 +0200
commitb548bea77884649e84cdaaf6765dfd70c7d43ab1 (patch)
treed10d0dfb4c2cd725b7b0ccc15dbe1908ee4d2192 /minadbd
parentMerge "recovery_utils: Use libvoid_headers." (diff)
downloadandroid_bootable_recovery-b548bea77884649e84cdaaf6765dfd70c7d43ab1.tar
android_bootable_recovery-b548bea77884649e84cdaaf6765dfd70c7d43ab1.tar.gz
android_bootable_recovery-b548bea77884649e84cdaaf6765dfd70c7d43ab1.tar.bz2
android_bootable_recovery-b548bea77884649e84cdaaf6765dfd70c7d43ab1.tar.lz
android_bootable_recovery-b548bea77884649e84cdaaf6765dfd70c7d43ab1.tar.xz
android_bootable_recovery-b548bea77884649e84cdaaf6765dfd70c7d43ab1.tar.zst
android_bootable_recovery-b548bea77884649e84cdaaf6765dfd70c7d43ab1.zip
Diffstat (limited to 'minadbd')
-rw-r--r--minadbd/Android.bp4
-rw-r--r--minadbd/minadbd_services.cpp18
2 files changed, 20 insertions, 2 deletions
diff --git a/minadbd/Android.bp b/minadbd/Android.bp
index 071712599..b7075e670 100644
--- a/minadbd/Android.bp
+++ b/minadbd/Android.bp
@@ -40,6 +40,7 @@ cc_library {
defaults: [
"minadbd_defaults",
+ "librecovery_utils_defaults",
],
srcs: [
@@ -48,6 +49,7 @@ cc_library {
],
static_libs: [
+ "librecovery_utils",
"libotautil",
],
@@ -97,6 +99,7 @@ cc_test {
defaults: [
"minadbd_defaults",
+ "librecovery_utils_defaults",
],
srcs: [
@@ -107,6 +110,7 @@ cc_test {
static_libs: [
"libminadbd_services",
"libfusesideload",
+ "librecovery_utils",
"libotautil",
"libadbd",
],
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";