From f73d0853953198945b905695c93e562209a861c5 Mon Sep 17 00:00:00 2001 From: Anthony Hugh Date: Tue, 22 Nov 2016 15:13:35 -0800 Subject: [PATCH] DO NOT MERGE: Properly set FLAG_ACTIVITY_BROUGHT_TO_FRONT for onNewIntent() callback It looks like there was a regression where #onNewIntent() was called before the FLAG_ACTIVITY_BROUGHT_TO_FRONT flag was set. This change updates the code so we set the flag properly. BUG: 33034247 Change-Id: I61959a289dc5af14ee9d3d7bfa213191238efc88 --- .../android/server/am/ActivityStarter.java | 21 +++++++++++++------ 1 file 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 06d8e4875e0a4..d5b29c617148c 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.