Move call to BootCompletedCleanup from OnBootCompleted into apexd_main
OnBootCompleted implements markBootCompleted binder, which is
synchronously called by StagingManager during boot to notify apexd of
the fact that staged sessions have been applied, and hence apexd should
stop monitoring for native crashes (now it's job of PackageWatchdog).
Because of that, we should don't any heavy work inside OnBootCompleted.
Instead, all the heavy cleanup work is now triggered from apexd_main
before calling AllowServiceShutdown to make sure that servicemanager
won't kill apexd in the middle of the cleanup routine.
Bug: 192426053
Bug: 190618831
Test: atest ApexTestCases
Change-Id: I45a23035bea3fda27a421a17e18792f2aa0a2de6
Merged-In: I45a23035bea3fda27a421a17e18792f2aa0a2de6
(cherry picked from commit 5368879048d0f6750c2008c9ab47963bd15fb468)
diff --git a/apexd/apexd.cpp b/apexd/apexd.cpp
index 2908688..b88cec4 100644
--- a/apexd/apexd.cpp
+++ b/apexd/apexd.cpp
@@ -1951,7 +1951,6 @@
void OnBootCompleted() {
ApexdLifecycle::GetInstance().MarkBootCompleted();
- BootCompletedCleanup();
}
// Returns true if any session gets staged
diff --git a/apexd/apexd_main.cpp b/apexd/apexd_main.cpp
index 26d5732..1326e38 100644
--- a/apexd/apexd_main.cpp
+++ b/apexd/apexd_main.cpp
@@ -185,6 +185,9 @@
lifecycle.WaitForBootStatus(android::apex::RevertActiveSessionsAndReboot);
}
+ // Run cleanup routine before AllowServiceShutdown(), to prevent
+ // service_manager killing apexd in the middle of the cleanup.
+ android::apex::BootCompletedCleanup();
android::apex::binder::AllowServiceShutdown();
android::apex::binder::JoinThreadPool();