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/service.cpp b/init/service.cpp
index ad42df7..cc97d94 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -45,7 +45,6 @@
#include <android/api-level.h>
#include "mount_namespace.h"
-#include "property_service.h"
#include "selinux.h"
#else
#include "host_init_stubs.h"
@@ -55,6 +54,7 @@
using android::base::GetProperty;
using android::base::Join;
using android::base::make_scope_guard;
+using android::base::SetProperty;
using android::base::StartsWith;
using android::base::StringPrintf;
using android::base::WriteStringToFile;
@@ -164,13 +164,13 @@
}
std::string prop_name = "init.svc." + name_;
- property_set(prop_name, new_state);
+ SetProperty(prop_name, new_state);
if (new_state == "running") {
uint64_t start_ns = time_started_.time_since_epoch().count();
std::string boottime_property = "ro.boottime." + name_;
if (GetProperty(boottime_property, "").empty()) {
- property_set(boottime_property, std::to_string(start_ns));
+ SetProperty(boottime_property, std::to_string(start_ns));
}
}
@@ -178,9 +178,9 @@
// on device for security checks.
std::string pid_property = "init.svc_debug_pid." + name_;
if (new_state == "running") {
- property_set(pid_property, std::to_string(pid_));
+ SetProperty(pid_property, std::to_string(pid_));
} else if (new_state == "stopped") {
- property_set(pid_property, "");
+ SetProperty(pid_property, "");
}
}
@@ -324,7 +324,7 @@
LOG(ERROR) << "updatable process '" << name_ << "' exited 4 times "
<< (boot_completed ? "in 4 minutes" : "before boot completed");
// Notifies update_verifier and apexd
- property_set("sys.init.updatable_crashing", "1");
+ SetProperty("sys.init.updatable_crashing", "1");
}
}
} else {