From c32b60099a3682436c2a394be58bd3b1539eb2f3 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Fri, 4 Jun 2021 20:32:31 +0800 Subject: [PATCH] Skip close activity transition since no closing app can be visible The layer of transition animation is usually shift to animation layer, so when transition controller going to apply a activity close transition to a bottom activity, the closing animation surface will be on top of the task, then suddenly occludes the top activity. An easy fix is to skip the close activity transtion if there is no closing activity can be visible. Bug: 186860966 Test: atest AppTransitionTests AppTransitionControllerTest Change-Id: I3869530fc1eaa87ed1403fed86ff68a1e4de5b23 --- .../server/wm/AppTransitionController.java | 8 +++++++- .../server/wm/AppTransitionControllerTest.java | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/AppTransitionController.java b/services/core/java/com/android/server/wm/AppTransitionController.java index e7c51a4ac65ad..50ad5fa8a1ad1 100644 --- a/services/core/java/com/android/server/wm/AppTransitionController.java +++ b/services/core/java/com/android/server/wm/AppTransitionController.java @@ -412,7 +412,13 @@ public class AppTransitionController { return TRANSIT_OLD_TASK_CLOSE; } if (isActivityClosing) { - return TRANSIT_OLD_ACTIVITY_CLOSE; + for (int i = closingApps.size() - 1; i >= 0; i--) { + if (closingApps.valueAt(i).visibleIgnoringKeyguard) { + return TRANSIT_OLD_ACTIVITY_CLOSE; + } + } + // Skip close activity transition since no closing app can be visible + return WindowManager.TRANSIT_OLD_UNSET; } } if (appTransition.containsTransitRequest(TRANSIT_RELAUNCH) diff --git a/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java index 57cf865268efa..c555612fef23b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java @@ -77,6 +77,24 @@ public class AppTransitionControllerTest extends WindowTestsBase { return r; } + @Test + public void testSkipOccludedActivityCloseTransition() { + final ActivityRecord behind = createActivityRecord(mDisplayContent, + WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); + final ActivityRecord topOpening = createActivityRecord(behind.getTask()); + topOpening.setOccludesParent(true); + topOpening.setVisible(true); + + mDisplayContent.prepareAppTransition(TRANSIT_OPEN); + mDisplayContent.prepareAppTransition(TRANSIT_CLOSE); + mDisplayContent.mClosingApps.add(behind); + + assertEquals(WindowManager.TRANSIT_OLD_UNSET, + AppTransitionController.getTransitCompatType(mDisplayContent.mAppTransition, + mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps, + null, null, false)); + } + @Test @FlakyTest(bugId = 131005232) public void testTranslucentOpen() {