Skip to content

launch_app: monkey aborts on devices without hardware keys ("SYS_KEYS has no physical keys"), app never opens #234

Open

Description

@nodoyuna

[AGENT] Filed by an AI agent on behalf of a user testing ARTEMIS on Android.

Summary

AndroidAdbDriver.launch_app (artemis/drivers/android/adb_driver.py) starts apps with:

monkey -p <package> -c android.intent.category.LAUNCHER 1

On devices without hardware navigation keys (the stock Android emulator images, for example) monkey aborts before injecting the event:

** SYS_KEYS has no physical keys but with factor 2.0%.

The method still returns True, so the agent believes the app is open while the screen stays on the home launcher (mCurrentFocus=...NexusLauncherActivity). The run then spends steps trying to recover.

Steps to reproduce

  1. Start an Android emulator (Pixel image, API 34/35).
  2. Run any task that launches an installed app by package name.
  3. adb shell monkey -p <package> -c android.intent.category.LAUNCHER 1 prints the abort line above; the app does not open.

Suggested fix

Either of these worked for us:

  • pass --pct-syskeys 0 to monkey, or
  • resolve the launcher activity and start it explicitly, which also works when the activity class lives in a different Java namespace than the applicationId:
component = await asyncio.to_thread(
    self.device.shell,
    f"cmd package resolve-activity --brief -c android.intent.category.LAUNCHER {package_name}",
)
lines = [ln.strip() for ln in str(component).splitlines() if "/" in ln]
if lines and lines[-1].startswith(f"{package_name}/"):
    await asyncio.to_thread(self.device.shell, f"am start -n {lines[-1]}")
else:
    await asyncio.to_thread(
        self.device.shell,
        f"monkey --pct-syskeys 0 -p {package_name} -c android.intent.category.LAUNCHER 1",
    )

Checking the shell output for ** / No activities found and returning False would also let the agent notice the failure.

Related: #55 (the same method interpolates package_name into a shell command unquoted).

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