init: Replace property_set() with android::base::SetProperty()

Init is no longer a special case and talks to property service just
like every other client, therefore move it away from property_set()
and to android::base::SetProperty().

In doing so, this change moves the initial property set up from the
kernel command line and property files directly into PropertyInit().
This makes the responsibilities between init and property services
more clear.

Test: boot, unit test cases
Change-Id: I36b8c83e845d887f1b203355c2391ec123c3d05f
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 98a9805..1028330 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -84,6 +84,7 @@
 using namespace std::literals::string_literals;
 
 using android::base::Basename;
+using android::base::SetProperty;
 using android::base::StartsWith;
 using android::base::StringPrintf;
 using android::base::unique_fd;
@@ -561,16 +562,16 @@
             LOG(ERROR) << "Userdata remount is not supported on FDE devices. How did you get here?";
             trigger_shutdown("reboot,requested-userdata-remount-on-fde-device");
         }
-        property_set("ro.crypto.state", "encrypted");
-        property_set("ro.crypto.type", "block");
+        SetProperty("ro.crypto.state", "encrypted");
+        SetProperty("ro.crypto.type", "block");
         ActionManager::GetInstance().QueueEventTrigger("defaultcrypto");
         return {};
     } else if (code == FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) {
-        property_set("ro.crypto.state", "unencrypted");
+        SetProperty("ro.crypto.state", "unencrypted");
         ActionManager::GetInstance().QueueEventTrigger("nonencrypted");
         return {};
     } else if (code == FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE) {
-        property_set("ro.crypto.state", "unsupported");
+        SetProperty("ro.crypto.state", "unsupported");
         ActionManager::GetInstance().QueueEventTrigger("nonencrypted");
         return {};
     } else if (code == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY) {
@@ -586,8 +587,8 @@
         if (!FscryptInstallKeyring()) {
             return Error() << "FscryptInstallKeyring() failed";
         }
-        property_set("ro.crypto.state", "encrypted");
-        property_set("ro.crypto.type", "file");
+        SetProperty("ro.crypto.state", "encrypted");
+        SetProperty("ro.crypto.type", "file");
 
         // Although encrypted, we have device key, so we do not need to
         // do anything different from the nonencrypted case.
@@ -597,8 +598,8 @@
         if (!FscryptInstallKeyring()) {
             return Error() << "FscryptInstallKeyring() failed";
         }
-        property_set("ro.crypto.state", "encrypted");
-        property_set("ro.crypto.type", "file");
+        SetProperty("ro.crypto.state", "encrypted");
+        SetProperty("ro.crypto.type", "file");
 
         // Although encrypted, vold has already set the device up, so we do not need to
         // do anything different from the nonencrypted case.
@@ -608,8 +609,8 @@
         if (!FscryptInstallKeyring()) {
             return Error() << "FscryptInstallKeyring() failed";
         }
-        property_set("ro.crypto.state", "encrypted");
-        property_set("ro.crypto.type", "file");
+        SetProperty("ro.crypto.state", "encrypted");
+        SetProperty("ro.crypto.type", "file");
 
         // Although encrypted, vold has already set the device up, so we do not need to
         // do anything different from the nonencrypted case.
@@ -662,7 +663,7 @@
     }
 
     auto mount_fstab_return_code = fs_mgr_mount_all(&fstab, mount_mode);
-    property_set(prop_name, std::to_string(t.duration().count()));
+    SetProperty(prop_name, std::to_string(t.duration().count()));
 
     if (import_rc && SelinuxGetVendorAndroidVersion() <= __ANDROID_API_Q__) {
         /* Paths of .rc files are specified at the 2nd argument and beyond */
@@ -718,7 +719,7 @@
                        << "' from init; use the restorecon builtin directly";
     }
 
-    property_set(args[1], args[2]);
+    SetProperty(args[1], args[2]);
     return {};
 }
 
@@ -832,7 +833,7 @@
         // To be consistent in vboot 1.0 and vboot 2.0 (AVB), use "system" for the partition even
         // for system as root, so it has property [partition.system.verified].
         std::string partition = entry.mount_point == "/" ? "system" : Basename(entry.mount_point);
-        property_set("partition." + partition + ".verified", std::to_string(mode));
+        SetProperty("partition." + partition + ".verified", std::to_string(mode));
     }
 
     return {};
@@ -1221,8 +1222,8 @@
 static Result<void> do_finish_userspace_reboot(const BuiltinArguments&) {
     LOG(INFO) << "Userspace reboot successfully finished";
     boot_clock::time_point now = boot_clock::now();
-    property_set("sys.init.userspace_reboot.last_finished",
-                 std::to_string(now.time_since_epoch().count()));
+    SetProperty("sys.init.userspace_reboot.last_finished",
+                std::to_string(now.time_since_epoch().count()));
     if (!android::sysprop::InitProperties::userspace_reboot_in_progress(false)) {
         return Error() << "Failed to set sys.init.userspace_reboot.in_progress property";
     }