Merge "Fix FallbackRecentsTest with recents in window enabled" into main

This commit is contained in:
Treehugger Robot
2025-05-12 11:09:45 -07:00
committed by Android (Google) Code Review
11 changed files with 92 additions and 20 deletions
@@ -15,6 +15,7 @@
*/
package com.android.quickstep;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
@@ -24,7 +25,6 @@ import static android.view.MotionEvent.ACTION_POINTER_UP;
import static android.view.MotionEvent.ACTION_UP;
import static com.android.launcher3.Flags.enableCursorHoverStates;
import static com.android.quickstep.fallback.window.RecentsWindowFlags.enableOverviewOnConnectedDisplays;
import static com.android.launcher3.LauncherPrefs.backedUpItem;
import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent;
import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe;
@@ -39,8 +39,10 @@ import static com.android.quickstep.InputConsumer.TYPE_CURSOR_HOVER;
import static com.android.quickstep.InputConsumer.createNoOpInputConsumer;
import static com.android.quickstep.InputConsumerUtils.newConsumer;
import static com.android.quickstep.InputConsumerUtils.tryCreateAssistantInputConsumer;
import static com.android.quickstep.fallback.window.RecentsWindowFlags.enableOverviewOnConnectedDisplays;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
import android.app.ActivityManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
@@ -98,6 +100,7 @@ import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.OverviewCommandHelper.CommandType;
import com.android.quickstep.OverviewComponentObserver.OverviewChangeListener;
import com.android.quickstep.actioncorner.ActionCornerHandler;
import com.android.quickstep.fallback.RecentsState;
import com.android.quickstep.fallback.window.RecentsWindowFlags;
import com.android.quickstep.fallback.window.RecentsWindowManager;
import com.android.quickstep.fallback.window.RecentsWindowSwipeHandler;
@@ -120,6 +123,8 @@ import com.android.systemui.shared.system.InputChannelCompat.InputEventReceiver;
import com.android.systemui.shared.system.InputConsumerController;
import com.android.systemui.shared.system.InputMonitorCompat;
import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.systemui.shared.system.smartspace.ISysuiUnlockAnimationController;
import com.android.systemui.unfold.progress.IUnfoldAnimation;
import com.android.wm.shell.back.IBackAnimation;
@@ -610,6 +615,50 @@ public class TouchInteractionService extends Service {
}
};
// We should clean up the recents window on the primary display on home intent start, however we
// have no other way of listening to this event in the 3P launcher case.
private final TaskStackChangeListener mHomeIntentStartedListener =
new TaskStackChangeListener() {
@Override
public void onActivityRestartAttempt(ActivityManager.RunningTaskInfo task,
boolean homeTaskVisible, boolean clearedTask, boolean wasVisible) {
TaskStackChangeListener.super.onActivityRestartAttempt(task, homeTaskVisible,
clearedTask, wasVisible);
if (task.configuration.windowConfiguration.getActivityType()
!= ACTIVITY_TYPE_HOME
|| task.displayId != DEFAULT_DISPLAY) {
// We only want to handle home intent starts, and only on the primary
// display.
return;
}
if (mGestureState != DEFAULT_STATE) {
// If there's an ongoing gesture, we shouldn't clean up the recents window
// since gestures will clean up the recents window when needed.
return;
}
RecentsWindowManager recentsWindowManager =
mRecentsWindowManagerRepository.get(DEFAULT_DISPLAY);
TaskAnimationManager taskAnimationManager =
mTaskAnimationManagerRepository.get(DEFAULT_DISPLAY);
if (recentsWindowManager == null || taskAnimationManager == null) {
return;
}
if (taskAnimationManager.isRecentsAnimationRunning()) {
RecentsState recentsState =
recentsWindowManager.getStateManager().getState();
if (!recentsState.isRecentsViewVisible()) {
// If we're in a state where the recents view is visible, we can ignore
// the recents animation running check, otherwise we should wait for
// the recents animation to end.
return;
}
}
if (recentsWindowManager.isStarted()) {
recentsWindowManager.getStateManager().goToState(RecentsState.HOME, true);
}
}
};
private OverviewCommandHelper mOverviewCommandHelper;
private OverviewComponentObserver mOverviewComponentObserver;
private InputConsumerController mInputConsumer;
@@ -824,6 +873,17 @@ public class TouchInteractionService extends Service {
mTaskbarManager.setRecentsViewContainer(newOverviewContainer);
}
}
if (RecentsWindowFlags.getEnableOverviewInWindow()) {
mRecentsWindowManagerRepository.forEach(
/* createIfAbsent= */ false, RecentsWindowManager::cleanupRecentsWindow);
if (isHomeAndOverviewSame) {
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(
mHomeIntentStartedListener);
} else {
TaskStackChangeListeners.getInstance().registerTaskStackListener(
mHomeIntentStartedListener);
}
}
}
@UiThread
@@ -881,6 +941,10 @@ public class TouchInteractionService extends Service {
mDisplayInfoChangeListener);
LockedUserState.get(this).removeOnUserUnlockedRunnable(mUserUnlockedRunnable);
ScreenOnTracker.INSTANCE.get(this).removeListener(mScreenOnListener);
if (RecentsWindowFlags.getEnableOverviewInWindow()) {
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(
mHomeIntentStartedListener);
}
super.onDestroy();
}