From a2dea77229c127fca30bc66ca825fbbf7904722f Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 12 Sep 2024 22:35:45 +0000 Subject: [PATCH] Using synthetic recents transitions for Recents in Window Bug: 366021931 Flag: com.android.launcher3.enable_fallback_overview_in_window Test: manual with enableFallbackOverviewInWindow=true Change-Id: I26fbc96373b55f0a4a87756fa99347f0e4f4361b --- quickstep/src/com/android/quickstep/GestureState.java | 11 +++++++++++ .../android/quickstep/RecentsAnimationCallbacks.java | 9 ++++++++- .../src/com/android/quickstep/SystemUiProxy.java | 5 ++++- .../com/android/quickstep/TaskAnimationManager.java | 9 +++++---- .../quickstep/util/SplitSelectStateController.java | 2 +- .../util/SplitWithKeyboardShortcutController.java | 3 ++- .../android/quickstep/TaskAnimationManagerTest.java | 5 +++-- 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index 2892d2c913..015a449cc4 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -36,6 +36,7 @@ import android.view.RemoteAnimationTarget; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.android.launcher3.Flags; import com.android.launcher3.statemanager.BaseState; import com.android.launcher3.statemanager.StatefulContainer; import com.android.quickstep.TopTaskTracker.CachedTaskInfo; @@ -301,6 +302,16 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL return mTrackpadGestureType == TrackpadGestureType.FOUR_FINGER; } + /** + * Requests that handling for this gesture should use a synthetic transition, as in that it + * will need to start a recents transition that is not backed by a system transition. This is + * generally only needed in scenarios where a system transition can not be created due to no + * changes in the WM hierarchy (ie. starting recents transition when you are already over home). + */ + public boolean useSyntheticRecentsTransition() { + return mRunningTask.isHomeTask() && Flags.enableFallbackOverviewInWindow(); + } + /** * @return the running task for this gesture. */ diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java index fc11812f0e..7d5bd377d0 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java @@ -15,7 +15,9 @@ */ package com.android.quickstep; +import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.view.RemoteAnimationTarget.MODE_CLOSING; +import static android.view.RemoteAnimationTarget.MODE_OPENING; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; @@ -29,6 +31,7 @@ import androidx.annotation.BinderThread; import androidx.annotation.NonNull; import androidx.annotation.UiThread; +import com.android.launcher3.Flags; import com.android.launcher3.Utilities; import com.android.launcher3.util.Preconditions; import com.android.quickstep.util.ActiveGestureProtoLogProxy; @@ -102,7 +105,11 @@ public class RecentsAnimationCallbacks implements long appCount = Arrays.stream(appTargets) .filter(app -> app.mode == MODE_CLOSING) .count(); - if (appCount == 0) { + + boolean isOpeningHome = Arrays.stream(appTargets).filter(app -> app.mode == MODE_OPENING + && app.windowConfiguration.getActivityType() == ACTIVITY_TYPE_HOME) + .count() > 0; + if (appCount == 0 && (!Flags.enableFallbackOverviewInWindow() || isOpeningHome)) { ActiveGestureProtoLogProxy.logOnRecentsAnimationStartCancelled(); // Edge case, if there are no closing app targets, then Launcher has nothing to handle notifyAnimationCanceled(); diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index c66813fe8b..14b4d60ca7 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -1535,7 +1535,7 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { * Starts the recents activity. The caller should manage the thread on which this is called. */ public boolean startRecentsActivity(Intent intent, ActivityOptions options, - RecentsAnimationListener listener) { + RecentsAnimationListener listener, boolean useSyntheticRecentsTransition) { if (mRecentTasks == null) { ActiveGestureProtoLogProxy.logRecentTasksMissing(); return false; @@ -1566,6 +1566,9 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { } }; final Bundle optsBundle = options.toBundle(); + if (useSyntheticRecentsTransition) { + optsBundle.putBoolean("is_synthetic_recents_transition", true); + } try { mRecentTasks.startRecentsTransition(mRecentsPendingIntent, intent, optsBundle, mContext.getIApplicationThread(), runner); diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index bda292af01..56c978a318 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -296,8 +296,8 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn // TODO:(b/365777482) if flag is enabled, but on launcher it will crash. if(containerInterface.getCreatedContainer() instanceof RecentsWindowManager && Flags.enableFallbackOverviewInWindow()){ - mRecentsAnimationStartPending = - getSystemUiProxy().startRecentsActivity(intent, options, mCallbacks); + mRecentsAnimationStartPending = getSystemUiProxy().startRecentsActivity(intent, options, + mCallbacks, gestureState.useSyntheticRecentsTransition()); mRecentsWindowsManager.startRecentsWindow(mCallbacks); } else { options.setPendingIntentBackgroundActivityStartMode( @@ -326,9 +326,10 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn }); } - mRecentsAnimationStartPending = getSystemUiProxy() - .startRecentsActivity(intent, options, mCallbacks); + mRecentsAnimationStartPending = getSystemUiProxy().startRecentsActivity(intent, + options, mCallbacks, false /* useSyntheticRecentsTransition */); } + if (enableHandleDelayedGestureCallbacks()) { ActiveGestureProtoLogProxy.logSettingRecentsAnimationStartPending( mRecentsAnimationStartPending); diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index 511c989928..ea582c493f 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -900,7 +900,7 @@ public class SplitSelectStateController { SystemUiProxy.INSTANCE.get(mLauncher.getApplicationContext()) .startRecentsActivity( mOverviewComponentObserver.getOverviewIntent(), options, - callbacks); + callbacks, false /* useSyntheticRecentsTransition */); }); } diff --git a/quickstep/src/com/android/quickstep/util/SplitWithKeyboardShortcutController.java b/quickstep/src/com/android/quickstep/util/SplitWithKeyboardShortcutController.java index 4c6e4ff359..744c08cc3c 100644 --- a/quickstep/src/com/android/quickstep/util/SplitWithKeyboardShortcutController.java +++ b/quickstep/src/com/android/quickstep/util/SplitWithKeyboardShortcutController.java @@ -99,7 +99,8 @@ public class SplitWithKeyboardShortcutController { options.setTransientLaunch(); SystemUiProxy.INSTANCE.get(mLauncher.getApplicationContext()) .startRecentsActivity(mOverviewComponentObserver.getOverviewIntent(), - ActivityOptions.makeBasic(), callbacks); + ActivityOptions.makeBasic(), callbacks, + false /* useSyntheticRecentsTransition */); }); }); } diff --git a/quickstep/tests/src/com/android/quickstep/TaskAnimationManagerTest.java b/quickstep/tests/src/com/android/quickstep/TaskAnimationManagerTest.java index ec07b9310e..633a5756c2 100644 --- a/quickstep/tests/src/com/android/quickstep/TaskAnimationManagerTest.java +++ b/quickstep/tests/src/com/android/quickstep/TaskAnimationManagerTest.java @@ -17,8 +17,8 @@ package com.android.quickstep; import static org.junit.Assert.assertEquals; -import static org.junit.Assume.assumeTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -73,7 +73,8 @@ public class TaskAnimationManagerTest { final ArgumentCaptor optionsCaptor = ArgumentCaptor.forClass(ActivityOptions.class); - verify(mSystemUiProxy).startRecentsActivity(any(), optionsCaptor.capture(), any()); + verify(mSystemUiProxy) + .startRecentsActivity(any(), optionsCaptor.capture(), any(), anyBoolean()); assertEquals(ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS, optionsCaptor.getValue().getPendingIntentBackgroundActivityStartMode()); }