Handle recents transition using DefaultTransitionHandler when Desktop
Mode Active When we are in desktop mode, we need to apply changes to the task surface such as setting the corner radius. To do so, we delegate recent transitions to the default mixed handler. After adding the required changes for desktop mode, RecentsTransitionHandler#startAnimation is applied. Test: Open 2 tasks and swipe up to get the task bar. Corners should remain rounded for all windows. Bug: 280819685 Change-Id: Ic25047473780801531a64e205bea26fb0c1f4b79
This commit is contained in:
@@ -542,9 +542,12 @@ public abstract class WMShellModule {
|
||||
Optional<PipTouchHandler> pipTouchHandlerOptional,
|
||||
Optional<RecentsTransitionHandler> recentsTransitionHandler,
|
||||
KeyguardTransitionHandler keyguardTransitionHandler,
|
||||
Optional<DesktopModeController> desktopModeController,
|
||||
Optional<DesktopTasksController> desktopTasksController,
|
||||
Transitions transitions) {
|
||||
return new DefaultMixedHandler(shellInit, transitions, splitScreenOptional,
|
||||
pipTouchHandlerOptional, recentsTransitionHandler, keyguardTransitionHandler);
|
||||
pipTouchHandlerOptional, recentsTransitionHandler, keyguardTransitionHandler,
|
||||
desktopModeController, desktopTasksController);
|
||||
}
|
||||
|
||||
@WMSingleton
|
||||
|
||||
@@ -33,6 +33,7 @@ import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_DE
|
||||
import android.app.ActivityManager.RunningTaskInfo;
|
||||
import android.app.WindowConfiguration;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.ContentObserver;
|
||||
import android.graphics.Region;
|
||||
import android.net.Uri;
|
||||
@@ -413,6 +414,25 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
|
||||
return wct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the proper surface states (rounded corners) to tasks when desktop mode is active.
|
||||
* This is intended to be used when desktop mode is part of another animation but isn't, itself,
|
||||
* animating.
|
||||
*/
|
||||
public void syncSurfaceState(@NonNull TransitionInfo info,
|
||||
SurfaceControl.Transaction finishTransaction) {
|
||||
// Add rounded corners to freeform windows
|
||||
final TypedArray ta = mContext.obtainStyledAttributes(
|
||||
new int[]{android.R.attr.dialogCornerRadius});
|
||||
final int cornerRadius = ta.getDimensionPixelSize(0, 0);
|
||||
ta.recycle();
|
||||
for (TransitionInfo.Change change: info.getChanges()) {
|
||||
if (change.getTaskInfo().getWindowingMode() == WINDOWING_MODE_FREEFORM) {
|
||||
finishTransaction.setCornerRadius(change.getLeash(), cornerRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link ContentObserver} for listening to changes to {@link Settings.System#DESKTOP_MODE}
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.wm.shell.desktopmode
|
||||
|
||||
import android.R
|
||||
import android.app.ActivityManager.RunningTaskInfo
|
||||
import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME
|
||||
import android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD
|
||||
@@ -24,6 +25,7 @@ import android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN
|
||||
import android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED
|
||||
import android.app.WindowConfiguration.WindowingMode
|
||||
import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.graphics.Point
|
||||
import android.graphics.Rect
|
||||
import android.graphics.Region
|
||||
@@ -460,6 +462,25 @@ class DesktopTasksController(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the proper surface states (rounded corners) to tasks when desktop mode is active.
|
||||
* This is intended to be used when desktop mode is part of another animation but isn't, itself,
|
||||
* animating.
|
||||
*/
|
||||
fun syncSurfaceState(
|
||||
info: TransitionInfo,
|
||||
finishTransaction: SurfaceControl.Transaction
|
||||
) {
|
||||
// Add rounded corners to freeform windows
|
||||
val ta: TypedArray = context.obtainStyledAttributes(
|
||||
intArrayOf(R.attr.dialogCornerRadius))
|
||||
val cornerRadius = ta.getDimensionPixelSize(0, 0).toFloat()
|
||||
ta.recycle()
|
||||
info.changes
|
||||
.filter { it.taskInfo.windowingMode == WINDOWING_MODE_FREEFORM }
|
||||
.forEach { finishTransaction.setCornerRadius(it.leash, cornerRadius) }
|
||||
}
|
||||
|
||||
private fun handleFreeformTaskLaunch(task: RunningTaskInfo): WindowContainerTransaction? {
|
||||
val activeTasks = desktopModeTaskRepository.getActiveTasks(task.displayId)
|
||||
if (activeTasks.none { desktopModeTaskRepository.isVisibleTask(it) }) {
|
||||
|
||||
@@ -40,6 +40,9 @@ import android.window.WindowContainerTransaction;
|
||||
import android.window.WindowContainerTransactionCallback;
|
||||
|
||||
import com.android.internal.protolog.common.ProtoLog;
|
||||
import com.android.wm.shell.desktopmode.DesktopModeController;
|
||||
import com.android.wm.shell.desktopmode.DesktopModeStatus;
|
||||
import com.android.wm.shell.desktopmode.DesktopTasksController;
|
||||
import com.android.wm.shell.keyguard.KeyguardTransitionHandler;
|
||||
import com.android.wm.shell.pip.PipTransitionController;
|
||||
import com.android.wm.shell.pip.phone.PipTouchHandler;
|
||||
@@ -65,6 +68,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
||||
private RecentsTransitionHandler mRecentsHandler;
|
||||
private StageCoordinator mSplitHandler;
|
||||
private final KeyguardTransitionHandler mKeyguardHandler;
|
||||
private DesktopModeController mDesktopModeController;
|
||||
private DesktopTasksController mDesktopTasksController;
|
||||
|
||||
private static class MixedTransition {
|
||||
static final int TYPE_ENTER_PIP_FROM_SPLIT = 1;
|
||||
@@ -81,6 +86,9 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
||||
/** Keyguard exit/occlude/unocclude transition. */
|
||||
static final int TYPE_KEYGUARD = 5;
|
||||
|
||||
/** Recents Transition while in desktop mode. */
|
||||
static final int TYPE_RECENTS_DURING_DESKTOP = 6;
|
||||
|
||||
/** The default animation for this mixed transition. */
|
||||
static final int ANIM_TYPE_DEFAULT = 0;
|
||||
|
||||
@@ -132,7 +140,9 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
||||
Optional<SplitScreenController> splitScreenControllerOptional,
|
||||
Optional<PipTouchHandler> pipTouchHandlerOptional,
|
||||
Optional<RecentsTransitionHandler> recentsHandlerOptional,
|
||||
KeyguardTransitionHandler keyguardHandler) {
|
||||
KeyguardTransitionHandler keyguardHandler,
|
||||
Optional<DesktopModeController> desktopModeControllerOptional,
|
||||
Optional<DesktopTasksController> desktopTasksControllerOptional) {
|
||||
mPlayer = player;
|
||||
mKeyguardHandler = keyguardHandler;
|
||||
if (Transitions.ENABLE_SHELL_TRANSITIONS && pipTouchHandlerOptional.isPresent()
|
||||
@@ -149,6 +159,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
||||
if (mRecentsHandler != null) {
|
||||
mRecentsHandler.addMixer(this);
|
||||
}
|
||||
mDesktopModeController = desktopModeControllerOptional.orElse(null);
|
||||
mDesktopTasksController = desktopTasksControllerOptional.orElse(null);
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
@@ -218,7 +230,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
||||
|
||||
@Override
|
||||
public Transitions.TransitionHandler handleRecentsRequest(WindowContainerTransaction outWCT) {
|
||||
if (mRecentsHandler != null && mSplitHandler.isSplitScreenVisible()) {
|
||||
if (mRecentsHandler != null && (mSplitHandler.isSplitScreenVisible()
|
||||
|| DesktopModeStatus.isActive(mPlayer.getContext()))) {
|
||||
return this;
|
||||
}
|
||||
return null;
|
||||
@@ -233,6 +246,13 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
||||
MixedTransition.TYPE_RECENTS_DURING_SPLIT, transition);
|
||||
mixed.mLeftoversHandler = mRecentsHandler;
|
||||
mActiveTransitions.add(mixed);
|
||||
} else if (DesktopModeStatus.isActive(mPlayer.getContext())) {
|
||||
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Got a recents request while "
|
||||
+ "desktop mode is active, so treat it as Mixed.");
|
||||
final MixedTransition mixed = new MixedTransition(
|
||||
MixedTransition.TYPE_RECENTS_DURING_DESKTOP, transition);
|
||||
mixed.mLeftoversHandler = mRecentsHandler;
|
||||
mActiveTransitions.add(mixed);
|
||||
} else {
|
||||
throw new IllegalStateException("Accepted a recents transition but don't know how to"
|
||||
+ " handle it");
|
||||
@@ -306,6 +326,9 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
||||
} else if (mixed.mType == MixedTransition.TYPE_KEYGUARD) {
|
||||
return animateKeyguard(mixed, info, startTransaction, finishTransaction,
|
||||
finishCallback);
|
||||
} else if (mixed.mType == MixedTransition.TYPE_RECENTS_DURING_DESKTOP) {
|
||||
return animateRecentsDuringDesktop(mixed, info, startTransaction, finishTransaction,
|
||||
finishCallback);
|
||||
} else {
|
||||
mActiveTransitions.remove(mixed);
|
||||
throw new IllegalStateException("Starting mixed animation without a known mixed type? "
|
||||
@@ -578,6 +601,30 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean animateRecentsDuringDesktop(@NonNull final MixedTransition mixed,
|
||||
@NonNull TransitionInfo info,
|
||||
@NonNull SurfaceControl.Transaction startTransaction,
|
||||
@NonNull SurfaceControl.Transaction finishTransaction,
|
||||
@NonNull Transitions.TransitionFinishCallback finishCallback) {
|
||||
boolean consumed = mRecentsHandler.startAnimation(
|
||||
mixed.mTransition, info, startTransaction, finishTransaction, finishCallback);
|
||||
if (!consumed) {
|
||||
return false;
|
||||
}
|
||||
//Sync desktop mode state (proto 1)
|
||||
if (mDesktopModeController != null) {
|
||||
mDesktopModeController.syncSurfaceState(info, finishTransaction);
|
||||
return true;
|
||||
}
|
||||
//Sync desktop mode state (proto 2)
|
||||
if (mDesktopTasksController != null) {
|
||||
mDesktopTasksController.syncSurfaceState(info, finishTransaction);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
|
||||
@NonNull SurfaceControl.Transaction t, @NonNull IBinder mergeTarget,
|
||||
@@ -621,6 +668,9 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
||||
finishCallback);
|
||||
} else if (mixed.mType == MixedTransition.TYPE_KEYGUARD) {
|
||||
mKeyguardHandler.mergeAnimation(transition, info, t, mergeTarget, finishCallback);
|
||||
} else if (mixed.mType == MixedTransition.TYPE_RECENTS_DURING_DESKTOP) {
|
||||
mixed.mLeftoversHandler.mergeAnimation(transition, info, t, mergeTarget,
|
||||
finishCallback);
|
||||
} else {
|
||||
throw new IllegalStateException("Playing a mixed transition with unknown type? "
|
||||
+ mixed.mType);
|
||||
@@ -646,6 +696,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
|
||||
mixed.mLeftoversHandler.onTransitionConsumed(transition, aborted, finishT);
|
||||
} else if (mixed.mType == MixedTransition.TYPE_KEYGUARD) {
|
||||
mKeyguardHandler.onTransitionConsumed(transition, aborted, finishT);
|
||||
} else if (mixed.mType == MixedTransition.TYPE_RECENTS_DURING_DESKTOP) {
|
||||
mixed.mLeftoversHandler.onTransitionConsumed(transition, aborted, finishT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user