Repository navigation
Description
Problem
On an Android emulator, close --shutdown leaves the agent-device test IME as the default input method. After the emulator restarts, default_input_method is still com.callstack.agentdevice.imehelper/.TestInputMethodService, and nothing reports it. That IME draws no keyboard, so a focused text field no longer opens a keyboard for whoever uses the emulator next.
~/.agent-device/android-test-ime-pending/ is empty after the restart, so the daemon treats the keyboard as restored.
Environment
- agent-device 0.21.23 (first seen on 0.21.18)
- Linux 7.0, Node 24.20.0
- Android emulator 36.5.11.0, adb 1.0.41 (platform-tools 37.0.0)
system-images;android-32;google_apis;x86_64(0.21.18 and 0.21.23),system-images;android-37.0;google_apis_playstore_ps16k;x86_64(0.21.18)- Emulator started with
emulator -avd <avd> -no-snapshot-load -no-boot-anim
Reproduction
Before each run, the real keyboard is set with adb shell ime set com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME.
npx agent-device open com.android.settings --platform android --relaunch
npx agent-device snapshot
npx agent-device close --shutdown # exit code 0, "Closed: default", the emulator shuts down
# restart the AVD, then:
adb shell settings get secure default_input_method| Run | Before open |
During the session | Stop | After restart |
|---|---|---|---|---|
| 1 to 3 (API 32, 0.21.23) | LatinIME |
TestInputMethodService |
close --shutdown |
TestInputMethodService |
| control (API 32, 0.21.23) | LatinIME |
TestInputMethodService |
close, wait 3 s, adb emu kill |
LatinIME |
Earlier measurements on 0.21.18, API 32 and 37, with an app opened through a deep link with --relaunch --foreground:
close --shutdown:TestInputMethodServiceafter restart, 3 runs out of 3.close, thenadb emu killright away:TestInputMethodServiceafter restart, 2 out of 2.close, then 3 to 7 s, thenadb emu kill:LatinIMEafter restart, 3 out of 3.
In the control run, default_input_method already reads LatinIME right after close, while the emulator is still running. The restore does happen, but an immediate emu kill loses it.
Code path
In packages/platform-android/src/lifecycle.ts, finalizeApplicationClose awaits host.androidApplications.restoreTestIme(...), then, when shutdownTarget is set on an emulator, calls host.deviceShutdown.android.shutdownTarget(...). packages/platform-android/src/shutdown/runtime.ts then runs adb -s <serial> emu kill right away. The published dist/src/runtime2.js has the same sequence in 0.21.18 and 0.21.23. I have not measured why the restored setting does not survive the kill.
Expected behavior
After close --shutdown, the emulator restarts with the keyboard that was the default before open.
Activity
fix(android): carry an aborted flush settle into the next close
fix(android): let a mid-wait restore extend the pending kill's flush …
fix(android): keep close --shutdown's IME restore out of the settings…