diff options
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityStarter.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index 06d8e4875e0a..d5b29c617148 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -1077,6 +1077,10 @@ class ActivityStarter { top.task.setIntent(mStartActivity); } ActivityStack.logStartActivity(AM_NEW_INTENT, mStartActivity, top.task); + + if (shouldActivityBeBroughtToFront(mReusedActivity)) { + mStartActivity.intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); + } top.deliverNewIntentLocked(mCallingUid, mStartActivity.intent, mStartActivity.launchedFromPackage); } @@ -1509,6 +1513,16 @@ class ActivityStarter { return intentActivity; } + private boolean shouldActivityBeBroughtToFront(ActivityRecord intentActivity) { + final ActivityStack focusStack = mSupervisor.getFocusedStack(); + ActivityRecord curTop = (focusStack == null) + ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop); + + return curTop != null + && (curTop.task != intentActivity.task || curTop.task != focusStack.topTask()) + && !mAvoidMoveToFront; + } + private ActivityRecord setTargetStackAndMoveToFrontIfNeeded(ActivityRecord intentActivity) { mTargetStack = intentActivity.task.stack; mTargetStack.mLastPausedActivity = null; @@ -1517,13 +1531,8 @@ class ActivityStarter { // the same behavior as if a new instance was being started, which means not bringing it // to the front if the caller is not itself in the front. final ActivityStack focusStack = mSupervisor.getFocusedStack(); - ActivityRecord curTop = (focusStack == null) - ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop); - if (curTop != null - && (curTop.task != intentActivity.task || curTop.task != focusStack.topTask()) - && !mAvoidMoveToFront) { - mStartActivity.intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); + if (shouldActivityBeBroughtToFront(intentActivity)) { if (mSourceRecord == null || (mSourceStack.topActivity() != null && mSourceStack.topActivity().task == mSourceRecord.task)) { // We really do want to push this one into the user's face, right now. |