Merge changes I8f0af447,I669919d4 into sc-v2-dev am: 445ff979f5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14664317 Change-Id: I0c1a7d1e66b3d88720f1a2b4736f40c6a5a4f2ae
This commit is contained in:
@@ -423,6 +423,11 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
// Set the exiting state first so if there is fixed rotation later, the running animation
|
// Set the exiting state first so if there is fixed rotation later, the running animation
|
||||||
// won't be interrupted by alpha animation for existing PiP.
|
// won't be interrupted by alpha animation for existing PiP.
|
||||||
mState = State.EXITING_PIP;
|
mState = State.EXITING_PIP;
|
||||||
|
|
||||||
|
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
|
||||||
|
mPipTransitionController.startTransition(destinationBounds, wct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
mSyncTransactionQueue.queue(wct);
|
mSyncTransactionQueue.queue(wct);
|
||||||
mSyncTransactionQueue.runInSync(t -> {
|
mSyncTransactionQueue.runInSync(t -> {
|
||||||
// Make sure to grab the latest source hint rect as it could have been
|
// Make sure to grab the latest source hint rect as it could have been
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.wm.shell.pip;
|
|||||||
|
|
||||||
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
|
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
|
||||||
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
||||||
|
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;
|
||||||
|
|
||||||
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA;
|
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA;
|
||||||
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
|
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
|
||||||
@@ -25,6 +26,7 @@ import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTI
|
|||||||
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
|
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
|
||||||
import static com.android.wm.shell.pip.PipAnimationController.isInPipDirection;
|
import static com.android.wm.shell.pip.PipAnimationController.isInPipDirection;
|
||||||
import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection;
|
import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection;
|
||||||
|
import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP;
|
||||||
|
|
||||||
import android.app.TaskInfo;
|
import android.app.TaskInfo;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -53,6 +55,7 @@ public class PipTransition extends PipTransitionController {
|
|||||||
private final int mEnterExitAnimationDuration;
|
private final int mEnterExitAnimationDuration;
|
||||||
private @PipAnimationController.AnimationType int mOneShotAnimationType = ANIM_TYPE_BOUNDS;
|
private @PipAnimationController.AnimationType int mOneShotAnimationType = ANIM_TYPE_BOUNDS;
|
||||||
private Transitions.TransitionFinishCallback mFinishCallback;
|
private Transitions.TransitionFinishCallback mFinishCallback;
|
||||||
|
private Rect mExitDestinationBounds = new Rect();
|
||||||
|
|
||||||
public PipTransition(Context context,
|
public PipTransition(Context context,
|
||||||
PipBoundsState pipBoundsState, PipMenuController pipMenuController,
|
PipBoundsState pipBoundsState, PipMenuController pipMenuController,
|
||||||
@@ -66,23 +69,54 @@ public class PipTransition extends PipTransitionController {
|
|||||||
.getInteger(R.integer.config_pipResizeAnimationDuration);
|
.getInteger(R.integer.config_pipResizeAnimationDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startTransition(Rect destinationBounds, WindowContainerTransaction out) {
|
||||||
|
mExitDestinationBounds.set(destinationBounds);
|
||||||
|
mTransitions.startTransition(TRANSIT_EXIT_PIP, out, this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startAnimation(@android.annotation.NonNull IBinder transition,
|
public boolean startAnimation(@android.annotation.NonNull IBinder transition,
|
||||||
@android.annotation.NonNull TransitionInfo info,
|
@android.annotation.NonNull TransitionInfo info,
|
||||||
@android.annotation.NonNull SurfaceControl.Transaction startTransaction,
|
@android.annotation.NonNull SurfaceControl.Transaction startTransaction,
|
||||||
@android.annotation.NonNull SurfaceControl.Transaction finishTransaction,
|
@android.annotation.NonNull SurfaceControl.Transaction finishTransaction,
|
||||||
@android.annotation.NonNull Transitions.TransitionFinishCallback finishCallback) {
|
@android.annotation.NonNull Transitions.TransitionFinishCallback finishCallback) {
|
||||||
|
|
||||||
|
if (info.getType() == TRANSIT_EXIT_PIP && info.getChanges().size() == 1) {
|
||||||
|
final TransitionInfo.Change change = info.getChanges().get(0);
|
||||||
|
mFinishCallback = finishCallback;
|
||||||
|
boolean success = startExpandAnimation(change.getTaskInfo(), change.getLeash(),
|
||||||
|
new Rect(mExitDestinationBounds));
|
||||||
|
mExitDestinationBounds.setEmpty();
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search for an Enter PiP transition (along with a show wallpaper one)
|
||||||
|
TransitionInfo.Change enterPip = null;
|
||||||
|
TransitionInfo.Change wallpaper = null;
|
||||||
for (int i = info.getChanges().size() - 1; i >= 0; --i) {
|
for (int i = info.getChanges().size() - 1; i >= 0; --i) {
|
||||||
final TransitionInfo.Change change = info.getChanges().get(i);
|
final TransitionInfo.Change change = info.getChanges().get(i);
|
||||||
if (change.getTaskInfo() != null
|
if (change.getTaskInfo() != null
|
||||||
&& change.getTaskInfo().configuration.windowConfiguration.getWindowingMode()
|
&& change.getTaskInfo().configuration.windowConfiguration.getWindowingMode()
|
||||||
== WINDOWING_MODE_PINNED) {
|
== WINDOWING_MODE_PINNED) {
|
||||||
mFinishCallback = finishCallback;
|
enterPip = change;
|
||||||
return startEnterAnimation(change.getTaskInfo(), change.getLeash(),
|
} else if ((change.getFlags() & FLAG_IS_WALLPAPER) != 0) {
|
||||||
startTransaction, finishTransaction);
|
wallpaper = change;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
if (enterPip == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the wallpaper if there is a wallpaper change.
|
||||||
|
if (wallpaper != null) {
|
||||||
|
startTransaction.show(wallpaper.getLeash());
|
||||||
|
startTransaction.setAlpha(wallpaper.getLeash(), 1.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
mFinishCallback = finishCallback;
|
||||||
|
return startEnterAnimation(enterPip.getTaskInfo(), enterPip.getLeash(),
|
||||||
|
startTransaction, finishTransaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -109,6 +143,21 @@ public class PipTransition extends PipTransitionController {
|
|||||||
finishResizeForMenu(destinationBounds);
|
finishResizeForMenu(destinationBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean startExpandAnimation(final TaskInfo taskInfo, final SurfaceControl leash,
|
||||||
|
final Rect destinationBounds) {
|
||||||
|
PipAnimationController.PipTransitionAnimator animator =
|
||||||
|
mPipAnimationController.getAnimator(taskInfo, leash, mPipBoundsState.getBounds(),
|
||||||
|
mPipBoundsState.getBounds(), destinationBounds, null,
|
||||||
|
TRANSITION_DIRECTION_LEAVE_PIP, 0 /* startingAngle */, Surface.ROTATION_0);
|
||||||
|
|
||||||
|
animator.setTransitionDirection(TRANSITION_DIRECTION_LEAVE_PIP)
|
||||||
|
.setPipAnimationCallback(mPipAnimationCallback)
|
||||||
|
.setDuration(mEnterExitAnimationDuration)
|
||||||
|
.start();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean startEnterAnimation(final TaskInfo taskInfo, final SurfaceControl leash,
|
private boolean startEnterAnimation(final TaskInfo taskInfo, final SurfaceControl leash,
|
||||||
final SurfaceControl.Transaction startTransaction,
|
final SurfaceControl.Transaction startTransaction,
|
||||||
final SurfaceControl.Transaction finishTransaction) {
|
final SurfaceControl.Transaction finishTransaction) {
|
||||||
@@ -127,7 +176,6 @@ public class PipTransition extends PipTransitionController {
|
|||||||
0 /* startingAngle */, Surface.ROTATION_0);
|
0 /* startingAngle */, Surface.ROTATION_0);
|
||||||
} else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) {
|
} else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) {
|
||||||
startTransaction.setAlpha(leash, 0f);
|
startTransaction.setAlpha(leash, 0f);
|
||||||
startTransaction.apply();
|
|
||||||
animator = mPipAnimationController.getAnimator(taskInfo, leash, destinationBounds,
|
animator = mPipAnimationController.getAnimator(taskInfo, leash, destinationBounds,
|
||||||
0f, 1f);
|
0f, 1f);
|
||||||
mOneShotAnimationType = ANIM_TYPE_BOUNDS;
|
mOneShotAnimationType = ANIM_TYPE_BOUNDS;
|
||||||
@@ -135,6 +183,7 @@ public class PipTransition extends PipTransitionController {
|
|||||||
throw new RuntimeException("Unrecognized animation type: "
|
throw new RuntimeException("Unrecognized animation type: "
|
||||||
+ mOneShotAnimationType);
|
+ mOneShotAnimationType);
|
||||||
}
|
}
|
||||||
|
startTransaction.apply();
|
||||||
animator.setTransitionDirection(TRANSITION_DIRECTION_TO_PIP)
|
animator.setTransitionDirection(TRANSITION_DIRECTION_TO_PIP)
|
||||||
.setPipAnimationCallback(mPipAnimationCallback)
|
.setPipAnimationCallback(mPipAnimationCallback)
|
||||||
.setDuration(mEnterExitAnimationDuration)
|
.setDuration(mEnterExitAnimationDuration)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.graphics.Rect;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
|
import android.window.WindowContainerTransaction;
|
||||||
|
|
||||||
import com.android.wm.shell.ShellTaskOrganizer;
|
import com.android.wm.shell.ShellTaskOrganizer;
|
||||||
import com.android.wm.shell.transition.Transitions;
|
import com.android.wm.shell.transition.Transitions;
|
||||||
@@ -46,6 +47,7 @@ public abstract class PipTransitionController implements Transitions.TransitionH
|
|||||||
protected final PipBoundsState mPipBoundsState;
|
protected final PipBoundsState mPipBoundsState;
|
||||||
protected final ShellTaskOrganizer mShellTaskOrganizer;
|
protected final ShellTaskOrganizer mShellTaskOrganizer;
|
||||||
protected final PipMenuController mPipMenuController;
|
protected final PipMenuController mPipMenuController;
|
||||||
|
protected final Transitions mTransitions;
|
||||||
private final Handler mMainHandler;
|
private final Handler mMainHandler;
|
||||||
private final List<PipTransitionCallback> mPipTransitionCallbacks = new ArrayList<>();
|
private final List<PipTransitionCallback> mPipTransitionCallbacks = new ArrayList<>();
|
||||||
|
|
||||||
@@ -98,6 +100,13 @@ public abstract class PipTransitionController implements Transitions.TransitionH
|
|||||||
SurfaceControl.Transaction tx) {
|
SurfaceControl.Transaction tx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the Shell wants to starts a transition/animation.
|
||||||
|
*/
|
||||||
|
public void startTransition(Rect destinationBounds, WindowContainerTransaction out) {
|
||||||
|
// Default implementation does nothing.
|
||||||
|
}
|
||||||
|
|
||||||
public PipTransitionController(PipBoundsState pipBoundsState,
|
public PipTransitionController(PipBoundsState pipBoundsState,
|
||||||
PipMenuController pipMenuController, PipBoundsAlgorithm pipBoundsAlgorithm,
|
PipMenuController pipMenuController, PipBoundsAlgorithm pipBoundsAlgorithm,
|
||||||
PipAnimationController pipAnimationController, Transitions transitions,
|
PipAnimationController pipAnimationController, Transitions transitions,
|
||||||
@@ -107,6 +116,7 @@ public abstract class PipTransitionController implements Transitions.TransitionH
|
|||||||
mShellTaskOrganizer = shellTaskOrganizer;
|
mShellTaskOrganizer = shellTaskOrganizer;
|
||||||
mPipBoundsAlgorithm = pipBoundsAlgorithm;
|
mPipBoundsAlgorithm = pipBoundsAlgorithm;
|
||||||
mPipAnimationController = pipAnimationController;
|
mPipAnimationController = pipAnimationController;
|
||||||
|
mTransitions = transitions;
|
||||||
mMainHandler = new Handler(Looper.getMainLooper());
|
mMainHandler = new Handler(Looper.getMainLooper());
|
||||||
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
|
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
|
||||||
transitions.addHandler(this);
|
transitions.addHandler(this);
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ public class Transitions implements RemoteCallable<Transitions> {
|
|||||||
/** Transition type for launching 2 tasks simultaneously. */
|
/** Transition type for launching 2 tasks simultaneously. */
|
||||||
public static final int TRANSIT_SPLIT_SCREEN_PAIR_OPEN = TRANSIT_FIRST_CUSTOM + 2;
|
public static final int TRANSIT_SPLIT_SCREEN_PAIR_OPEN = TRANSIT_FIRST_CUSTOM + 2;
|
||||||
|
|
||||||
|
/** Transition type for exiting PIP via the Shell, either via Expand or Dismiss. */
|
||||||
|
public static final int TRANSIT_EXIT_PIP = TRANSIT_FIRST_CUSTOM + 3;
|
||||||
|
|
||||||
private final WindowOrganizer mOrganizer;
|
private final WindowOrganizer mOrganizer;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final ShellExecutor mMainExecutor;
|
private final ShellExecutor mMainExecutor;
|
||||||
|
|||||||
Reference in New Issue
Block a user