Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ed1868d authored by randypfohl's avatar randypfohl
Browse files

Moving RecentsWindowManager away from the singleton pattern

Test: Built and tested locally

Flag: com.android.launcher3.enable_fallback_overview_in_window

Bug:292269949

Change-Id: Ic70d9a3e65ffb86e369f52982891b94bef4cacd7
parent c50aa8bf
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -294,7 +294,7 @@ public abstract class AbsSwipeUpHandler<
    private static final int LOG_NO_OP_PAGE_INDEX = -1;

    protected final TaskAnimationManager mTaskAnimationManager;

    protected final RecentsWindowManager mRecentsWindowManager;
    // Either RectFSpringAnim (if animating home) or ObjectAnimator (from mCurrentShift) otherwise
    private RunningWindowAnim[] mRunningWindowAnim;
    // Possible second animation running at the same time as mRunningWindowAnim
@@ -355,12 +355,11 @@ public abstract class AbsSwipeUpHandler<
    public AbsSwipeUpHandler(Context context, RecentsAnimationDeviceState deviceState,
            TaskAnimationManager taskAnimationManager, GestureState gestureState,
            long touchTimeMs, boolean continuingLastGesture,
            InputConsumerController inputConsumer) {
            InputConsumerController inputConsumer, RecentsWindowManager recentsWindowManager) {
        super(context, deviceState, gestureState);
        mContainerInterface = gestureState.getContainerInterface();
        if (Flags.enableFallbackOverviewInWindow()) {
            RecentsWindowManager.Companion.getInstanceOrNull()
                    .registerInitListener(this::onActivityInit);
        if (recentsWindowManager != null && Flags.enableFallbackOverviewInWindow()) {
            recentsWindowManager.registerInitListener(this::onActivityInit);
        }
        mActivityInitListener =
                mContainerInterface.createActivityInitListener(this::onActivityInit);
@@ -375,6 +374,7 @@ public abstract class AbsSwipeUpHandler<
                    endLauncherTransitionController();
                }, new InputProxyHandlerFactory(mContainerInterface, mGestureState));
        mTaskAnimationManager = taskAnimationManager;
        mRecentsWindowManager = recentsWindowManager;
        mTouchTimeMs = touchTimeMs;
        mContinuingLastGesture = continuingLastGesture;

+2 −1
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.util.DisplayController;
import com.android.quickstep.fallback.FallbackRecentsView;
import com.android.quickstep.fallback.RecentsState;
import com.android.quickstep.fallback.window.RecentsWindowManager;
import com.android.quickstep.util.ActiveGestureLog;
import com.android.quickstep.util.RectFSpringAnim;
import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties;
@@ -105,7 +106,7 @@ public class FallbackSwipeHandler extends
            TaskAnimationManager taskAnimationManager, GestureState gestureState, long touchTimeMs,
            boolean continuingLastGesture, InputConsumerController inputConsumer) {
        super(context, deviceState, taskAnimationManager, gestureState, touchTimeMs,
                continuingLastGesture, inputConsumer);
                continuingLastGesture, inputConsumer, null);

        mRunningOverHome = mGestureState.getRunningTask() != null
                && mGestureState.getRunningTask().isHomeTask();
+25 −4
Original line number Diff line number Diff line
@@ -51,10 +51,31 @@ import java.util.function.Predicate;
 */
public final class FallbackWindowInterface extends BaseWindowInterface{

    public static final FallbackWindowInterface INSTANCE = new FallbackWindowInterface();
    private static FallbackWindowInterface INSTANCE;

    private FallbackWindowInterface() {
    private final RecentsWindowManager mRecentsWindowManager;

    /**
     * This is only null before init() or after destroy()
     */
    @Nullable
    public static FallbackWindowInterface getInstance(){
        return INSTANCE;
    }

    public static void init(RecentsWindowManager recentsWindowManager) {
        if (INSTANCE == null) {
            INSTANCE = new FallbackWindowInterface(recentsWindowManager);
        }
    }

    private FallbackWindowInterface(RecentsWindowManager recentsWindowManager) {
        super(DEFAULT, BACKGROUND_APP);
        mRecentsWindowManager = recentsWindowManager;
    }

    public void destroy() {
        INSTANCE = null;
    }

    /** 2 */
@@ -100,7 +121,7 @@ public final class FallbackWindowInterface extends BaseWindowInterface{
    @Nullable
    @Override
    public RecentsWindowManager getCreatedContainer() {
        return RecentsWindowManager.Companion.getInstanceOrNull();
        return mRecentsWindowManager;
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.launcher3.views.ClipIconView;
import com.android.launcher3.views.FloatingIconView;
import com.android.launcher3.views.FloatingView;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.quickstep.fallback.window.RecentsWindowManager;
import com.android.quickstep.util.RectFSpringAnim;
import com.android.quickstep.util.ScalingWorkspaceRevealAnim;
import com.android.quickstep.util.StaggeredWorkspaceAnim;
@@ -68,7 +69,7 @@ public class LauncherSwipeHandlerV2 extends AbsSwipeUpHandler<
            TaskAnimationManager taskAnimationManager, GestureState gestureState, long touchTimeMs,
            boolean continuingLastGesture, InputConsumerController inputConsumer) {
        super(context, deviceState, taskAnimationManager, gestureState, touchTimeMs,
                continuingLastGesture, inputConsumer);
                continuingLastGesture, inputConsumer, null);
    }


+3 −4
Original line number Diff line number Diff line
@@ -46,19 +46,18 @@ import com.android.quickstep.OverviewCommandHelper.CommandType.SHOW
import com.android.quickstep.OverviewCommandHelper.CommandType.TOGGLE
import com.android.quickstep.util.ActiveGestureLog
import com.android.quickstep.views.RecentsView
import com.android.quickstep.views.RecentsViewContainer
import com.android.quickstep.views.TaskView
import com.android.systemui.shared.recents.model.ThumbnailData
import com.android.systemui.shared.system.InteractionJankMonitorWrapper
import java.io.PrintWriter
import java.util.concurrent.ConcurrentLinkedDeque
import kotlin.coroutines.resume
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.withTimeout
import java.io.PrintWriter
import java.util.concurrent.ConcurrentLinkedDeque
import kotlin.coroutines.resume

/** Helper class to handle various atomic commands for switching between Overview. */
class OverviewCommandHelper
Loading