summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2019-06-11 02:52:27 +0200
committerandroid-build-merger <android-build-merger@google.com>2019-06-11 02:52:27 +0200
commit860448ffec5dc25b16c5039f1a24699ae1e52490 (patch)
tree7a922a82acc8bad61354ed53665a6b9e573fd930
parentMerge "minadbd: Support `adb rescue getprop`." am: 533a12c71e am: 0d00c1bf12 am: 024b53abe3 (diff)
parentMerge "minadbd: `adb rescue getprop` returns newline-terminated result." am: cb930939a4 am: d401ed099e (diff)
downloadandroid_bootable_recovery-860448ffec5dc25b16c5039f1a24699ae1e52490.tar
android_bootable_recovery-860448ffec5dc25b16c5039f1a24699ae1e52490.tar.gz
android_bootable_recovery-860448ffec5dc25b16c5039f1a24699ae1e52490.tar.bz2
android_bootable_recovery-860448ffec5dc25b16c5039f1a24699ae1e52490.tar.lz
android_bootable_recovery-860448ffec5dc25b16c5039f1a24699ae1e52490.tar.xz
android_bootable_recovery-860448ffec5dc25b16c5039f1a24699ae1e52490.tar.zst
android_bootable_recovery-860448ffec5dc25b16c5039f1a24699ae1e52490.zip
-rw-r--r--minadbd/minadbd_services.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp
index d2b824cfe..1e6eb3165 100644
--- a/minadbd/minadbd_services.cpp
+++ b/minadbd/minadbd_services.cpp
@@ -156,9 +156,10 @@ 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]".
+// 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::set<std::string> kGetpropAllowedProps = {
"ro.build.date.utc",
@@ -171,10 +172,6 @@ static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) {
"ro.product.device",
"ro.product.vendor.device",
};
- if (!prop.empty() && kGetpropAllowedProps.find(prop) == kGetpropAllowedProps.end()) {
- return;
- }
-
std::string result;
if (prop.empty()) {
for (const auto& key : kGetpropAllowedProps) {
@@ -184,11 +181,11 @@ static void RescueGetpropHostService(unique_fd sfd, const std::string& prop) {
}
result += "[" + key + "]: [" + value + "]\n";
}
- } else {
- result = android::base::GetProperty(prop, "");
+ } else if (kGetpropAllowedProps.find(prop) != kGetpropAllowedProps.end()) {
+ result = android::base::GetProperty(prop, "") + "\n";
}
if (result.empty()) {
- return;
+ result = "\n";
}
if (!android::base::WriteFully(sfd, result.data(), result.size())) {
exit(kMinadbdHostSocketIOError);