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
This commit is contained in:
Winson Chung
2024-09-12 22:35:45 +00:00
committed by randypfohl
parent dca74bcb24
commit a2dea77229
7 changed files with 34 additions and 10 deletions
@@ -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.
*/
@@ -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();
@@ -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);
@@ -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);
@@ -900,7 +900,7 @@ public class SplitSelectStateController {
SystemUiProxy.INSTANCE.get(mLauncher.getApplicationContext())
.startRecentsActivity(
mOverviewComponentObserver.getOverviewIntent(), options,
callbacks);
callbacks, false /* useSyntheticRecentsTransition */);
});
}
@@ -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 */);
});
});
}
@@ -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<ActivityOptions> 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());
}