From d23fb21ab3888c999630b9572fc46707ba85faa5 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 16 Mar 2022 19:14:00 -0600 Subject: [PATCH] Return START_TASK_TO_FRONT for bring fullscreen task The condition was added for split screen that intends to return START_DELIVERED_TO_TOP for an activity on top of the split but not the global top. While in fullscreen mode, it is possible that a translucent task on top of another one. That should still return START_TASK_TO_FRONT when moving the bottom visible activity to top. It may affect shell transition because only START_SUCCESS or START_TASK_TO_FRONT requires transition, otherwise it will abort. Bug: 223988300 Test: atest ActivityStarterTests#testMoveVisibleTaskToFront Test: Enable shell transition. Launch a landscape translucent activity from launcher. Launch home again and no crash by "Trying to rotate outside a transition". Change-Id: I2073084d5e7318b114fa74718caf4315fb21fa83 --- .../com/android/server/wm/ActivityStarter.java | 3 ++- .../android/server/wm/ActivityStarterTests.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java index 7d2dfa0715979..77ec67f31d508 100644 --- a/services/core/java/com/android/server/wm/ActivityStarter.java +++ b/services/core/java/com/android/server/wm/ActivityStarter.java @@ -2730,10 +2730,11 @@ class ActivityStarter { false /* includingParents */); intentTask = intentTask.getParent().asTaskFragment().getTask(); } - // If the task is in multi-windowing mode, the activity may already be on + // If the activity is visible in multi-windowing mode, it may already be on // the top (visible to user but not the global top), then the result code // should be START_DELIVERED_TO_TOP instead of START_TASK_TO_FRONT. final boolean wasTopOfVisibleRootTask = intentActivity.mVisibleRequested + && intentActivity.inMultiWindowMode() && intentActivity == mTargetRootTask.topRunningActivity(); // We only want to move to the front, if we aren't going to launch on a // different root task. If we launch on a different root task, we will put the diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java index f9aa4b17bc2ca..9902e83c3648d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java @@ -500,6 +500,23 @@ public class ActivityStarterTests extends WindowTestsBase { return Pair.create(splitPrimaryActivity, splitSecondActivity); } + @Test + public void testMoveVisibleTaskToFront() { + final ActivityRecord activity = new TaskBuilder(mSupervisor) + .setCreateActivity(true).build().getTopMostActivity(); + final ActivityRecord translucentActivity = new TaskBuilder(mSupervisor) + .setCreateActivity(true).build().getTopMostActivity(); + assertTrue(activity.mVisibleRequested); + + final ActivityStarter starter = prepareStarter(FLAG_ACTIVITY_NEW_TASK, + false /* mockGetRootTask */); + starter.getIntent().setComponent(activity.mActivityComponent); + final int result = starter.setReason("testMoveVisibleTaskToFront").execute(); + + assertEquals(START_TASK_TO_FRONT, result); + assertEquals(1, activity.compareTo(translucentActivity)); + } + /** * Tests activity is cleaned up properly in a task mode violation. */