Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c5c7cc2 authored by Anthony Hugh's avatar Anthony Hugh Committed by Erik Wolsheimer
Browse files

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
parent ff527305
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -1090,6 +1090,9 @@ class ActivityStarter {
                        top.getTask().setIntent(mStartActivity);
                    }
                    ActivityStack.logStartActivity(AM_NEW_INTENT, mStartActivity, top.getTask());
                    if (shouldActivityBeBroughtToFront(reusedActivity)) {
                        mStartActivity.intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
                    }
                    top.deliverNewIntentLocked(mCallingUid, mStartActivity.intent,
                            mStartActivity.launchedFromPackage);
                }
@@ -1561,6 +1564,16 @@ class ActivityStarter {
        return DEFAULT_DISPLAY;
    }

    private boolean shouldActivityBeBroughtToFront(ActivityRecord intentActivity) {
        final ActivityStack focusStack = mSupervisor.getFocusedStack();
        ActivityRecord curTop = (focusStack == null)
                ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop);
        final TaskRecord topTask = curTop != null ? curTop.getTask() : null;
        return topTask != null
                && (topTask != intentActivity.getTask() || topTask != focusStack.topTask())
                && !mAvoidMoveToFront;
    }

    /**
     * Figure out which task and activity to bring to front when we have found an existing matching
     * activity record in history. May also clear the task if needed.
@@ -1575,14 +1588,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);

        final TaskRecord topTask = curTop != null ? curTop.getTask() : null;
        if (topTask != null
                && (topTask != intentActivity.getTask() || topTask != focusStack.topTask())
                && !mAvoidMoveToFront) {
            mStartActivity.intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
        if (shouldActivityBeBroughtToFront(intentActivity)) {
            if (mSourceRecord == null || (mSourceStack.topActivity() != null &&
                    mSourceStack.topActivity().getTask() == mSourceRecord.getTask())) {
                // We really do want to push this one into the user's face, right now.