diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-06-12 05:26:18 +0200 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-06-12 05:26:18 +0200 |
commit | 48d38a678eaf2679e12a3bcaf43cf2899db2bd7d (patch) | |
tree | eac6422f971aa717cdddb2135362011d41881f1e | |
parent | Snap for 5606075 from af0a76d1c567fc4112ac6cc8112de3478a41dd2a to qt-c2f2-release (diff) | |
parent | minadbd: `adb rescue getprop` returns newline-terminated result. (diff) | |
download | android_bootable_recovery-48d38a678eaf2679e12a3bcaf43cf2899db2bd7d.tar android_bootable_recovery-48d38a678eaf2679e12a3bcaf43cf2899db2bd7d.tar.gz android_bootable_recovery-48d38a678eaf2679e12a3bcaf43cf2899db2bd7d.tar.bz2 android_bootable_recovery-48d38a678eaf2679e12a3bcaf43cf2899db2bd7d.tar.lz android_bootable_recovery-48d38a678eaf2679e12a3bcaf43cf2899db2bd7d.tar.xz android_bootable_recovery-48d38a678eaf2679e12a3bcaf43cf2899db2bd7d.tar.zst android_bootable_recovery-48d38a678eaf2679e12a3bcaf43cf2899db2bd7d.zip |
-rw-r--r-- | minadbd/minadbd_services.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index 1c4c0f494..68f940cd8 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,19 +156,36 @@ static void RescueInstallHostService(unique_fd sfd, const std::string& args) { } } +// Answers the query on a given property |prop|, by writing the result to the given |sfd|. The +// result will be newline-terminated, so nonexistent or nonallowed query will be answered with "\n". +// 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) { - static const std::unordered_set<std::string> kGetpropAllowedProps = { - "ro.build.fingerprint", + static const std::set<std::string> kGetpropAllowedProps = { "ro.build.date.utc", + "ro.build.fingerprint", + "ro.build.flavor", + "ro.build.id", + "ro.build.product", + "ro.build.tags", + "ro.build.version.incremental", + "ro.product.device", + "ro.product.vendor.device", }; - auto allowed = kGetpropAllowedProps.find(prop) != kGetpropAllowedProps.end(); - if (!allowed) { - return; + 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 if (kGetpropAllowedProps.find(prop) != kGetpropAllowedProps.end()) { + result = android::base::GetProperty(prop, "") + "\n"; } - - auto result = android::base::GetProperty(prop, ""); if (result.empty()) { - return; + result = "\n"; } if (!android::base::WriteFully(sfd, result.data(), result.size())) { exit(kMinadbdHostSocketIOError); |