feat: forward --launch-args to adb shell am start on Android#599
Merged
thymikee merged 2 commits intoMay 30, 2026
Merged
Conversation
b0219ec to
8933dc3
Compare
6eedf59 to
0922430
Compare
Stacked on top of the iOS-only --launch-args PR (callstackincubator#598). Removes the Android UNSUPPORTED_OPERATION guard added with the Maestro work and threads launchArgs through all five Android open paths. Per-path threading: - openAndroidPackage (-p package launch + activity-fallback) - openAndroidPackageActivity (-n component override) - openAndroidIntent (named intent action) - openAndroidDeepLink (-a VIEW -d <url>, with optional -p) - openAndroidAppBoundDeepLink (-a VIEW -d <url> -p <resolved>) `adb shell` joins its argv with spaces and feeds the result to a device shell, which re-tokenises. The other am-start arguments are well-known and never contain shell-significant characters, so they round-trip untouched. Launch arguments are user-supplied and may contain JSON, spaces, `#`, etc.; each is single-quoted unless it consists entirely of safe shell characters (the same approach long used in adb-driven tooling for the same reason). Help text on --launch-args is updated to describe the Android shape (`adb shell am start args, e.g. --es key value` for typed Intent extras) and macOS remains the only rejected platform. Tests: - src/platforms/android/__tests__/index.test.ts: five new tests cover package, activity-override, deep-link URL, app-bound URL, and JSON-with-shell-metacharacters quoting paths. - src/core/__tests__/dispatch-open.test.ts: the previous "rejects Android launch arguments" test is inverted into a forwarding test that asserts openAndroidApp receives the args. Validated end-to-end on a Pixel emulator running a debug build whose launcher activity reads an Intent extra to bootstrap test configuration: a JSON value containing `#`, `/`, `:` survived single-quoted transit through `adb shell` and arrived at the activity unchanged.
9743a04 to
5cb02a5
Compare
5cb02a5 to
5b758f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the
--launch-argsflag added in #598 to Android, removing theUNSUPPORTED_OPERATIONguard that landed with the Maestro work and forwarding launch arguments verbatim toadb shell am start.Opening this as a separate PR so the Android-specific design decisions (shell-quoting model, threading across the five Android open helpers, app-bound URL path) get their own review thread.
What this PR does
src/core/dispatch.tsdevice.platform === 'android'rejection forlaunchArgs.src/core/interactors/android.tsoptions.launchArgsintoopenAndroidApp.src/platforms/android/app-lifecycle.tslaunchArgs?: string[]toOpenAndroidAppOptions; threads the args through all five Android open helpers (openAndroidPackage,openAndroidPackageActivity,openAndroidIntent,openAndroidDeepLink,openAndroidAppBoundDeepLink); adds aquoteAndroidShellArghelper applied to launch arg values.src/utils/command-schema.ts--launch-argshelp text to describe the Android shape (--es key valuefor typed Intent extras); macOS remains the only rejected platform.Why shell-quoting
adb shelljoins its argv with spaces and sends the result as a single string to a shell on the device, which then re-tokenises before invokingam start. The well-knownam startflags (-a,-c,-n,-p,-d, etc.) and the values we generate for them never contain shell-significant characters, so they round-trip untouched. Launch arguments are user-supplied and routinely contain JSON, spaces,#,;,&, etc., which the device shell would otherwise re-interpret as comments, separators, or backgrounding operators.Helper:
Safe-ASCII args pass through unquoted (keeps
adbandam startlogs readable); anything else is single-quoted with the standard'\''escape for embedded single quotes. The same shape long used by ADB-driven tooling for the same reason.Per-path argv shapes
Tests
src/platforms/android/__tests__/index.test.ts— five new tests cover:--es,--ez):,/,#is single-quoted on the way to the devicesrc/core/__tests__/dispatch-open.test.ts— the previous "rejects Android launch arguments" test is inverted into a forwarding test that assertsopenAndroidAppreceives the args.Manual validation
Verified end-to-end on a Pixel emulator running a debug build whose launcher activity reads an Intent extra to bootstrap test configuration:
agent-device open com.example.app --platform android \ --activity com.example.app/com.example.app.bootstrap.SyncActivity \ --launch-args --es \ --launch-args EXTRA_CONFIG \ --launch-args '{"mode":"debug","path":"a/b","note":"x #y"}'The JSON value (containing
#,/,:— all shell-significant on the device side) survived single-quoted transit throughadb shell, arrived at the activity as an Intent extra, and was consumed by the app's bootstrap code unchanged.pnpm checkpasses locally on top of #598's branch.