fix(android): reinstall and reselect the test IME helper after it disappears

Merged
LA
4d ago
+164-8

Summary

open remembers per daemon that it installed the test IME helper and never checks again, so once the helper is gone (uninstalled, -wipe-data, or an emulator snapshot from before the install), the next open leaves the real keyboard active and succeeds (#3407).

  • A remembered install now re-reads the installed version code (one cmd package list packages --show-versioncode, about 34 ms on an API 33 emulator) and reinstalls a missing or older helper. The cache still skips the APK checksums.
  • After an install, ensureAndroidImeHelper waits up to 5 s for ime list -a -s to list the service. adb install returns before the input method manager registers it, and ime enable/ime set then fail with "Unknown input method". This also hits first installs on main. A wait that runs out leaves the refusal to the existing read-back.

Closes #3407. 3 files: the two checks and tests.

Validation

Head 72ce59f: pnpm check:affected --run passed, run with AWS_REGION unset because cloud-connect-profile.test.ts reads the host's region. Reverting either change fails its new test.

Live on an Android 13 emulator (API 33, arm64, -gpu swiftshader_indirect), open com.android.settings, reading default_input_method after each open:

Test IME selected afterbase 3d48bb9head 72ce59f
reopen after adb uninstall (#3407's steps)0/1010/10
first open, helper freshly installed16/2020/20
reopen after loading a snapshot taken without the helper0/1010/10

Not run on a physical device or a remote adb provider.