Run BootCompletedCleanup() on boot complete

When both BootCompletedCleanup() and installAndActivatePackage() run
simultaneously, BootCompletedCleanup() can remove the target package
while it's being installed. (or remove DM device).

This is a regression from 5368879048d0f6750c2008c9ab47963bd15fb468,
where BootCompletedCleanup() was moved from OnBootCompleted() to
apexd_main. Before the change, BootCompletedCleanup() was called only
when markBootComplete() is invoked. But with the change,
BootCompletedCleanup() is called even when apexservice is started as a
lazy service.

While the race could be fixed in many ways, restricting
BootCompletedCleanup() to run only when "booting" might be easy one.

Bug: 260143932
Test: atest ApexTestCases
Test: atest VendorApexHostTestCases
Change-Id: I4ccafb4883c361eee5e6882809f7502a1718577c
1 file changed