fix: add MAIN/LAUNCHER flags to Android launcher activity resolver
Merged
MY
9mo ago+168+168+012345678901234567890123456789-39-39-01234567890123456789
Summary
- Add
-a android.intent.action.MAIN -c android.intent.category.LAUNCHERto theresolve-activityfallback command inresolveAndroidLaunchComponent() - The resolver was missing these intent flags, causing it to resolve the wrong activity on multi-entry apps (e.g. Microsoft Outlook)
- E2E testing uncovered a deeper issue:
am start -W -p <package>exits with code 0 even when it fails to resolve the activity, printingError: Activity not started, unable to resolve Intentto stdout. The originaltry/catchnever triggered the fallback becauserunCmddid not throw on exit code 0. AddedisAmStartError()to detect this silent failure and correctly fall through to the component-based fallback. - Add unit tests for resolver parsing, error detection, and launch command construction
Changes
Commit 1: Fix resolve-activity flags
resolveAndroidLaunchComponent() now passes -a android.intent.action.MAIN -c android.intent.category.LAUNCHER to cmd package resolve-activity, ensuring the correct launcher activity is resolved for multi-entry apps.
Commit 2: Detect am start silent failures
- Replace
try/catchwithallowFailure: true+ stdout/stderr inspection viaisAmStartError() am start -preturning exit code 0 withError: Activity not startedin stdout now correctly triggers the component-based fallback- Verified end-to-end on a physical Android device with Microsoft Outlook
Test plan
-
parseAndroidLaunchComponentcorrectly parses multi-entry resolve output -
isAmStartErrordetectsam startfailure messages in stdout -
isAmStartErrorreturns false for successful launches - Fallback
resolve-activitycommand includes-a MAIN -c LAUNCHERflags - Default launch path still uses
-p <package>(system-driven resolution) - E2E:
agent-device open "com.microsoft.office.outlook" --platform androidlaunches Outlook without--activityflag on physical device