From 91b3f6ace48b914face7c588ee502bc2bd246a7d Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Thu, 7 Jan 2021 16:47:28 +0800 Subject: [PATCH] Fix the trampoline activity shows at the top due to app transition. Regression from c4ab2ccaaf105167c719bb1768a07f6b590a1d08. The check of mSkipAppTransitionAnimation is missing when selecting transit. Fix: 176942303 Test: atest AppTransitionTests AppTransitionControllerTest AppWindowTokenTests Change-Id: I96ff8cf07124103349516f1481dfc1a06d86cbf0 --- .../server/wm/AppTransitionController.java | 13 +++++++-- .../wm/AppTransitionControllerTest.java | 6 ++-- .../android/server/wm/AppTransitionTests.java | 28 ++++++++++++++++--- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/wm/AppTransitionController.java b/services/core/java/com/android/server/wm/AppTransitionController.java index dde527d161e0f..d562bde459253 100644 --- a/services/core/java/com/android/server/wm/AppTransitionController.java +++ b/services/core/java/com/android/server/wm/AppTransitionController.java @@ -154,7 +154,7 @@ public class AppTransitionController { ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, "**** GOOD TO GO"); // TODO(new-app-transition): Remove code using appTransition.getAppTransition() final AppTransition appTransition = mDisplayContent.mAppTransition; - mDisplayContent.mSkipAppTransitionAnimation = false; + mDisplayContent.mNoAnimationNotifyOnTransitionFinished.clear(); appTransition.removeAppTransitionTimeoutCallbacks(); @@ -188,7 +188,9 @@ public class AppTransitionController { final @TransitionOldType int transit = getTransitCompatType( mDisplayContent.mAppTransition, mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps, - mWallpaperControllerLocked.getWallpaperTarget(), getOldWallpaper()); + mWallpaperControllerLocked.getWallpaperTarget(), getOldWallpaper(), + mDisplayContent.mSkipAppTransitionAnimation); + mDisplayContent.mSkipAppTransitionAnimation = false; ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, "handleAppTransitionReady: displayId=%d appTransition={%s}" @@ -274,7 +276,8 @@ public class AppTransitionController { */ static @TransitionOldType int getTransitCompatType(AppTransition appTransition, ArraySet openingApps, ArraySet closingApps, - @Nullable WindowState wallpaperTarget, @Nullable WindowState oldWallpaper) { + @Nullable WindowState wallpaperTarget, @Nullable WindowState oldWallpaper, + boolean skipAppTransitionAnimation) { // Determine if closing and opening app token sets are wallpaper targets, in which case // special animations are needed. @@ -298,6 +301,10 @@ public class AppTransitionController { return TRANSIT_OLD_KEYGUARD_UNOCCLUDE; } + // This is not keyguard transition and one of the app has request to skip app transition. + if (skipAppTransitionAnimation) { + return WindowManager.TRANSIT_OLD_UNSET; + } final @TransitionFlags int flags = appTransition.getTransitFlags(); final @TransitionType int firstTransit = appTransition.getFirstAppTransition(); 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 6c824d6c87dce..ce5fc4021eac8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/AppTransitionControllerTest.java @@ -83,7 +83,7 @@ public class AppTransitionControllerTest extends WindowTestsBase { assertEquals(WindowManager.TRANSIT_OLD_TRANSLUCENT_ACTIVITY_OPEN, AppTransitionController.getTransitCompatType(mDisplayContent.mAppTransition, mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps, - null, null)); + null, null, false)); } @Test @@ -99,7 +99,7 @@ public class AppTransitionControllerTest extends WindowTestsBase { assertEquals(WindowManager.TRANSIT_OLD_TRANSLUCENT_ACTIVITY_CLOSE, AppTransitionController.getTransitCompatType(mDisplayContent.mAppTransition, mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps, - null, null)); + null, null, false)); } @Test @@ -117,7 +117,7 @@ public class AppTransitionControllerTest extends WindowTestsBase { assertEquals(TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE, AppTransitionController.getTransitCompatType(mDisplayContent.mAppTransition, mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps, - null, null)); + null, null, false)); } @Test diff --git a/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java index 8cc515e83342e..f1e36098d84e0 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java @@ -23,6 +23,7 @@ import static android.view.WindowManager.TRANSIT_FLAG_APP_CRASHED; import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY; import static android.view.WindowManager.TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE; import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY; +import static android.view.WindowManager.TRANSIT_OLD_UNSET; import static android.view.WindowManager.TRANSIT_OPEN; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; @@ -81,7 +82,8 @@ public class AppTransitionTests extends WindowTestsBase { assertEquals(TRANSIT_OLD_KEYGUARD_GOING_AWAY, AppTransitionController.getTransitCompatType(mDc.mAppTransition, mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps, - null /* wallpaperTarget */, null /* oldWallpaper */)); + null /* wallpaperTarget */, null /* oldWallpaper */, + false /*skipAppTransitionAnimation*/)); } @Test @@ -95,7 +97,8 @@ public class AppTransitionTests extends WindowTestsBase { assertEquals(TRANSIT_OLD_KEYGUARD_GOING_AWAY, AppTransitionController.getTransitCompatType(mDc.mAppTransition, mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps, - null /* wallpaperTarget */, null /* oldWallpaper */)); + null /* wallpaperTarget */, null /* oldWallpaper */, + false /*skipAppTransitionAnimation*/)); } @Test @@ -109,7 +112,8 @@ public class AppTransitionTests extends WindowTestsBase { assertEquals(TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE, AppTransitionController.getTransitCompatType(mDc.mAppTransition, mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps, - null /* wallpaperTarget */, null /* oldWallpaper */)); + null /* wallpaperTarget */, null /* oldWallpaper */, + false /*skipAppTransitionAnimation*/)); } @Test @@ -123,7 +127,23 @@ public class AppTransitionTests extends WindowTestsBase { assertEquals(TRANSIT_OLD_KEYGUARD_GOING_AWAY, AppTransitionController.getTransitCompatType(mDc.mAppTransition, mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps, - null /* wallpaperTarget */, null /* oldWallpaper */)); + null /* wallpaperTarget */, null /* oldWallpaper */, + false /*skipAppTransitionAnimation*/)); + } + + @Test + public void testSkipTransitionAnimation() { + final DisplayContent dc = createNewDisplay(Display.STATE_ON); + final ActivityRecord activity = createActivityRecord(dc); + + mDc.prepareAppTransition(TRANSIT_OPEN); + mDc.prepareAppTransition(TRANSIT_CLOSE); + mDc.mClosingApps.add(activity); + assertEquals(TRANSIT_OLD_UNSET, + AppTransitionController.getTransitCompatType(mDc.mAppTransition, + mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps, + null /* wallpaperTarget */, null /* oldWallpaper */, + true /*skipAppTransitionAnimation*/)); } @Test