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
This commit is contained in:
Jerry Chang
2022-12-26 18:01:19 +00:00
parent b4838aa947
commit 1d0a70b8da

View File

@@ -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(