Add mixed-handler for unfold and mix in pip state
Add unfold to mixed-handler so that we can mix in updates for other components. In this case, we update pip state during unfold. Bug: 286084821 Test: Unfold with a PiP Change-Id: I872c8326dfa4662feecb45e2d2b4fd7b042a9123
This commit is contained in:
@@ -547,10 +547,11 @@ public abstract class WMShellModule {
|
|||||||
KeyguardTransitionHandler keyguardTransitionHandler,
|
KeyguardTransitionHandler keyguardTransitionHandler,
|
||||||
Optional<DesktopModeController> desktopModeController,
|
Optional<DesktopModeController> desktopModeController,
|
||||||
Optional<DesktopTasksController> desktopTasksController,
|
Optional<DesktopTasksController> desktopTasksController,
|
||||||
|
Optional<UnfoldTransitionHandler> unfoldHandler,
|
||||||
Transitions transitions) {
|
Transitions transitions) {
|
||||||
return new DefaultMixedHandler(shellInit, transitions, splitScreenOptional,
|
return new DefaultMixedHandler(shellInit, transitions, splitScreenOptional,
|
||||||
pipTouchHandlerOptional, recentsTransitionHandler, keyguardTransitionHandler,
|
pipTouchHandlerOptional, recentsTransitionHandler, keyguardTransitionHandler,
|
||||||
desktopModeController, desktopTasksController);
|
desktopModeController, desktopTasksController, unfoldHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WMSingleton
|
@WMSingleton
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@@ -55,6 +54,7 @@ import com.android.wm.shell.recents.RecentsTransitionHandler;
|
|||||||
import com.android.wm.shell.splitscreen.SplitScreenController;
|
import com.android.wm.shell.splitscreen.SplitScreenController;
|
||||||
import com.android.wm.shell.splitscreen.StageCoordinator;
|
import com.android.wm.shell.splitscreen.StageCoordinator;
|
||||||
import com.android.wm.shell.sysui.ShellInit;
|
import com.android.wm.shell.sysui.ShellInit;
|
||||||
|
import com.android.wm.shell.unfold.UnfoldTransitionHandler;
|
||||||
import com.android.wm.shell.util.TransitionUtil;
|
import com.android.wm.shell.util.TransitionUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -74,6 +74,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
|||||||
private final KeyguardTransitionHandler mKeyguardHandler;
|
private final KeyguardTransitionHandler mKeyguardHandler;
|
||||||
private DesktopModeController mDesktopModeController;
|
private DesktopModeController mDesktopModeController;
|
||||||
private DesktopTasksController mDesktopTasksController;
|
private DesktopTasksController mDesktopTasksController;
|
||||||
|
private UnfoldTransitionHandler mUnfoldHandler;
|
||||||
|
|
||||||
private static class MixedTransition {
|
private static class MixedTransition {
|
||||||
static final int TYPE_ENTER_PIP_FROM_SPLIT = 1;
|
static final int TYPE_ENTER_PIP_FROM_SPLIT = 1;
|
||||||
@@ -93,6 +94,9 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
|||||||
/** Recents Transition while in desktop mode. */
|
/** Recents Transition while in desktop mode. */
|
||||||
static final int TYPE_RECENTS_DURING_DESKTOP = 6;
|
static final int TYPE_RECENTS_DURING_DESKTOP = 6;
|
||||||
|
|
||||||
|
/** Fuld/Unfold transition. */
|
||||||
|
static final int TYPE_UNFOLD = 7;
|
||||||
|
|
||||||
/** The default animation for this mixed transition. */
|
/** The default animation for this mixed transition. */
|
||||||
static final int ANIM_TYPE_DEFAULT = 0;
|
static final int ANIM_TYPE_DEFAULT = 0;
|
||||||
|
|
||||||
@@ -146,7 +150,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
|||||||
Optional<RecentsTransitionHandler> recentsHandlerOptional,
|
Optional<RecentsTransitionHandler> recentsHandlerOptional,
|
||||||
KeyguardTransitionHandler keyguardHandler,
|
KeyguardTransitionHandler keyguardHandler,
|
||||||
Optional<DesktopModeController> desktopModeControllerOptional,
|
Optional<DesktopModeController> desktopModeControllerOptional,
|
||||||
Optional<DesktopTasksController> desktopTasksControllerOptional) {
|
Optional<DesktopTasksController> desktopTasksControllerOptional,
|
||||||
|
Optional<UnfoldTransitionHandler> unfoldHandler) {
|
||||||
mPlayer = player;
|
mPlayer = player;
|
||||||
mKeyguardHandler = keyguardHandler;
|
mKeyguardHandler = keyguardHandler;
|
||||||
if (Transitions.ENABLE_SHELL_TRANSITIONS && pipTouchHandlerOptional.isPresent()
|
if (Transitions.ENABLE_SHELL_TRANSITIONS && pipTouchHandlerOptional.isPresent()
|
||||||
@@ -165,6 +170,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
|||||||
}
|
}
|
||||||
mDesktopModeController = desktopModeControllerOptional.orElse(null);
|
mDesktopModeController = desktopModeControllerOptional.orElse(null);
|
||||||
mDesktopTasksController = desktopTasksControllerOptional.orElse(null);
|
mDesktopTasksController = desktopTasksControllerOptional.orElse(null);
|
||||||
|
mUnfoldHandler = unfoldHandler.orElse(null);
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,6 +236,16 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
|||||||
mixed.mLeftoversHandler = handler.first;
|
mixed.mLeftoversHandler = handler.first;
|
||||||
mActiveTransitions.add(mixed);
|
mActiveTransitions.add(mixed);
|
||||||
return handler.second;
|
return handler.second;
|
||||||
|
} else if (mUnfoldHandler != null && mUnfoldHandler.hasUnfold(request)) {
|
||||||
|
final WindowContainerTransaction wct =
|
||||||
|
mUnfoldHandler.handleRequest(transition, request);
|
||||||
|
if (wct != null) {
|
||||||
|
final MixedTransition mixed = new MixedTransition(
|
||||||
|
MixedTransition.TYPE_UNFOLD, transition);
|
||||||
|
mixed.mLeftoversHandler = mUnfoldHandler;
|
||||||
|
mActiveTransitions.add(mixed);
|
||||||
|
}
|
||||||
|
return wct;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -335,6 +351,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
|||||||
} else if (mixed.mType == MixedTransition.TYPE_RECENTS_DURING_DESKTOP) {
|
} else if (mixed.mType == MixedTransition.TYPE_RECENTS_DURING_DESKTOP) {
|
||||||
return animateRecentsDuringDesktop(mixed, info, startTransaction, finishTransaction,
|
return animateRecentsDuringDesktop(mixed, info, startTransaction, finishTransaction,
|
||||||
finishCallback);
|
finishCallback);
|
||||||
|
} else if (mixed.mType == MixedTransition.TYPE_UNFOLD) {
|
||||||
|
return animateUnfold(mixed, info, startTransaction, finishTransaction, finishCallback);
|
||||||
} else {
|
} else {
|
||||||
mActiveTransitions.remove(mixed);
|
mActiveTransitions.remove(mixed);
|
||||||
throw new IllegalStateException("Starting mixed animation without a known mixed type? "
|
throw new IllegalStateException("Starting mixed animation without a known mixed type? "
|
||||||
@@ -642,6 +660,33 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean animateUnfold(@NonNull final MixedTransition mixed,
|
||||||
|
@NonNull TransitionInfo info,
|
||||||
|
@NonNull SurfaceControl.Transaction startTransaction,
|
||||||
|
@NonNull SurfaceControl.Transaction finishTransaction,
|
||||||
|
@NonNull Transitions.TransitionFinishCallback finishCallback) {
|
||||||
|
final Transitions.TransitionFinishCallback finishCB = (wct, wctCB) -> {
|
||||||
|
mixed.mInFlightSubAnimations--;
|
||||||
|
if (mixed.mInFlightSubAnimations > 0) return;
|
||||||
|
mActiveTransitions.remove(mixed);
|
||||||
|
finishCallback.onTransitionFinished(wct, wctCB);
|
||||||
|
};
|
||||||
|
mixed.mInFlightSubAnimations = 1;
|
||||||
|
if (!mUnfoldHandler.startAnimation(
|
||||||
|
mixed.mTransition, info, startTransaction, finishTransaction, finishCB)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Sync pip state.
|
||||||
|
if (mPipHandler != null) {
|
||||||
|
// We don't know when to apply `startTransaction` so use a separate transaction here.
|
||||||
|
// This should be fine because these surface properties are independent.
|
||||||
|
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
|
||||||
|
mPipHandler.syncPipSurfaceState(info, t, finishTransaction);
|
||||||
|
t.apply();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/** Use to when split use intent to enter, check if this enter transition should be mixed or
|
/** Use to when split use intent to enter, check if this enter transition should be mixed or
|
||||||
* not.*/
|
* not.*/
|
||||||
public boolean shouldSplitEnterMixed(PendingIntent intent) {
|
public boolean shouldSplitEnterMixed(PendingIntent intent) {
|
||||||
@@ -699,6 +744,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
|||||||
} else if (mixed.mType == MixedTransition.TYPE_RECENTS_DURING_DESKTOP) {
|
} else if (mixed.mType == MixedTransition.TYPE_RECENTS_DURING_DESKTOP) {
|
||||||
mixed.mLeftoversHandler.mergeAnimation(transition, info, t, mergeTarget,
|
mixed.mLeftoversHandler.mergeAnimation(transition, info, t, mergeTarget,
|
||||||
finishCallback);
|
finishCallback);
|
||||||
|
} else if (mixed.mType == MixedTransition.TYPE_UNFOLD) {
|
||||||
|
mUnfoldHandler.mergeAnimation(transition, info, t, mergeTarget, finishCallback);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Playing a mixed transition with unknown type? "
|
throw new IllegalStateException("Playing a mixed transition with unknown type? "
|
||||||
+ mixed.mType);
|
+ mixed.mType);
|
||||||
@@ -726,6 +773,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
|||||||
mKeyguardHandler.onTransitionConsumed(transition, aborted, finishT);
|
mKeyguardHandler.onTransitionConsumed(transition, aborted, finishT);
|
||||||
} else if (mixed.mType == MixedTransition.TYPE_RECENTS_DURING_DESKTOP) {
|
} else if (mixed.mType == MixedTransition.TYPE_RECENTS_DURING_DESKTOP) {
|
||||||
mixed.mLeftoversHandler.onTransitionConsumed(transition, aborted, finishT);
|
mixed.mLeftoversHandler.onTransitionConsumed(transition, aborted, finishT);
|
||||||
|
} else if (mixed.mType == MixedTransition.TYPE_UNFOLD) {
|
||||||
|
mUnfoldHandler.onTransitionConsumed(transition, aborted, finishT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,12 +184,18 @@ public class UnfoldTransitionHandler implements TransitionHandler, UnfoldListene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether `request` contains an unfold action. */
|
||||||
|
public boolean hasUnfold(@NonNull TransitionRequestInfo request) {
|
||||||
|
return (request.getType() == TRANSIT_CHANGE
|
||||||
|
&& request.getDisplayChange() != null
|
||||||
|
&& request.getDisplayChange().isPhysicalDisplayChanged());
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public WindowContainerTransaction handleRequest(@NonNull IBinder transition,
|
public WindowContainerTransaction handleRequest(@NonNull IBinder transition,
|
||||||
@NonNull TransitionRequestInfo request) {
|
@NonNull TransitionRequestInfo request) {
|
||||||
if (request.getType() == TRANSIT_CHANGE && request.getDisplayChange() != null
|
if (hasUnfold(request)) {
|
||||||
&& request.getDisplayChange().isPhysicalDisplayChanged()) {
|
|
||||||
mTransition = transition;
|
mTransition = transition;
|
||||||
return new WindowContainerTransaction();
|
return new WindowContainerTransaction();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user