summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiddle Hsu <riddlehsu@google.com>2020-02-22 23:20:41 +0800
committerAnis Assi <anisassi@google.com>2020-03-12 13:37:37 -0700
commitc10ac9677a4557409f6122d0dd93253363ca1a5d (patch)
tree9383fe3f77e46eee8ae2bb7311276bf37ee4d9cd
parent4404f3cfcd725dbbfdeffd7a489c853a178b49bf (diff)
downloadbase-c10ac9677a4557409f6122d0dd93253363ca1a5d.tar.gz
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): Original : Task(A1, B1, A2, B2) This Change: Task(A1, B1), Task(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 \ -m CtsServicesHostTestCases Change-Id: I97bd875146a52f62b8fe82235487ccefb2955e8e (cherry picked from commit 2be3ba49733df585bcfbf63d3b299d15dbfb0f13)
-rw-r--r--services/core/java/com/android/server/am/ActivityStarter.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java
index 7401fff433e9..2baff7c09991 100644
--- a/services/core/java/com/android/server/am/ActivityStarter.java
+++ b/services/core/java/com/android/server/am/ActivityStarter.java
@@ -948,6 +948,8 @@ class ActivityStarter {
} else {
callingPid = callingUid = -1;
}
+ boolean forceNewTask = false;
+ final int filterCallingUid = callingUid >= 0 ? callingUid : realCallingUid;
final long origId = Binder.clearCallingIdentity();
try {
synchronized (mService) {
@@ -967,6 +969,9 @@ class ActivityStarter {
// Don't modify the client's object!
intent = new Intent(intent);
+ if (forceNewTask) {
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ }
// Collect information about the target of the Intent.
ActivityInfo aInfo = mSupervisor.resolveActivity(intent, resolvedTypes[i], 0,
@@ -992,7 +997,17 @@ class ActivityStarter {
return res;
}
- resultTo = outActivity[0] != null ? outActivity[0].appToken : null;
+ final ActivityRecord started = outActivity[0];
+ if (started != null && started.getUid() == filterCallingUid) {
+ // Only the started activity which has the same uid as the source caller can
+ // be the caller of next activity.
+ resultTo = started.appToken;
+ forceNewTask = false;
+ } else {
+ // Different apps not adjacent to the caller are forced to be new task.
+ resultTo = null;
+ forceNewTask = true;
+ }
}
}
} finally {