init: only set ro.boottime.<service> properties once.

Currently, init attempts to set ro.boottime.<service> properties
whenever a service starts, however since these properties are ro. this
means that an error is printed whenever a service is restarted.

Since these properties are intended for reporting boottime, these
subsequent writes during restarts are erroneous and therefore this
change stops attempting to write them, thus silencing the error.

Test: boot bullhead, restart processes, observe no error print
Change-Id: I372f8d5c26590fc0661b92f632410e23e6418841
This commit is contained in:
Tom Cherry 2017-08-18 10:47:46 -07:00
parent 334929b525
commit fed3373b5b

View file

@ -201,7 +201,10 @@ void Service::NotifyStateChange(const std::string& new_state) const {
if (new_state == "running") {
uint64_t start_ns = time_started_.time_since_epoch().count();
property_set("ro.boottime." + name_, std::to_string(start_ns));
std::string boottime_property = "ro.boottime." + name_;
if (GetProperty(boottime_property, "").empty()) {
property_set(boottime_property, std::to_string(start_ns));
}
}
}