diff options
author | Nikita Ioffe <ioffe@google.com> | 2019-11-13 21:47:06 +0000 |
---|---|---|
committer | Nikita Ioffe <ioffe@google.com> | 2019-11-14 01:38:05 +0000 |
commit | c0df1874adf45fa962d76be1049fec8d445e3134 (patch) | |
tree | 50baab64511f155f3a083c352aefd9ecbb298a55 /init/builtins.cpp | |
parent | 8e2f75e3192fe5b12516bc927e9c8f928c0c0849 (diff) |
Add sysprops for start & end of userspace reboot
There will be useful in debugging/logging events to statsd.
Also as part of this CL, sys.init.userspace_reboot.in_progress property
is now used as a mean of synchronization. It is set directly in
DoUserspaceReboot, to make sure that all the setprop actions triggered
by userspace-reboot-requested were processed.
Test: adb reboot userspace
Test: adb shell getprop sys.init.userspace_reboot.last_started
Test: adb shell getprop sys.init.userspace_reboot.last_finished
Bug: 135984674
Change-Id: I9debcd4f058e790855200d5295344dafb30e496a
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r-- | init/builtins.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp index a55514b82..8f5814536 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -65,6 +65,7 @@ #include "action_manager.h" #include "bootchart.h" +#include "builtin_arguments.h" #include "fscrypt_init_extensions.h" #include "init.h" #include "mount_namespace.h" @@ -1216,6 +1217,15 @@ static Result<void> do_enter_default_mount_ns(const BuiltinArguments& args) { } } +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())); + property_set(kUserspaceRebootInProgress, "0"); + return {}; +} + // Builtin-function-map start const BuiltinFunctionMap& GetBuiltinFunctionMap() { constexpr std::size_t kMax = std::numeric_limits<std::size_t>::max(); @@ -1237,6 +1247,7 @@ const BuiltinFunctionMap& GetBuiltinFunctionMap() { {"exec_background", {1, kMax, {false, do_exec_background}}}, {"exec_start", {1, 1, {false, do_exec_start}}}, {"export", {2, 2, {false, do_export}}}, + {"finish_userspace_reboot", {0, 0, {false, do_finish_userspace_reboot}}}, {"hostname", {1, 1, {true, do_hostname}}}, {"ifup", {1, 1, {true, do_ifup}}}, {"init_user0", {0, 0, {false, do_init_user0}}}, |