Loading services/core/java/com/android/server/am/ActivityStack.java +18 −10 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static com.android.server.am.ActivityManagerService.LOCK_SCREEN_SHOWN; import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE; import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE; import static com.android.server.am.ActivityStackSupervisor.FindTaskResult; import static com.android.server.am.ActivityStackSupervisor.MOVING; import static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS; Loading Loading @@ -569,10 +570,10 @@ final class ActivityStack { } /** * Returns the top activity in any existing task matching the given * Intent. Returns null if no such task is found. * Returns the top activity in any existing task matching the given Intent in the input result. * Returns null if no such task is found. */ ActivityRecord findTaskLocked(ActivityRecord target) { void findTaskLocked(ActivityRecord target, FindTaskResult result) { Intent intent = target.intent; ActivityInfo info = target.info; ComponentName cls = intent.getComponent(); Loading Loading @@ -627,10 +628,15 @@ final class ActivityStack { + taskIntent.getComponent().flattenToShortString() + "/aff=" + r.task.rootAffinity + " to new cls=" + intent.getComponent().flattenToShortString() + "/aff=" + info.taskAffinity); if (!isDocument && !taskIsDocument && task.rootAffinity != null) { if (!isDocument && !taskIsDocument && result.r == null && task.canMatchRootAffinity()) { if (task.rootAffinity.equals(target.taskAffinity)) { if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Found matching affinity!"); return r; if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Found matching affinity candidate!"); // It is possible for multiple tasks to have the same root affinity especially // if they are in separate stacks. We save off this candidate, but keep looking // to see if there is a better candidate. result.r = r; result.matchedByRootAffinity = true; } } else if (taskIntent != null && taskIntent.getComponent() != null && taskIntent.getComponent().compareTo(cls) == 0 && Loading @@ -639,7 +645,9 @@ final class ActivityStack { //dump(); if (DEBUG_TASKS) Slog.d(TAG_TASKS, "For Intent " + intent + " bringing to top: " + r.intent); return r; result.r = r; result.matchedByRootAffinity = false; break; } else if (affinityIntent != null && affinityIntent.getComponent() != null && affinityIntent.getComponent().compareTo(cls) == 0 && Objects.equals(documentData, taskDocumentData)) { Loading @@ -647,11 +655,11 @@ final class ActivityStack { //dump(); if (DEBUG_TASKS) Slog.d(TAG_TASKS, "For Intent " + intent + " bringing to top: " + r.intent); return r; result.r = r; result.matchedByRootAffinity = false; break; } else if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Not a match: " + task); } return null; } /** Loading services/core/java/com/android/server/am/ActivityStackSupervisor.java +18 −6 Original line number Diff line number Diff line Loading @@ -418,6 +418,12 @@ public final class ActivityStackSupervisor implements DisplayListener { private final ActivityMetricsLogger mActivityMetricsLogger; static class FindTaskResult { ActivityRecord r; boolean matchedByRootAffinity; } private final FindTaskResult mTmpFindTaskResult = new FindTaskResult(); /** * Description of a request to start a new activity, which has been held * due to app switches being disabled. Loading Loading @@ -3641,7 +3647,7 @@ public final class ActivityStackSupervisor implements DisplayListener { } if (bounds != null) { resizeStackLocked(PINNED_STACK_ID, bounds, !PRESERVE_WINDOWS, true); resizeStackLocked(stackId, bounds, !PRESERVE_WINDOWS, true); } // The task might have already been running and its visibility needs to be synchronized with Loading Loading @@ -3670,6 +3676,8 @@ public final class ActivityStackSupervisor implements DisplayListener { } ActivityRecord findTaskLocked(ActivityRecord r) { mTmpFindTaskResult.r = null; mTmpFindTaskResult.matchedByRootAffinity = false; if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Looking for task of " + r); for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) { final ArrayList<ActivityStack> stacks = mActivityDisplays.valueAt(displayNdx).mStacks; Loading @@ -3684,14 +3692,18 @@ public final class ActivityStackSupervisor implements DisplayListener { "Skipping stack: (new task not allowed) " + stack); continue; } final ActivityRecord ar = stack.findTaskLocked(r); if (ar != null) { return ar; stack.findTaskLocked(r, mTmpFindTaskResult); // It is possible to have task in multiple stacks with the same root affinity. // If the match we found was based on root affinity we keep on looking to see if // there is a better match in another stack. We eventually return the match based // on root affinity if we don't find a better match. if (mTmpFindTaskResult.r != null && !mTmpFindTaskResult.matchedByRootAffinity) { return mTmpFindTaskResult.r; } } } if (DEBUG_TASKS) Slog.d(TAG_TASKS, "No task found"); return null; if (DEBUG_TASKS && mTmpFindTaskResult.r == null) Slog.d(TAG_TASKS, "No task found"); return mTmpFindTaskResult.r; } ActivityRecord findActivityLocked(Intent intent, ActivityInfo info) { Loading services/core/java/com/android/server/am/TaskRecord.java +6 −0 Original line number Diff line number Diff line Loading @@ -1394,6 +1394,12 @@ final class TaskRecord { return mLastNonFullscreenBounds; } boolean canMatchRootAffinity() { // We don't allow root affinity matching on the pinned stack as no other task should // be launching in it based on affinity. return rootAffinity != null && (stack == null || stack.mStackId != PINNED_STACK_ID); } void dump(PrintWriter pw, String prefix) { pw.print(prefix); pw.print("userId="); pw.print(userId); pw.print(" effectiveUid="); UserHandle.formatUid(pw, effectiveUid); Loading Loading
services/core/java/com/android/server/am/ActivityStack.java +18 −10 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static com.android.server.am.ActivityManagerService.LOCK_SCREEN_SHOWN; import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE; import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE; import static com.android.server.am.ActivityStackSupervisor.FindTaskResult; import static com.android.server.am.ActivityStackSupervisor.MOVING; import static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS; Loading Loading @@ -569,10 +570,10 @@ final class ActivityStack { } /** * Returns the top activity in any existing task matching the given * Intent. Returns null if no such task is found. * Returns the top activity in any existing task matching the given Intent in the input result. * Returns null if no such task is found. */ ActivityRecord findTaskLocked(ActivityRecord target) { void findTaskLocked(ActivityRecord target, FindTaskResult result) { Intent intent = target.intent; ActivityInfo info = target.info; ComponentName cls = intent.getComponent(); Loading Loading @@ -627,10 +628,15 @@ final class ActivityStack { + taskIntent.getComponent().flattenToShortString() + "/aff=" + r.task.rootAffinity + " to new cls=" + intent.getComponent().flattenToShortString() + "/aff=" + info.taskAffinity); if (!isDocument && !taskIsDocument && task.rootAffinity != null) { if (!isDocument && !taskIsDocument && result.r == null && task.canMatchRootAffinity()) { if (task.rootAffinity.equals(target.taskAffinity)) { if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Found matching affinity!"); return r; if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Found matching affinity candidate!"); // It is possible for multiple tasks to have the same root affinity especially // if they are in separate stacks. We save off this candidate, but keep looking // to see if there is a better candidate. result.r = r; result.matchedByRootAffinity = true; } } else if (taskIntent != null && taskIntent.getComponent() != null && taskIntent.getComponent().compareTo(cls) == 0 && Loading @@ -639,7 +645,9 @@ final class ActivityStack { //dump(); if (DEBUG_TASKS) Slog.d(TAG_TASKS, "For Intent " + intent + " bringing to top: " + r.intent); return r; result.r = r; result.matchedByRootAffinity = false; break; } else if (affinityIntent != null && affinityIntent.getComponent() != null && affinityIntent.getComponent().compareTo(cls) == 0 && Objects.equals(documentData, taskDocumentData)) { Loading @@ -647,11 +655,11 @@ final class ActivityStack { //dump(); if (DEBUG_TASKS) Slog.d(TAG_TASKS, "For Intent " + intent + " bringing to top: " + r.intent); return r; result.r = r; result.matchedByRootAffinity = false; break; } else if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Not a match: " + task); } return null; } /** Loading
services/core/java/com/android/server/am/ActivityStackSupervisor.java +18 −6 Original line number Diff line number Diff line Loading @@ -418,6 +418,12 @@ public final class ActivityStackSupervisor implements DisplayListener { private final ActivityMetricsLogger mActivityMetricsLogger; static class FindTaskResult { ActivityRecord r; boolean matchedByRootAffinity; } private final FindTaskResult mTmpFindTaskResult = new FindTaskResult(); /** * Description of a request to start a new activity, which has been held * due to app switches being disabled. Loading Loading @@ -3641,7 +3647,7 @@ public final class ActivityStackSupervisor implements DisplayListener { } if (bounds != null) { resizeStackLocked(PINNED_STACK_ID, bounds, !PRESERVE_WINDOWS, true); resizeStackLocked(stackId, bounds, !PRESERVE_WINDOWS, true); } // The task might have already been running and its visibility needs to be synchronized with Loading Loading @@ -3670,6 +3676,8 @@ public final class ActivityStackSupervisor implements DisplayListener { } ActivityRecord findTaskLocked(ActivityRecord r) { mTmpFindTaskResult.r = null; mTmpFindTaskResult.matchedByRootAffinity = false; if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Looking for task of " + r); for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) { final ArrayList<ActivityStack> stacks = mActivityDisplays.valueAt(displayNdx).mStacks; Loading @@ -3684,14 +3692,18 @@ public final class ActivityStackSupervisor implements DisplayListener { "Skipping stack: (new task not allowed) " + stack); continue; } final ActivityRecord ar = stack.findTaskLocked(r); if (ar != null) { return ar; stack.findTaskLocked(r, mTmpFindTaskResult); // It is possible to have task in multiple stacks with the same root affinity. // If the match we found was based on root affinity we keep on looking to see if // there is a better match in another stack. We eventually return the match based // on root affinity if we don't find a better match. if (mTmpFindTaskResult.r != null && !mTmpFindTaskResult.matchedByRootAffinity) { return mTmpFindTaskResult.r; } } } if (DEBUG_TASKS) Slog.d(TAG_TASKS, "No task found"); return null; if (DEBUG_TASKS && mTmpFindTaskResult.r == null) Slog.d(TAG_TASKS, "No task found"); return mTmpFindTaskResult.r; } ActivityRecord findActivityLocked(Intent intent, ActivityInfo info) { Loading
services/core/java/com/android/server/am/TaskRecord.java +6 −0 Original line number Diff line number Diff line Loading @@ -1394,6 +1394,12 @@ final class TaskRecord { return mLastNonFullscreenBounds; } boolean canMatchRootAffinity() { // We don't allow root affinity matching on the pinned stack as no other task should // be launching in it based on affinity. return rootAffinity != null && (stack == null || stack.mStackId != PINNED_STACK_ID); } void dump(PrintWriter pw, String prefix) { pw.print(prefix); pw.print("userId="); pw.print(userId); pw.print(" effectiveUid="); UserHandle.formatUid(pw, effectiveUid); Loading