init: trigger shutdown directly from builtins
Especially now that property_service is a thread, there may be some
delay between when init sets sys.powerctl and when the main thread of
init receives this and triggers shutdown. It's possible that
outstanding init commands are run during this gap and that is not
desirable.
Instead, have builtins call TriggerShutdown() directly, so we can be
sure that the next action that init runs will be to shutdown the
device.
Test: reboot works
Test: reboot into recovery due to bad /data works
Change-Id: I26fb9f4f57f46c7451b8b58187138cfedd6fd9eb
diff --git a/init/reboot.cpp b/init/reboot.cpp
index 4b892b7..d77b975 100644
--- a/init/reboot.cpp
+++ b/init/reboot.cpp
@@ -710,7 +710,7 @@
auto guard = android::base::make_scope_guard([] {
// Leave shutdown so that we can handle a full reboot.
LeaveShutdown();
- property_set("sys.powerctl", "reboot,abort-userspace-reboot");
+ TriggerShutdown("reboot,abort-userspace-reboot");
});
// Triggering userspace-reboot-requested will result in a bunch of set_prop
// actions. We should make sure, that all of them are propagated before