From 7d776095439199dd217db55961dbc8a75b616075 Mon Sep 17 00:00:00 2001 From: shawnlin Date: Thu, 3 Jun 2021 15:04:46 +0800 Subject: [PATCH] Add a method in RecentsAnimationController to animate the nav bar There is no transition for app launch from recent in live tile so we have to add a method for Launcher to trigger the nav bar animation for this case. Bug: 189278432 Test: manual - launch app from recent in live tile mode Change-Id: Ia63964491449e6f634350cbc8599cdec42d76d06 --- .../view/IRecentsAnimationController.aidl | 9 +++++ .../server/wm/RecentsAnimationController.java | 38 ++++++++++++++++--- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/core/java/android/view/IRecentsAnimationController.aidl b/core/java/android/view/IRecentsAnimationController.aidl index 6a2b723f905b7..61f524f517868 100644 --- a/core/java/android/view/IRecentsAnimationController.aidl +++ b/core/java/android/view/IRecentsAnimationController.aidl @@ -154,4 +154,13 @@ interface IRecentsAnimationController { * app. */ void detachNavigationBarFromApp(boolean moveHomeToTop); + + /** + * Used for animating the navigation bar during app launch from recents in live tile mode. + * + * First fade out the navigation bar at the bottom of the display and then fade in to the app. + * + * @param duration the duration of the app launch animation + */ + void animateNavigationBarToApp(long duration); } diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java index 2b40b75eefe3c..5362771ed2862 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimationController.java +++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java @@ -156,6 +156,7 @@ public class RecentsAnimationController implements DeathRecipient { @VisibleForTesting boolean mShouldAttachNavBarToAppDuringTransition; private boolean mNavigationBarAttachedToApp; + private ActivityRecord mNavBarAttachedApp; /** * Animates the screenshot of task that used to be controlled by RecentsAnimation. @@ -392,6 +393,18 @@ public class RecentsAnimationController implements DeathRecipient { Binder.restoreCallingIdentity(token); } } + + @Override + public void animateNavigationBarToApp(long duration) { + final long token = Binder.clearCallingIdentity(); + try { + synchronized (mService.getWindowManagerLock()) { + animateNavigationBarForAppLaunch(duration); + } + } finally { + Binder.restoreCallingIdentity(token); + } + } }; /** @@ -613,7 +626,6 @@ public class RecentsAnimationController implements DeathRecipient { || mDisplayContent.getFadeRotationAnimationController() != null) { return; } - ActivityRecord topActivity = null; boolean shouldTranslateNavBar = false; final boolean isDisplayLandscape = mDisplayContent.getConfiguration().orientation == ORIENTATION_LANDSCAPE; @@ -630,12 +642,12 @@ public class RecentsAnimationController implements DeathRecipient { continue; } shouldTranslateNavBar = isSplitScreenSecondary; - topActivity = task.getTopVisibleActivity(); + mNavBarAttachedApp = task.getTopVisibleActivity(); break; } final WindowState navWindow = getNavigationBarWindow(); - if (topActivity == null || navWindow == null || navWindow.mToken == null) { + if (mNavBarAttachedApp == null || navWindow == null || navWindow.mToken == null) { return; } mNavigationBarAttachedToApp = true; @@ -643,9 +655,9 @@ public class RecentsAnimationController implements DeathRecipient { final SurfaceControl.Transaction t = navWindow.mToken.getPendingTransaction(); final SurfaceControl navSurfaceControl = navWindow.mToken.getSurfaceControl(); if (shouldTranslateNavBar) { - navWindow.setSurfaceTranslationY(-topActivity.getBounds().top); + navWindow.setSurfaceTranslationY(-mNavBarAttachedApp.getBounds().top); } - t.reparent(navSurfaceControl, topActivity.getSurfaceControl()); + t.reparent(navSurfaceControl, mNavBarAttachedApp.getSurfaceControl()); t.show(navSurfaceControl); final WindowContainer imeContainer = mDisplayContent.getImeContainer(); @@ -695,9 +707,25 @@ public class RecentsAnimationController implements DeathRecipient { } } + void animateNavigationBarForAppLaunch(long duration) { + if (!mShouldAttachNavBarToAppDuringTransition + // Skip the case where the nav bar is controlled by fade rotation. + || mDisplayContent.getFadeRotationAnimationController() != null + || mNavigationBarAttachedToApp + || mNavBarAttachedApp == null) { + return; + } + + final NavBarFadeAnimationController controller = + new NavBarFadeAnimationController(mDisplayContent); + controller.fadeOutAndInSequentially(duration, null /* fadeOutParent */, + mNavBarAttachedApp.getSurfaceControl()); + } + void addTaskToTargets(Task task, OnAnimationFinishedCallback finishedCallback) { if (mRunner != null) { mIsAddingTaskToTargets = task != null; + mNavBarAttachedApp = task == null ? null : task.getTopVisibleActivity(); // No need to send task appeared when the task target already exists, or when the // task is being managed as a multi-window mode outside of recents (e.g. bubbles). if (isAnimatingTask(task) || skipAnimation(task)) {