Microdroid: wait for apexd.status=ready instead of activated in init.rc
This fixes a race condition. See
I8a5ebfcb82569eb098391c7860e6a6afd31d3650 for a similer fix in
minidroid.
Bug: 271275085
Test: manually, by running the microdroid sample on a VM in cuttlefish
Test: 1. as it is
Test: 2. by locally adding two times 5 seconds sleeps
(`wait /only-wait 5`) before wait_for_prop apexd.status ready to
trigger the deadlock.
Change-Id: Ia3250f098f1d87700351d3c179e31471167e90ed
diff --git a/microdroid/init.rc b/microdroid/init.rc
index 5187a12..c997bfd 100644
--- a/microdroid/init.rc
+++ b/microdroid/init.rc
@@ -35,7 +35,10 @@
restorecon /mnt/extra-apk
# Wait for apexd to finish activating APEXes before starting more processes.
- wait_for_prop apexd.status activated
+ # Microdroid starts apexd in VM mode in which apexd doesn't wait for init after setting
+ # apexd.status to activated, but immediately transitions to ready. Therefore, it's not safe to
+ # wait for the activated status, by the time this line is reached it may be already be ready.
+ wait_for_prop apexd.status ready
perform_apex_config
# Notify to microdroid_manager that perform_apex_config is done.