SIGN IN SIGN UP

Fix flaky android/run-emulator: wait for PackageManager before installing test APK

Summary:

The pull / android / run-emulator job intermittently fails while
installing the instrumentation test APK:

  adb: failed to install android-test-debug-androidTest.apk:
  java.lang.IllegalStateException: Cannot access system provider:
  'settings' before system providers are installed!

sys.boot_completed flips to 1 when ActivityManager is up, but
system_server may still be registering the settings provider and
PackageManager. On the CI software-emulated (swiftshader) x86_64 cold
boot the window is wide enough that the install races the framework and
aborts the script. Because run-emulator is a required check on pull,
each flake reds an otherwise-good commit and starves the viable/strict
sampled set.

Gate the install on PackageManager actually answering (cmd package list
packages) instead of only sys.boot_completed, and retry the install a
few times to absorb transient adb drops on cold boot.

Test Plan:

bash -n scripts/run_android_emulator.sh passes. Behavior validated in
CI via the android/run-emulator job.

Reviewers:

Co-authored-with Claude Code (Opus 4.8).
S
SS-JIA committed
46fdc130b5be16d23181f953362d90068bdc2f18
Parent: 4019e4c