Skip to content

input keyevent 82 fails intermittently after emulator reports boot completed #489

Description

@MohitMaliFtechiz

We are using reactivecircus/android-emulator-runner@v2 in our GitHub Actions CI workflow. Occasionally, after the emulator reports that it has successfully booted, the action executes:

/usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell input keyevent 82

This command intermittently fails with:

Emulator booted.
  /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell input keyevent 82
  java.lang.IllegalStateException: android.os.ServiceManager$ServiceNotFoundException: No service published for: input
  	at android.hardware.input.InputManager.getInstance(InputManager.java:243)
  	at com.android.commands.input.Input.injectKeyEvent(Input.java:355)
  	at com.android.commands.input.Input.access$100(Input.java:41)
  	at com.android.commands.input.Input$InputKeyEvent.sendKeyEvent(Input.java:203)
  	at com.android.commands.input.Input$InputKeyEvent.run(Input.java:190)
  	at com.android.commands.input.Input.onRun(Input.java:107)
  	at com.android.internal.os.BaseCommand.run(BaseCommand.java:60)
  	at com.android.commands.input.Input.main(Input.java:71)
  	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
  	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:399)
  Caused by: android.os.ServiceManager$ServiceNotFoundException: No service published for: input
  	at android.os.ServiceManager.getServiceOrThrow(ServiceManager.java:153)
  	at android.hardware.input.InputManager.getInstance(InputManager.java:241)

See multiple jobs failing in kiwix/kiwix-android#5015:

What is interesting is that the action has already determined that the emulator has booted:

adb shell getprop sys.boot_completed
1
Emulator booted.

Immediately afterwards, the input keyevent 82 command is executed and fails because the input service is not yet available.

The failure is intermittent. The same workflow and emulator configuration can pass successfully on another run. For example, on successful runs we see:

adb shell getprop sys.boot_completed
1
Emulator booted.
adb shell input keyevent 82
Disabling animations.
adb shell settings put global window_animation_scale 0.0
adb shell settings put global transition_animation_scale 0.0
adb shell settings put global animator_duration_scale 0.0

Our relevant configuration is: https://github.com/kiwix/kiwix-android/blob/main/.github/workflows/ci.yml

The important observation is that sys.boot_completed is 1, but the Android input service is apparently not available yet.

Could the action wait for the input service (or another appropriate framework readiness signal) before executing adb shell input keyevent 82?

Please let us know if there is a recommended workaround or if this is something that should be handled by the action.

Thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions