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

Commit effafdfe authored by Eric Lin's avatar Eric Lin
Browse files

Add IntDef annotations for transition and animation types.

Add proper @IntDef annotations for mixed transition types and animation
sub-types in DefaultMixedHandler. This provides better type safety
through enum-like constraints for constants and fixes an incorrect value
for ANIM_TYPE_PAIR_TO_PAIR (changed from 1 to 2).

Bug: 387193964
Test: atest WMShellUnitTests
Flag: EXEMPT refactor
Change-Id: Ib78e99c1843052e861b404a516ecb8d4e6705448
parent a2e00828
Loading
Loading
Loading
Loading
+38 −3
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static android.window.TransitionInfo.FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;

import static com.android.wm.shell.shared.TransitionUtil.isOpeningType;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.PendingIntent;
@@ -56,6 +57,8 @@ import com.android.wm.shell.splitscreen.StageCoordinator;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.unfold.UnfoldTransitionHandler;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Map;
import java.util.Optional;
@@ -131,6 +134,27 @@ public class DefaultMixedHandler implements MixedTransitionHandler,
        /** Transition of a visible app into a bubble when launched from another bubble. */
        static final int TYPE_LAUNCH_OR_CONVERT_TO_BUBBLE_FROM_EXISTING_BUBBLE = 15;

        @IntDef(prefix = {"TYPE_"}, value = {
                TYPE_ENTER_PIP_FROM_SPLIT,
                TYPE_DISPLAY_AND_SPLIT_CHANGE,
                TYPE_OPTIONS_REMOTE_AND_PIP_OR_DESKTOP_CHANGE,
                TYPE_RECENTS_DURING_SPLIT,
                TYPE_KEYGUARD,
                TYPE_RECENTS_DURING_KEYGUARD,
                TYPE_RECENTS_DURING_DESKTOP,
                TYPE_UNFOLD,
                TYPE_ENTER_PIP_FROM_ACTIVITY_EMBEDDING,
                TYPE_ENTER_PIP_REPLACE_FROM_SPLIT,
                TYPE_ENTER_PIP_WITH_DISPLAY_CHANGE,
                TYPE_OPEN_IN_DESKTOP,
                TYPE_LAUNCH_OR_CONVERT_TO_BUBBLE,
                TYPE_LAUNCH_OR_CONVERT_SPLIT_TASK_TO_BUBBLE,
                TYPE_LAUNCH_OR_CONVERT_TO_BUBBLE_FROM_EXISTING_BUBBLE,
        })
        @Retention(RetentionPolicy.SOURCE)
        @interface MixedTransitionType {
        }

        // Mixed transition sub-animation types

        /** The default animation for this mixed transition. */
@@ -140,9 +164,19 @@ public class DefaultMixedHandler implements MixedTransitionHandler,
        static final int ANIM_TYPE_GOING_HOME = 1;

        /** For RECENTS_DURING_SPLIT, is set when this turns into a pair->pair task switch. */
        static final int ANIM_TYPE_PAIR_TO_PAIR = 1;
        static final int ANIM_TYPE_PAIR_TO_PAIR = 2;

        @IntDef(prefix = {"ANIM_TYPE_"}, value = {
                ANIM_TYPE_DEFAULT,
                ANIM_TYPE_GOING_HOME,
                ANIM_TYPE_PAIR_TO_PAIR,
        })
        @interface SubAnimationType {
        }

        @MixedTransitionType
        final int mType;
        @SubAnimationType
        int mAnimType = ANIM_TYPE_DEFAULT;
        final IBinder mTransition;

@@ -172,7 +206,7 @@ public class DefaultMixedHandler implements MixedTransitionHandler,
         */
        int mInFlightSubAnimations = 0;

        MixedTransition(int type, IBinder transition, Transitions player,
        MixedTransition(@MixedTransitionType int type, IBinder transition, Transitions player,
                MixedTransitionHandler mixedHandler, PipTransitionController pipHandler,
                StageCoordinator splitHandler, KeyguardTransitionHandler keyguardHandler) {
            mType = type;
@@ -424,7 +458,8 @@ public class DefaultMixedHandler implements MixedTransitionHandler,
        return null;
    }

    private DefaultMixedTransition createDefaultMixedTransition(int type, IBinder transition) {
    private DefaultMixedTransition createDefaultMixedTransition(
            @MixedTransition.MixedTransitionType int type, IBinder transition) {
        return new DefaultMixedTransition(
                type, transition, mPlayer, this, mPipHandler, mSplitHandler, mKeyguardHandler,
                mUnfoldHandler, mActivityEmbeddingController, mDesktopTasksController,