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

Commit 4c51ad9e authored by Todd Lee's avatar Todd Lee
Browse files

Refactor mixed transition handling for use in other form factors

This change moves DefaultMixedHandler to implement
MixedTransitionHandler stub interface. At the same time, this interface
is provided as a dynamically overridable module in systemui/dagger.

This is a no-op on phones but provides non-phone form factors the
opportunity to hook into providing their own mixed handlers that can
be added to Transtitions on init.

Flag: NA refactor only
Bug: b/335463085
Test: atest WMShellUnitTests

Change-Id: I4a890f09352e242e16049861a47f815c45199a8a
parent 9adec260
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ import com.android.wm.shell.taskview.TaskViewFactory;
import com.android.wm.shell.taskview.TaskViewFactoryController;
import com.android.wm.shell.taskview.TaskViewTransitions;
import com.android.wm.shell.transition.HomeTransitionObserver;
import com.android.wm.shell.transition.MixedTransitionHandler;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.unfold.ShellUnfoldProgressProvider;
import com.android.wm.shell.unfold.UnfoldAnimationController;
@@ -675,6 +676,22 @@ public abstract class WMShellBaseModule {
        return new TaskViewTransitions(transitions);
    }

    // Workaround for dynamic overriding with a default implementation, see {@link DynamicOverride}
    @BindsOptionalOf
    @DynamicOverride
    abstract MixedTransitionHandler optionalMixedTransitionHandler();

    @WMSingleton
    @Provides
    static Optional<MixedTransitionHandler> provideMixedTransitionHandler(
            @DynamicOverride Optional<MixedTransitionHandler> mixedTransitionHandler
    ) {
        if (mixedTransitionHandler.isPresent()) {
            return mixedTransitionHandler;
        }
        return Optional.empty();
    }

    //
    // Keyguard transitions (optional feature)
    //
@@ -934,6 +951,7 @@ public abstract class WMShellBaseModule {
            Optional<OneHandedController> oneHandedControllerOptional,
            Optional<HideDisplayCutoutController> hideDisplayCutoutControllerOptional,
            Optional<ActivityEmbeddingController> activityEmbeddingOptional,
            Optional<MixedTransitionHandler> mixedTransitionHandler,
            Transitions transitions,
            StartingWindowController startingWindow,
            ProtoLogController protoLogController,
+3 −2
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.taskview.TaskViewTransitions;
import com.android.wm.shell.transition.DefaultMixedHandler;
import com.android.wm.shell.transition.HomeTransitionObserver;
import com.android.wm.shell.transition.MixedTransitionHandler;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.unfold.ShellUnfoldProgressProvider;
import com.android.wm.shell.unfold.UnfoldAnimationController;
@@ -373,8 +374,9 @@ public abstract class WMShellModule {
    //

    @WMSingleton
    @DynamicOverride
    @Provides
    static DefaultMixedHandler provideDefaultMixedHandler(
    static MixedTransitionHandler provideMixedTransitionHandler(
            ShellInit shellInit,
            Optional<SplitScreenController> splitScreenOptional,
            @Nullable PipTransitionController pipTransitionController,
@@ -655,7 +657,6 @@ public abstract class WMShellModule {
    @Provides
    static Object provideIndependentShellComponentsToCreate(
            DragAndDropController dragAndDropController,
            DefaultMixedHandler defaultMixedHandler,
            Optional<DesktopTasksTransitionObserver> desktopTasksTransitionObserverOptional) {
        return new Object();
    }
+5 −4
Original line number Diff line number Diff line
@@ -61,9 +61,10 @@ import java.util.function.Consumer;

/**
 * A handler for dealing with transitions involving multiple other handlers. For example: an
 * activity in split-screen going into PiP.
 * activity in split-screen going into PiP. Note this is provided as a handset-specific
 * implementation of {@code MixedTransitionHandler}.
 */
public class DefaultMixedHandler implements Transitions.TransitionHandler,
public class DefaultMixedHandler implements MixedTransitionHandler,
        RecentsTransitionHandler.RecentsMixedHandler {

    private final Transitions mPlayer;
@@ -116,7 +117,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
        final IBinder mTransition;

        protected final Transitions mPlayer;
        protected final DefaultMixedHandler mMixedHandler;
        protected final MixedTransitionHandler mMixedHandler;
        protected final PipTransitionController mPipHandler;
        protected final StageCoordinator mSplitHandler;
        protected final KeyguardTransitionHandler mKeyguardHandler;
@@ -142,7 +143,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
        int mInFlightSubAnimations = 0;

        MixedTransition(int type, IBinder transition, Transitions player,
                DefaultMixedHandler mixedHandler, PipTransitionController pipHandler,
                MixedTransitionHandler mixedHandler, PipTransitionController pipHandler,
                StageCoordinator splitHandler, KeyguardTransitionHandler keyguardHandler) {
            mType = type;
            mTransition = transition;
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
    private final ActivityEmbeddingController mActivityEmbeddingController;

    DefaultMixedTransition(int type, IBinder transition, Transitions player,
            DefaultMixedHandler mixedHandler, PipTransitionController pipHandler,
            MixedTransitionHandler mixedHandler, PipTransitionController pipHandler,
            StageCoordinator splitHandler, KeyguardTransitionHandler keyguardHandler,
            UnfoldTransitionHandler unfoldHandler,
            ActivityEmbeddingController activityEmbeddingController) {
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.transition;

/**
 * Interface for a {@link Transitions.TransitionHandler} that can take the subset of transitions
 * that it handles and further decompose those transitions into sub-transitions which can be
 * independently delegated to separate handlers.
 */
public interface MixedTransitionHandler extends Transitions.TransitionHandler {

    // TODO(b/335685449) this currently exists purely as a marker interface for use in form-factor
    // specific/sysui dagger modules. Going forward, we should define this in a meaningful
    // way so as to provide a clear basis for expectations/behaviours associated with mixed
    // transitions and their default handlers.

}
Loading