From fdf406d2f5462c4f2629e73cc14fff48c611b164 Mon Sep 17 00:00:00 2001 From: Nevan Wichers Date: Wed, 11 Dec 2024 21:03:34 -0800 Subject: [PATCH] Allow the agent to launch an app by package name. PiperOrigin-RevId: 705351651 --- android_world/env/adb_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android_world/env/adb_utils.py b/android_world/env/adb_utils.py index 29afc82..70b163f 100644 --- a/android_world/env/adb_utils.py +++ b/android_world/env/adb_utils.py @@ -635,8 +635,12 @@ def launch_app( activity = get_adb_activity(app_name) if activity is None: - logging.error('Failed to launch app: %r', app_name) - return None + # If the app name is not in the mapping, assume it is a package name. + response = issue_generic_request( + ['shell', 'monkey', '-p', app_name, '1'], env, timeout_sec=5 + ) + logging.info('Launching app by package name, response: %r', response) + return app_name start_activity(activity, extra_args=[], env=env, timeout_sec=5) return app_name