Merge "RESTRICT AUTOMERGE Create separated tasks for different apps from startActivities" into pi-dev

This commit is contained in:
TreeHugger Robot
2020-03-10 15:44:57 +00:00
committed by Android (Google) Code Review

View File

@@ -334,6 +334,9 @@ public class ActivityStartController {
} else { } else {
callingPid = callingUid = -1; callingPid = callingUid = -1;
} }
boolean forceNewTask = false;
final int filterCallingUid = ActivityStarter.computeResolveFilterUid(
callingUid, realCallingUid, UserHandle.USER_NULL);
final long origId = Binder.clearCallingIdentity(); final long origId = Binder.clearCallingIdentity();
try { try {
synchronized (mService) { synchronized (mService) {
@@ -353,11 +356,13 @@ public class ActivityStartController {
// Don't modify the client's object! // Don't modify the client's object!
intent = new Intent(intent); intent = new Intent(intent);
if (forceNewTask) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
// Collect information about the target of the Intent. // Collect information about the target of the Intent.
ActivityInfo aInfo = mSupervisor.resolveActivity(intent, resolvedTypes[i], 0, ActivityInfo aInfo = mSupervisor.resolveActivity(intent, resolvedTypes[i], 0,
null, userId, ActivityStarter.computeResolveFilterUid( null, userId, filterCallingUid);
callingUid, realCallingUid, UserHandle.USER_NULL));
// TODO: New, check if this is correct // TODO: New, check if this is correct
aInfo = mService.getActivityInfoForUser(aInfo, userId); aInfo = mService.getActivityInfoForUser(aInfo, userId);
@@ -397,7 +402,17 @@ public class ActivityStartController {
return res; 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 { } finally {