Switch adb to <android-base/properties.h>.

Bug: http://b/23102347
Test: manual
Change-Id: Iffa66258c01f84f41b9af99ab5e768a0a2669106
diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp
index b54243e..094988a 100644
--- a/adb/daemon/main.cpp
+++ b/adb/daemon/main.cpp
@@ -29,11 +29,11 @@
 
 #include <android-base/logging.h>
 #include <android-base/macros.h>
+#include <android-base/properties.h>
 #include <android-base/stringprintf.h>
 #include <libminijail.h>
 #include <scoped_minijail.h>
 
-#include "cutils/properties.h"
 #include "debuggerd/client.h"
 #include "private/android_filesystem_config.h"
 #include "selinux/android.h"
@@ -48,9 +48,7 @@
 
 static void drop_capabilities_bounding_set_if_needed(struct minijail *j) {
 #if defined(ALLOW_ADBD_ROOT)
-    char value[PROPERTY_VALUE_MAX];
-    property_get("ro.debuggable", value, "");
-    if (strcmp(value, "1") == 0) {
+    if (android::base::GetBoolProperty("ro.debuggable", false)) {
         return;
     }
 #endif
@@ -59,8 +57,6 @@
 
 static bool should_drop_privileges() {
 #if defined(ALLOW_ADBD_ROOT)
-    char value[PROPERTY_VALUE_MAX];
-
     // The properties that affect `adb root` and `adb unroot` are ro.secure and
     // ro.debuggable. In this context the names don't make the expected behavior
     // particularly obvious.
@@ -71,24 +67,19 @@
     //
     // ro.secure:
     //   Drop privileges by default. Set to 1 on userdebug and user builds.
-    property_get("ro.secure", value, "1");
-    bool ro_secure = (strcmp(value, "1") == 0);
-
-    property_get("ro.debuggable", value, "");
-    bool ro_debuggable = (strcmp(value, "1") == 0);
+    bool ro_secure = android::base::GetBoolProperty("ro.secure", true);
+    bool ro_debuggable = android::base::GetBoolProperty("ro.debuggable", false);
 
     // Drop privileges if ro.secure is set...
     bool drop = ro_secure;
 
-    property_get("service.adb.root", value, "");
-    bool adb_root = (strcmp(value, "1") == 0);
-    bool adb_unroot = (strcmp(value, "0") == 0);
-
     // ... except "adb root" lets you keep privileges in a debuggable build.
+    std::string prop = android::base::GetProperty("service.adb.root", "");
+    bool adb_root = (prop == "1");
+    bool adb_unroot = (prop == "0");
     if (ro_debuggable && adb_root) {
         drop = false;
     }
-
     // ... and "adb unroot" lets you explicitly drop privileges.
     if (adb_unroot) {
         drop = true;
@@ -159,7 +150,7 @@
     // descriptor will always be open.
     adbd_cloexec_auth_socket();
 
-    if (ALLOW_ADBD_NO_AUTH && property_get_bool("ro.adb.secure", 0) == 0) {
+    if (ALLOW_ADBD_NO_AUTH && !android::base::GetBoolProperty("ro.adb.secure", false)) {
         auth_required = false;
     }
 
@@ -187,14 +178,13 @@
     // If one of these properties is set, also listen on that port.
     // If one of the properties isn't set and we couldn't listen on usb, listen
     // on the default port.
-    char prop_port[PROPERTY_VALUE_MAX];
-    property_get("service.adb.tcp.port", prop_port, "");
-    if (prop_port[0] == '\0') {
-        property_get("persist.adb.tcp.port", prop_port, "");
+    std::string prop_port = android::base::GetProperty("service.adb.tcp.port", "");
+    if (prop_port.empty()) {
+        prop_port = android::base::GetProperty("persist.adb.tcp.port", "");
     }
 
     int port;
-    if (sscanf(prop_port, "%d", &port) == 1 && port > 0) {
+    if (sscanf(prop_port.c_str(), "%d", &port) == 1 && port > 0) {
         D("using port=%d", port);
         // Listen on TCP port specified by service.adb.tcp.port property.
         local_init(port);