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

Commit 1d0a70b8 authored by Jerry Chang's avatar Jerry Chang
Browse files

Fix not able to enter split screen with trampoline launch

Make sure to bring the starting activity to the front when its caller is
in the front no matter if the caller is the top most task or not.

Fix: 263330444
Test: repro steps of the bug
Change-Id: I0191876adbd8190c6bf47140467ded04f9beb006
parent b4838aa9
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -2867,9 +2867,9 @@ class ActivityStarter {

        if (differentTopTask && !mAvoidMoveToFront) {
            mStartActivity.intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
            if (mSourceRecord == null || (mSourceRootTask.getTopNonFinishingActivity() != null
                    && mSourceRootTask.getTopNonFinishingActivity().getTask()
                            == mSourceRecord.getTask())) {
            // TODO(b/264487981): Consider using BackgroundActivityStartController to determine
            //  whether to bring the launching activity to the front.
            if (mSourceRecord == null || inTopNonFinishingTask(mSourceRecord)) {
                // We really do want to push this one into the user's face, right now.
                if (mLaunchTaskBehind && mSourceRecord != null) {
                    intentActivity.setTaskToAffiliateWith(mSourceRecord.getTask());
@@ -2928,6 +2928,20 @@ class ActivityStarter {
                mRootWindowContainer.getDefaultTaskDisplayArea(), mTargetRootTask);
    }

    private boolean inTopNonFinishingTask(ActivityRecord r) {
        if (r == null || r.getTask() == null) {
            return false;
        }

        final Task rTask = r.getTask();
        final Task parent = rTask.getCreatedByOrganizerTask() != null
                ? rTask.getCreatedByOrganizerTask() : r.getRootTask();
        final ActivityRecord topNonFinishingActivity = parent != null
                ? parent.getTopNonFinishingActivity() : null;

        return topNonFinishingActivity != null && topNonFinishingActivity.getTask() == rTask;
    }

    private void resumeTargetRootTaskIfNeeded() {
        if (mDoResume) {
            final ActivityRecord next = mTargetRootTask.topRunningActivity(