[automerger skipped] minadbd sends heartbeat to rescue service for getprop command.
am: dd0158ac60 -s ours
am skip reason: change_id Ib9d5ed710cfa94ecfe6cf393a71a0b67b2539531 with SHA1 0bbb2ed53e is in history

Change-Id: I02a82fc0d026e06eadbadd6af0af85228ce2e044
diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp
index 6c10274..03341e4 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 @@
   }
 }
 
+// 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);