userspace reboot: stop post-data services and wait for them to be killed
* Refactored code around stopping services a little bit to reuse it
between full reboot and userspace reboot.
* Add a scope_guard to fallback to full reboot in case userspace reboot
fails.
* In case of userspace reboot init will also wait for services to be
terminated/killed and log the ones that didn't react to
SIGTERM/SIGKILL in time.
* If some of the services didn't react to SIGKILL, fail userspace reboot.
Test: adb reboot userspace
Bug: 135984674
Change-Id: I820c7bc406169333b0f929f0eea028d8384eb2ac
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 4f9b93e..c5bf1603 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -918,11 +918,14 @@
on init && property:ro.debuggable=1
start console
-on userspace-reboot:
+on userspace-reboot
# TODO(b/135984674): reset all necessary properties here.
setprop sys.init.userspace_reboot_in_progress 1
+ setprop sys.boot_completed 0
+ setprop sys.init.updatable_crashing 0
+ setprop apexd.status 0
-on userspace-reboot-resume:
+on userspace-reboot-resume
# TODO(b/135984674): remount userdata and reset checkpointing
trigger nonencrypted
trigger post-fs-data