Merge "Find activity in task with same user" into tm-qpr-dev am: fc9ccbb8a0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19741912

Change-Id: Ic9cdef99705a48d5675640a9522c6686787941f9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jeff Chang
2022-09-05 00:35:45 +00:00
committed by Automerger Merge Worker
2 changed files with 8 additions and 6 deletions

View File

@@ -2102,7 +2102,8 @@ class ActivityStarter {
// already be running somewhere in the history, and we want to shuffle it to // already be running somewhere in the history, and we want to shuffle it to
// the front of the root task if so. // the front of the root task if so.
final ActivityRecord act = final ActivityRecord act =
targetTask.findActivityInHistory(mStartActivity.mActivityComponent); targetTask.findActivityInHistory(mStartActivity.mActivityComponent,
mStartActivity.mUserId);
if (act != null) { if (act != null) {
final Task task = act.getTask(); final Task task = act.getTask();
task.moveActivityToFrontLocked(act); task.moveActivityToFrontLocked(act);

View File

@@ -1640,7 +1640,7 @@ class Task extends TaskFragment {
* or {@code null} if none was found. * or {@code null} if none was found.
*/ */
private ActivityRecord clearTopActivities(ActivityRecord newR, int launchFlags) { private ActivityRecord clearTopActivities(ActivityRecord newR, int launchFlags) {
final ActivityRecord r = findActivityInHistory(newR.mActivityComponent); final ActivityRecord r = findActivityInHistory(newR.mActivityComponent, newR.mUserId);
if (r == null) return null; if (r == null) return null;
final PooledPredicate f = PooledLambda.obtainPredicate(Task::finishActivityAbove, final PooledPredicate f = PooledLambda.obtainPredicate(Task::finishActivityAbove,
@@ -1756,17 +1756,18 @@ class Task extends TaskFragment {
* Find the activity in the history task within the given task. Returns * Find the activity in the history task within the given task. Returns
* the index within the history at which it's found, or < 0 if not found. * the index within the history at which it's found, or < 0 if not found.
*/ */
ActivityRecord findActivityInHistory(ComponentName component) { ActivityRecord findActivityInHistory(ComponentName component, int userId) {
final PooledPredicate p = PooledLambda.obtainPredicate(Task::matchesActivityInHistory, final PooledPredicate p = PooledLambda.obtainPredicate(Task::matchesActivityInHistory,
PooledLambda.__(ActivityRecord.class), component); PooledLambda.__(ActivityRecord.class), component, userId);
final ActivityRecord r = getActivity(p); final ActivityRecord r = getActivity(p);
p.recycle(); p.recycle();
return r; return r;
} }
private static boolean matchesActivityInHistory( private static boolean matchesActivityInHistory(
ActivityRecord r, ComponentName activityComponent) { ActivityRecord r, ComponentName activityComponent, int userId) {
return !r.finishing && r.mActivityComponent.equals(activityComponent); return !r.finishing && r.mActivityComponent.equals(activityComponent)
&& r.mUserId == userId;
} }
/** Updates the last task description values. */ /** Updates the last task description values. */