Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion artemis/drivers/android/adb_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,10 @@ async def press_key(self, key: KeyCode | str | int) -> bool:

async def launch_app(self, package_name: str) -> bool:
try:
cmd = f"monkey -p {package_name} -c android.intent.category.LAUNCHER 1"
# --pct-syskeys 0: on devices without physical keys (emulators, head units) monkey otherwise warns
# "SYS_KEYS has no physical keys" and can spend its single event on a key instead of the launch,
# leaving the previous app in the foreground.
cmd = f"monkey --pct-syskeys 0 -p {package_name} -c android.intent.category.LAUNCHER 1"
await asyncio.to_thread(self.device.shell, cmd)
return True
except Exception as e:
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ async def test_android_driver_with_mock_adb():
await driver.press_key(KeyCode.BACK)
mock_adb_device.shell.assert_called_with("input keyevent 4")

# Launch through the LAUNCHER category without system-key events (keyless devices)
assert await driver.launch_app("com.example.themesim") is True
mock_adb_device.shell.assert_called_with(
"monkey --pct-syskeys 0 -p com.example.themesim -c android.intent.category.LAUNCHER 1"
)


@pytest.mark.asyncio
async def test_android_driver_preserves_elements_from_combined_screen_data():
Expand Down
Loading