From 13dbfff19eeee73133c976ef6b23298e271a1985 Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Fri, 20 May 2016 08:50:15 -0700 Subject: [PATCH] Put launch adjacent activity in a new task if the activity does exist For the launch adjacent case we only want to put the activity in an existing task if the activity already exists in the history. Bug: 28828326 Change-Id: I1a6fdd6779cb20f8c0d9b7d94635b21718f4ac1b --- .../com/android/server/am/ActivityStarter.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index ad57ae2cecb39..dc4d7b1d8a054 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -1396,11 +1396,18 @@ class ActivityStarter { final TaskRecord task = mSupervisor.anyTaskForIdLocked(mOptions.getLaunchTaskId()); intentActivity = task != null ? task.getTopActivity() : null; } else if (putIntoExistingTask) { - // See if there is a task to bring to the front. If this is a SINGLE_INSTANCE - // activity, there can be one and only one instance of it in the history, and it is - // always in its own unique task, so we do a special search. - intentActivity = mLaunchSingleInstance ? mSupervisor.findActivityLocked(mIntent, mStartActivity.info) - : mSupervisor.findTaskLocked(mStartActivity); + if (mLaunchSingleInstance) { + // There can be one and only one instance of single instance activity in the + // history, and it is always in its own unique task, so we do a special search. + intentActivity = mSupervisor.findActivityLocked(mIntent, mStartActivity.info); + } else if ((mLaunchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) != 0) { + // For the launch adjacent case we only want to put the activity in an existing + // task if the activity already exists in the history. + intentActivity = mSupervisor.findActivityLocked(mIntent, mStartActivity.info); + } else { + // Otherwise find the best task to put the activity in. + intentActivity = mSupervisor.findTaskLocked(mStartActivity); + } } return intentActivity; }