frameworks/base
Revisão | a952197bd161ac0e03abc6acb5f48e4ec2a56e9d (tree) |
---|---|
Hora | 2020-03-31 05:56:09 |
Autor | Riddle Hsu <riddlehsu@goog...> |
Commiter | Anis Assi |
RESTRICT AUTOMERGE Create separated tasks for different apps from startActivities
Assume there are 2 applications A, B with different uids.
There are 4 activities A1, A2, B1, B2 with default task
affinity and launch mode.
After A1 called startActivities(B1, A2, B2):
In other words, the source caller cannot launch its activity
above the activity of other application in the same task, and
it can still launch activity of other application in its task.
Bug: 145669109
Test: run cts --test android.server.cts.StartActivityTests \
Change-Id: I97bd875146a52f62b8fe82235487ccefb2955e8e
(cherry picked from commit 973ecc619c0bb87a03481774ea9e86d2924601e4)
@@ -940,6 +940,8 @@ class ActivityStarter { | ||
940 | 940 | } else { |
941 | 941 | callingPid = callingUid = -1; |
942 | 942 | } |
943 | + boolean forceNewTask = false; | |
944 | + final int filterCallingUid = callingUid >= 0 ? callingUid : realCallingUid; | |
943 | 945 | final long origId = Binder.clearCallingIdentity(); |
944 | 946 | try { |
945 | 947 | synchronized (mService) { |
@@ -959,6 +961,9 @@ class ActivityStarter { | ||
959 | 961 | |
960 | 962 | // Don't modify the client's object! |
961 | 963 | intent = new Intent(intent); |
964 | + if (forceNewTask) { | |
965 | + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
966 | + } | |
962 | 967 | |
963 | 968 | // Collect information about the target of the Intent. |
964 | 969 | ActivityInfo aInfo = mSupervisor.resolveActivity(intent, resolvedTypes[i], 0, |
@@ -984,7 +989,17 @@ class ActivityStarter { | ||
984 | 989 | return res; |
985 | 990 | } |
986 | 991 | |
987 | - resultTo = outActivity[0] != null ? outActivity[0].appToken : null; | |
992 | + final ActivityRecord started = outActivity[0]; | |
993 | + if (started != null && started.getUid() == filterCallingUid) { | |
994 | + // Only the started activity which has the same uid as the source caller can | |
995 | + // be the caller of next activity. | |
996 | + resultTo = started.appToken; | |
997 | + forceNewTask = false; | |
998 | + } else { | |
999 | + // Different apps not adjacent to the caller are forced to be new task. | |
1000 | + resultTo = null; | |
1001 | + forceNewTask = true; | |
1002 | + } | |
988 | 1003 | } |
989 | 1004 | } |
990 | 1005 | } finally { |