summaryrefslogtreecommitdiffstats
path: root/minadbd
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2019-06-05 22:43:55 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-06-05 22:43:55 +0200
commit533a12c71ebaf4e1f28734e05a1b72831cd7cc55 (patch)
treeacbc6e7b8b37c397c689a3694cd54b733eed5ede /minadbd
parentMerge "minadbd: More allowed properties." (diff)
parentminadbd: Support `adb rescue getprop`. (diff)
downloadandroid_bootable_recovery-533a12c71ebaf4e1f28734e05a1b72831cd7cc55.tar
android_bootable_recovery-533a12c71ebaf4e1f28734e05a1b72831cd7cc55.tar.gz
android_bootable_recovery-533a12c71ebaf4e1f28734e05a1b72831cd7cc55.tar.bz2
android_bootable_recovery-533a12c71ebaf4e1f28734e05a1b72831cd7cc55.tar.lz
android_bootable_recovery-533a12c71ebaf4e1f28734e05a1b72831cd7cc55.tar.xz
android_bootable_recovery-533a12c71ebaf4e1f28734e05a1b72831cd7cc55.tar.zst
android_bootable_recovery-533a12c71ebaf4e1f28734e05a1b72831cd7cc55.zip
Diffstat (limited to 'minadbd')
-rw-r--r--minadbd/minadbd_services.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp
index 5eda73e40..d2b824cfe 100644
--- a/minadbd/minadbd_services.cpp
+++ b/minadbd/minadbd_services.cpp
@@ -25,10 +25,10 @@
#include <functional>
#include <memory>
+#include <set>
#include <string>
#include <string_view>
#include <thread>
-#include <unordered_set>
#include <android-base/file.h>
#include <android-base/logging.h>
@@ -156,8 +156,11 @@ static void RescueInstallHostService(unique_fd sfd, const std::string& args) {
}
}
+// Answers the query on a given property. The result will be written to the given sfd. If given an
+// empty string, dumps all the supported properties (similar to `adb shell getprop`) in lines, e.g.
+// "[prop]: [value]".
static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) {
- static const std::unordered_set<std::string> kGetpropAllowedProps = {
+ static const std::set<std::string> kGetpropAllowedProps = {
"ro.build.date.utc",
"ro.build.fingerprint",
"ro.build.flavor",
@@ -168,12 +171,22 @@ static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) {
"ro.product.device",
"ro.product.vendor.device",
};
- auto allowed = kGetpropAllowedProps.find(prop) != kGetpropAllowedProps.end();
- if (!allowed) {
+ if (!prop.empty() && kGetpropAllowedProps.find(prop) == kGetpropAllowedProps.end()) {
return;
}
- auto result = android::base::GetProperty(prop, "");
+ std::string result;
+ if (prop.empty()) {
+ for (const auto& key : kGetpropAllowedProps) {
+ auto value = android::base::GetProperty(key, "");
+ if (value.empty()) {
+ continue;
+ }
+ result += "[" + key + "]: [" + value + "]\n";
+ }
+ } else {
+ result = android::base::GetProperty(prop, "");
+ }
if (result.empty()) {
return;
}