OSDN Git Service

Fix am start -S <package>
authorNg Zhi An <zhin@google.com>
Tue, 2 Apr 2019 16:00:22 +0000 (09:00 -0700)
committerZhi An Ng <zhin@google.com>
Wed, 3 Apr 2019 20:01:32 +0000 (20:01 +0000)
commit494d4fea1e05e14521412a0c2e72a42b0eefa483
treee903cd5259023afefb3e89908e1b362fdf22ad7b
parent29e5ea6741605fcc7699163a1cf36a3b9a042dd5
Fix am start -S <package>

Previously, am start <package> and am start -S <package> had different
behaviors because the -S code path did not convert the default user id
(by calling handleIncomingUser) into a proper userId that is uses for
querying intent activities.
The default user id is converted in other code paths, so we do not
convert it inside of makeIntent, but only in the mStopOption path, right
before queryIntentActivities.

Test: adb shell am start -S com.android.chrome
Test: adb shell run-as com.example.zhin am start
(same as P)
IllegalArgumentException: No intent supplied
Test: adb shell run-as com.example.zhin am start com.example.zhin
(same as P)
Security exception: Permission Denial: startActivityAsUser asks to run as user
-2 but is calling from uid u0a193; this requires
android.permission.INTERACT_ACROSS_USERS_FULL
Test: adb shell run-as com.example.zhin am start --user 0 com.example.zhin
(same as P)
Starting: Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] pkg=com.example.zhin }
Error: Activity not started, unable to resolve Intent {
    act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
    flg=0x10000000 pkg=com.example.zhin }
Bug: 129712542
Change-Id: I3ce6ffd40fd834bffd28b4440c1fb0024c799d95
services/core/java/com/android/server/am/ActivityManagerShellCommand.java