diff options
Diffstat (limited to 'libs')
18 files changed, 121 insertions, 121 deletions
diff --git a/libs/WindowManager/Shell/res/layout/letterbox_restart_dialog_layout.xml b/libs/WindowManager/Shell/res/layout/letterbox_restart_dialog_layout.xml index 5aff4159e135..7f1aac3551b6 100644 --- a/libs/WindowManager/Shell/res/layout/letterbox_restart_dialog_layout.xml +++ b/libs/WindowManager/Shell/res/layout/letterbox_restart_dialog_layout.xml @@ -73,11 +73,13 @@ android:textAlignment="center"/> <LinearLayout + android:id="@+id/letterbox_restart_dialog_checkbox_container" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingVertical="14dp" android:orientation="horizontal" android:layout_gravity="center_vertical" - android:layout_marginVertical="32dp"> + android:layout_marginVertical="18dp"> <CheckBox android:id="@+id/letterbox_restart_dialog_checkbox" diff --git a/libs/WindowManager/Shell/res/values/config.xml b/libs/WindowManager/Shell/res/values/config.xml index 76eb0945d990..a3916b71592b 100644 --- a/libs/WindowManager/Shell/res/values/config.xml +++ b/libs/WindowManager/Shell/res/values/config.xml @@ -125,4 +125,7 @@ <!-- Whether the additional education about reachability is enabled --> <bool name="config_letterboxIsReachabilityEducationEnabled">false</bool> + + <!-- Whether DragAndDrop capability is enabled --> + <bool name="config_enableShellDragDrop">true</bool> </resources> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 21f02b10035b..3eb9fa2eef6b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -260,7 +260,7 @@ public class BubbleController implements ConfigurationChangeListener, /** One handed mode controller to register transition listener. */ private Optional<OneHandedController> mOneHandedOptional; /** Drag and drop controller to register listener for onDragStarted. */ - private DragAndDropController mDragAndDropController; + private Optional<DragAndDropController> mDragAndDropController; /** Used to send bubble events to launcher. */ private Bubbles.BubbleStateListener mBubbleStateListener; @@ -286,7 +286,7 @@ public class BubbleController implements ConfigurationChangeListener, BubblePositioner positioner, DisplayController displayController, Optional<OneHandedController> oneHandedOptional, - DragAndDropController dragAndDropController, + Optional<DragAndDropController> dragAndDropController, @ShellMainThread ShellExecutor mainExecutor, @ShellMainThread Handler mainHandler, @ShellBackgroundThread ShellExecutor bgExecutor, @@ -469,7 +469,7 @@ public class BubbleController implements ConfigurationChangeListener, }); mOneHandedOptional.ifPresent(this::registerOneHandedState); - mDragAndDropController.addListener(this::collapseStack); + mDragAndDropController.ifPresent(controller -> controller.addListener(this::collapseStack)); // Clear out any persisted bubbles on disk that no longer have a valid user. List<UserInfo> users = mUserManager.getAliveUsers(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java index 9eba5ecd36f1..e7dede757578 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java @@ -738,10 +738,6 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange getRefBounds2(mTempRect); t.setPosition(leash2, mTempRect.left, mTempRect.top) .setWindowCrop(leash2, mTempRect.width(), mTempRect.height()); - // Make right or bottom side surface always higher than left or top side to avoid weird - // animation when dismiss split. e.g. App surface fling above on decor surface. - t.setLayer(leash1, 1); - t.setLayer(leash2, 2); if (mImePositionProcessor.adjustSurfaceLayoutForIme( t, dividerLeash, leash1, leash2, dimLayer1, dimLayer2)) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/RestartDialogLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/RestartDialogLayout.java index c53e6389331a..05fd5f1172e1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/RestartDialogLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/RestartDialogLayout.java @@ -95,6 +95,9 @@ public class RestartDialogLayout extends ConstraintLayout implements DialogConta @Override protected void onFinishInflate() { super.onFinishInflate(); + final View checkboxContainer = findViewById( + R.id.letterbox_restart_dialog_checkbox_container); + final CheckBox checkbox = findViewById(R.id.letterbox_restart_dialog_checkbox); mDialogContainer = findViewById(R.id.letterbox_restart_dialog_container); mDialogTitle = findViewById(R.id.letterbox_restart_dialog_title); mBackgroundDim = getBackground().mutate(); @@ -103,5 +106,6 @@ public class RestartDialogLayout extends ConstraintLayout implements DialogConta // We add a no-op on-click listener to the dialog container so that clicks on it won't // propagate to the listener of the layout (which represents the background dim). mDialogContainer.setOnClickListener(view -> {}); + checkboxContainer.setOnClickListener(view -> checkbox.performClick()); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvWMShellModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvWMShellModule.java index e9957fd4f4f1..12d51f54a09c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvWMShellModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/TvWMShellModule.java @@ -41,11 +41,11 @@ import com.android.wm.shell.sysui.ShellController; import com.android.wm.shell.sysui.ShellInit; import com.android.wm.shell.transition.Transitions; -import java.util.Optional; - import dagger.Module; import dagger.Provides; +import java.util.Optional; + /** * Provides dependencies from {@link com.android.wm.shell}, these dependencies are only * accessible from components within the WM subcomponent (can be explicitly exposed to the @@ -81,7 +81,7 @@ public class TvWMShellModule { DisplayController displayController, DisplayImeController displayImeController, DisplayInsetsController displayInsetsController, - DragAndDropController dragAndDropController, + Optional<DragAndDropController> dragAndDropController, Transitions transitions, TransactionPool transactionPool, IconProvider iconProvider, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java index 9808c591592f..36d941bda663 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java @@ -186,15 +186,15 @@ public abstract class WMShellBaseModule { @WMSingleton @Provides - static DragAndDropController provideDragAndDropController(Context context, + static Optional<DragAndDropController> provideDragAndDropController(Context context, ShellInit shellInit, ShellController shellController, DisplayController displayController, UiEventLogger uiEventLogger, IconProvider iconProvider, @ShellMainThread ShellExecutor mainExecutor) { - return new DragAndDropController(context, shellInit, shellController, displayController, - uiEventLogger, iconProvider, mainExecutor); + return Optional.ofNullable(DragAndDropController.create(context, shellInit, shellController, + displayController, uiEventLogger, iconProvider, mainExecutor)); } @WMSingleton @@ -796,7 +796,7 @@ public abstract class WMShellBaseModule { DisplayController displayController, DisplayImeController displayImeController, DisplayInsetsController displayInsetsController, - DragAndDropController dragAndDropController, + Optional<DragAndDropController> dragAndDropControllerOptional, ShellTaskOrganizer shellTaskOrganizer, Optional<BubbleController> bubblesOptional, Optional<SplitScreenController> splitScreenOptional, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java index 2f0f56cfdfb0..f3130d358ec1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java @@ -171,7 +171,7 @@ public abstract class WMShellModule { BubblePositioner positioner, DisplayController displayController, @DynamicOverride Optional<OneHandedController> oneHandedOptional, - DragAndDropController dragAndDropController, + Optional<DragAndDropController> dragAndDropController, @ShellMainThread ShellExecutor mainExecutor, @ShellMainThread Handler mainHandler, @ShellBackgroundThread ShellExecutor bgExecutor, @@ -320,7 +320,7 @@ public abstract class WMShellModule { DisplayController displayController, DisplayImeController displayImeController, DisplayInsetsController displayInsetsController, - DragAndDropController dragAndDropController, + Optional<DragAndDropController> dragAndDropController, Transitions transitions, TransactionPool transactionPool, IconProvider iconProvider, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java index 4cfaae6e51c7..091de3a86461 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java @@ -94,7 +94,24 @@ public class DragAndDropController implements DisplayController.OnDisplaysChange void onDragStarted(); } - public DragAndDropController(Context context, + /** + * Creates {@link DragAndDropController}. Returns {@code null} if the feature is disabled. + */ + public static DragAndDropController create(Context context, + ShellInit shellInit, + ShellController shellController, + DisplayController displayController, + UiEventLogger uiEventLogger, + IconProvider iconProvider, + ShellExecutor mainExecutor) { + if (!context.getResources().getBoolean(R.bool.config_enableShellDragDrop)) { + return null; + } + return new DragAndDropController(context, shellInit, shellController, displayController, + uiEventLogger, iconProvider, mainExecutor); + } + + DragAndDropController(Context context, ShellInit shellInit, ShellController shellController, DisplayController displayController, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java index eb4d2a16c522..bffc51c6b22f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java @@ -549,6 +549,14 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler { // are in mOpening. for (int i = 0; i < closingTasks.size(); ++i) { final TransitionInfo.Change change = closingTasks.get(i); + final int pausingIdx = TaskState.indexOf(mPausingTasks, change); + if (pausingIdx >= 0) { + mPausingTasks.remove(pausingIdx); + didMergeThings = true; + ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION, + " closing pausing taskId=%d", change.getTaskInfo().taskId); + continue; + } int openingIdx = TaskState.indexOf(mOpeningTasks, change); if (openingIdx < 0) { Slog.w(TAG, "Closing a task that wasn't opening, this may be split or" @@ -601,6 +609,11 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler { didMergeThings = true; mState = STATE_NEW_TASK; } + if (mPausingTasks.isEmpty()) { + // The pausing tasks may be removed by the incoming closing tasks. + ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION, + "[%d] RecentsController.merge: empty pausing tasks", mInstanceId); + } if (!hasTaskChange) { // Activity only transition, so consume the merge as it doesn't affect the rest of // recents. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java index 643245943916..af52350f5b48 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java @@ -165,7 +165,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, private final DisplayController mDisplayController; private final DisplayImeController mDisplayImeController; private final DisplayInsetsController mDisplayInsetsController; - private final DragAndDropController mDragAndDropController; + private final Optional<DragAndDropController> mDragAndDropController; private final Transitions mTransitions; private final TransactionPool mTransactionPool; private final IconProvider mIconProvider; @@ -191,7 +191,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, DisplayController displayController, DisplayImeController displayImeController, DisplayInsetsController displayInsetsController, - DragAndDropController dragAndDropController, + Optional<DragAndDropController> dragAndDropController, Transitions transitions, TransactionPool transactionPool, IconProvider iconProvider, @@ -253,7 +253,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, mDisplayController = displayController; mDisplayImeController = displayImeController; mDisplayInsetsController = displayInsetsController; - mDragAndDropController = dragAndDropController; + mDragAndDropController = Optional.of(dragAndDropController); mTransitions = transitions; mTransactionPool = transactionPool; mIconProvider = iconProvider; @@ -289,7 +289,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, // TODO: Multi-display mStageCoordinator = createStageCoordinator(); } - mDragAndDropController.setSplitScreenController(this); + mDragAndDropController.ifPresent(controller -> controller.setSplitScreenController(this)); } protected StageCoordinator createStageCoordinator() { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java index 51b8000f14bb..a2af93fc42c6 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java @@ -30,8 +30,6 @@ import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON import static com.android.wm.shell.splitscreen.SplitScreenController.exitReasonToString; import static com.android.wm.shell.transition.Transitions.TRANSIT_SPLIT_DISMISS; import static com.android.wm.shell.transition.Transitions.TRANSIT_SPLIT_DISMISS_SNAP; -import static com.android.wm.shell.transition.Transitions.TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE; -import static com.android.wm.shell.transition.Transitions.TRANSIT_SPLIT_SCREEN_PAIR_OPEN; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -165,7 +163,7 @@ class SplitScreenTransitions { t.setLayer(leash, Integer.MAX_VALUE); t.show(leash); } - boolean isOpening = isOpeningTransition(info); + boolean isOpening = TransitionUtil.isOpeningType(info.getType()); if (isOpening && (mode == TRANSIT_OPEN || mode == TRANSIT_TO_FRONT)) { // fade in startExampleAnimation(leash, true /* show */); @@ -295,14 +293,16 @@ class SplitScreenTransitions { @Nullable RemoteTransition remoteTransition, Transitions.TransitionHandler handler, @Nullable TransitionConsumedCallback consumedCallback, - @Nullable TransitionFinishedCallback finishedCallback) { + @Nullable TransitionFinishedCallback finishedCallback, + int extraTransitType) { if (mPendingEnter != null) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " splitTransition " + " skip to start enter split transition since it already exist. "); return null; } final IBinder transition = mTransitions.startTransition(transitType, wct, handler); - setEnterTransition(transition, remoteTransition, consumedCallback, finishedCallback); + setEnterTransition(transition, remoteTransition, consumedCallback, finishedCallback, + extraTransitType); return transition; } @@ -310,9 +310,10 @@ class SplitScreenTransitions { void setEnterTransition(@NonNull IBinder transition, @Nullable RemoteTransition remoteTransition, @Nullable TransitionConsumedCallback consumedCallback, - @Nullable TransitionFinishedCallback finishedCallback) { + @Nullable TransitionFinishedCallback finishedCallback, + int extraTransitType) { mPendingEnter = new TransitSession( - transition, consumedCallback, finishedCallback, remoteTransition); + transition, consumedCallback, finishedCallback, remoteTransition, extraTransitType); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " splitTransition " + " deduced Enter split screen"); @@ -513,12 +514,6 @@ class SplitScreenTransitions { mTransitions.getAnimExecutor().execute(va::start); } - private boolean isOpeningTransition(TransitionInfo info) { - return TransitionUtil.isOpeningType(info.getType()) - || info.getType() == TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE - || info.getType() == TRANSIT_SPLIT_SCREEN_PAIR_OPEN; - } - /** Calls when the transition got consumed. */ interface TransitionConsumedCallback { void onConsumed(boolean aborted); @@ -539,16 +534,19 @@ class SplitScreenTransitions { /** Whether the transition was canceled. */ boolean mCanceled; + /** A note for extra transit type, to help indicate custom transition. */ + final int mExtraTransitType; + TransitSession(IBinder transition, @Nullable TransitionConsumedCallback consumedCallback, @Nullable TransitionFinishedCallback finishedCallback) { - this(transition, consumedCallback, finishedCallback, null /* remoteTransition */); + this(transition, consumedCallback, finishedCallback, null /* remoteTransition */, 0); } TransitSession(IBinder transition, @Nullable TransitionConsumedCallback consumedCallback, @Nullable TransitionFinishedCallback finishedCallback, - @Nullable RemoteTransition remoteTransition) { + @Nullable RemoteTransition remoteTransition, int extraTransitType) { mTransition = transition; mConsumedCallback = consumedCallback; mFinishedCallback = finishedCallback; @@ -560,6 +558,7 @@ class SplitScreenTransitions { mTransitions.getMainExecutor(), remoteTransition); mRemoteHandler.setTransition(transition); } + mExtraTransitType = extraTransitType; } /** Sets transition consumed callback. */ diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java index 4c903f500651..0ef26fcff284 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java @@ -446,26 +446,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps, final IRemoteAnimationFinishedCallback finishedCallback) { - boolean openingToSide = false; - if (apps != null) { - for (int i = 0; i < apps.length; ++i) { - if (apps[i].mode == MODE_OPENING - && mSideStage.containsTask(apps[i].taskId)) { - openingToSide = true; - break; - } - } - } else if (mSideStage.getChildCount() != 0) { - // There are chances the entering app transition got canceled by performing - // rotation transition. Checks if there is any child task existed in split - // screen before fallback to cancel entering flow. - openingToSide = true; - } - - if (isEnteringSplit && !openingToSide) { + if (isEnteringSplit && mSideStage.getChildCount() == 0) { mMainExecutor.execute(() -> exitSplitScreen( - mSideStage.getChildCount() == 0 ? mMainStage : mSideStage, - EXIT_REASON_UNKNOWN)); + null /* childrenToTop */, EXIT_REASON_UNKNOWN)); + mSplitUnsupportedToast.show(); } if (finishedCallback != null) { @@ -526,17 +510,17 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, wct.sendPendingIntent(intent, fillInIntent, options); // If split screen is not activated, we're expecting to open a pair of apps to split. - final int transitType = mMainStage.isActive() + final int extraTransitType = mMainStage.isActive() ? TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE : TRANSIT_SPLIT_SCREEN_PAIR_OPEN; prepareEnterSplitScreen(wct, null /* taskInfo */, position); - mSplitTransitions.startEnterTransition(transitType, wct, null, this, + mSplitTransitions.startEnterTransition(TRANSIT_TO_FRONT, wct, null, this, null /* consumedCallback */, (finishWct, finishT) -> { if (!evictWct.isEmpty()) { finishWct.merge(evictWct, true); } - } /* finishedCallback */); + } /* finishedCallback */, extraTransitType); } /** Launches an activity into split by legacy transition. */ @@ -550,26 +534,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps, IRemoteAnimationFinishedCallback finishedCallback, SurfaceControl.Transaction t) { - boolean openingToSide = false; - if (apps != null) { - for (int i = 0; i < apps.length; ++i) { - if (apps[i].mode == MODE_OPENING - && mSideStage.containsTask(apps[i].taskId)) { - openingToSide = true; - break; - } - } - } else if (mSideStage.getChildCount() != 0) { - // There are chances the entering app transition got canceled by performing - // rotation transition. Checks if there is any child task existed in split - // screen before fallback to cancel entering flow. - openingToSide = true; - } - - if (isEnteringSplit && !openingToSide && apps != null) { + if (isEnteringSplit && mSideStage.getChildCount() == 0) { mMainExecutor.execute(() -> exitSplitScreen( - mSideStage.getChildCount() == 0 ? mMainStage : mSideStage, - EXIT_REASON_UNKNOWN)); + null /* childrenToTop */, EXIT_REASON_UNKNOWN)); + mSplitUnsupportedToast.show(); } if (apps != null) { @@ -709,7 +677,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, wct.startTask(mainTaskId, mainOptions); mSplitTransitions.startEnterTransition( - TRANSIT_SPLIT_SCREEN_PAIR_OPEN, wct, remoteTransition, this, null, null); + TRANSIT_TO_FRONT, wct, remoteTransition, this, null, null, + TRANSIT_SPLIT_SCREEN_PAIR_OPEN); setEnterInstanceId(instanceId); } @@ -760,7 +729,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } mSplitTransitions.startEnterTransition( - TRANSIT_SPLIT_SCREEN_PAIR_OPEN, wct, remoteTransition, this, null, null); + TRANSIT_TO_FRONT, wct, remoteTransition, this, null, null, + TRANSIT_SPLIT_SCREEN_PAIR_OPEN); setEnterInstanceId(instanceId); } @@ -1088,7 +1058,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, private void onRemoteAnimationFinishedOrCancelled(WindowContainerTransaction evictWct) { mIsDividerRemoteAnimating = false; mShouldUpdateRecents = true; - mSplitRequest = null; + clearRequestIfPresented(); // If any stage has no child after animation finished, it means that split will display // nothing, such status will happen if task and intent is same app but not support // multi-instance, we should exit split and expand that app as full screen. @@ -1108,7 +1078,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, private void onRemoteAnimationFinished(RemoteAnimationTarget[] apps) { mIsDividerRemoteAnimating = false; mShouldUpdateRecents = true; - mSplitRequest = null; + clearRequestIfPresented(); // If any stage has no child after finished animation, that side of the split will display // nothing. This might happen if starting the same app on the both sides while not // supporting multi-instance. Exit the split screen and expand that app to full screen. @@ -1381,6 +1351,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, }); mShouldUpdateRecents = false; mIsDividerRemoteAnimating = false; + mSplitRequest = null; mSplitLayout.getInvisibleBounds(mTempRect1); if (childrenToTop == null || childrenToTop.getTopVisibleChildTaskId() == INVALID_TASK_ID) { @@ -1473,6 +1444,13 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } } + private void clearRequestIfPresented() { + if (mSideStageListener.mVisible && mSideStageListener.mHasChildren + && mMainStageListener.mVisible && mSideStageListener.mHasChildren) { + mSplitRequest = null; + } + } + /** * Returns whether the split pair in the recent tasks list should be broken. */ @@ -1851,6 +1829,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, true /* setReparentLeafTaskIfRelaunch */); setRootForceTranslucent(true, wct); } else { + clearRequestIfPresented(); wct.setReparentLeafTaskIfRelaunch(mRootTaskInfo.token, false /* setReparentLeafTaskIfRelaunch */); setRootForceTranslucent(false, wct); @@ -2010,7 +1989,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } if (mMainStageListener.mHasChildren && mSideStageListener.mHasChildren) { mShouldUpdateRecents = true; - mSplitRequest = null; + clearRequestIfPresented(); updateRecentTasksSplitPair(); if (!mLogger.hasStartedSession()) { @@ -2334,7 +2313,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, out = new WindowContainerTransaction(); prepareEnterSplitScreen(out); mSplitTransitions.setEnterTransition(transition, request.getRemoteTransition(), - null /* consumedCallback */, null /* finishedCallback */); + null /* consumedCallback */, null /* finishedCallback */, + 0 /* extraTransitType */); } } return out; @@ -2573,7 +2553,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } } - if (info.getType() == TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE) { + if (mSplitTransitions.mPendingEnter.mExtraTransitType + == TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE) { if (mainChild == null && sideChild == null) { Log.w(TAG, "Launched a task in split, but didn't receive any task in transition."); mSplitTransitions.mPendingEnter.cancel(null /* finishedCb */); @@ -2716,6 +2697,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } }); mShouldUpdateRecents = false; + mSplitRequest = null; // Update local states. setSplitsVisible(false); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java index ead0bcd15c73..a841b7f96d3c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java @@ -220,20 +220,12 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener { mCallbacks.onNoLongerSupportMultiWindow(); return; } - if (taskInfo.topActivity == null && mChildrenTaskInfo.contains(taskInfo.taskId) - && mChildrenTaskInfo.get(taskInfo.taskId).topActivity != null) { - // If top activity become null, it means the task is about to vanish, we use this - // signal to remove it from children list earlier for smooth dismiss transition. - mChildrenTaskInfo.remove(taskInfo.taskId); - mChildrenLeashes.remove(taskInfo.taskId); - } else { - mChildrenTaskInfo.put(taskInfo.taskId, taskInfo); - } + mChildrenTaskInfo.put(taskInfo.taskId, taskInfo); mCallbacks.onChildTaskStatusChanged(taskInfo.taskId, true /* present */, taskInfo.isVisible); - if (!ENABLE_SHELL_TRANSITIONS && mChildrenLeashes.contains(taskInfo.taskId)) { - updateChildTaskSurface(taskInfo, mChildrenLeashes.get(taskInfo.taskId), - false /* firstAppeared */); + if (!ENABLE_SHELL_TRANSITIONS) { + updateChildTaskSurface( + taskInfo, mChildrenLeashes.get(taskInfo.taskId), false /* firstAppeared */); } } else { throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo @@ -267,6 +259,9 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener { return; } sendStatusChanged(); + } else { + throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo + + "\n mRootTaskInfo: " + mRootTaskInfo); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/tv/TvSplitScreenController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/tv/TvSplitScreenController.java index 46d2a5a11671..27d520d81c41 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/tv/TvSplitScreenController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/tv/TvSplitScreenController.java @@ -72,7 +72,7 @@ public class TvSplitScreenController extends SplitScreenController { DisplayController displayController, DisplayImeController displayImeController, DisplayInsetsController displayInsetsController, - DragAndDropController dragAndDropController, + Optional<DragAndDropController> dragAndDropController, Transitions transitions, TransactionPool transactionPool, IconProvider iconProvider, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java index 362d91ac5b5e..b1c3791ad15a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java @@ -74,14 +74,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin new WindowDecoration.RelayoutResult<>(); private final Point mPositionInParent = new Point(); - private final PointF mHandleMenuAppInfoPillPosition = new PointF(); - private final PointF mHandleMenuWindowingPillPosition = new PointF(); - private final PointF mHandleMenuMoreActionsPillPosition = new PointF(); - - // Collection of additional windows that comprise the handle menu. - private AdditionalWindow mHandleMenuAppInfoPill; - private AdditionalWindow mHandleMenuWindowingPill; - private AdditionalWindow mHandleMenuMoreActionsPill; private HandleMenu mHandleMenu; private ResizeVeil mResizeVeil; @@ -91,16 +83,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin private TaskCornersListener mCornersListener; - private int mMenuWidth; - private int mMarginMenuTop; - private int mMarginMenuStart; - private int mMarginMenuSpacing; - private int mAppInfoPillHeight; - private int mWindowingPillHeight; - private int mMoreActionsPillHeight; - private int mShadowRadius; - private int mMenuCornerRadius; - DesktopModeWindowDecoration( Context context, DisplayController displayController, diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java index a9f311f9e9eb..92cbf7f068b4 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java @@ -180,8 +180,9 @@ public class SplitTransitionTests extends ShellTestCase { TestRemoteTransition testRemote = new TestRemoteTransition(); IBinder transition = mSplitScreenTransitions.startEnterTransition( - TRANSIT_SPLIT_SCREEN_PAIR_OPEN, new WindowContainerTransaction(), - new RemoteTransition(testRemote, "Test"), mStageCoordinator, null, null); + TRANSIT_OPEN, new WindowContainerTransaction(), + new RemoteTransition(testRemote, "Test"), mStageCoordinator, null, null, + TRANSIT_SPLIT_SCREEN_PAIR_OPEN); mMainStage.onTaskAppeared(mMainChild, createMockSurface()); mSideStage.onTaskAppeared(mSideChild, createMockSurface()); boolean accepted = mStageCoordinator.startAnimation(transition, info, @@ -397,7 +398,7 @@ public class SplitTransitionTests extends ShellTestCase { } private TransitionInfo createEnterPairInfo() { - return new TransitionInfoBuilder(TRANSIT_SPLIT_SCREEN_PAIR_OPEN, 0) + return new TransitionInfoBuilder(TRANSIT_OPEN, 0) .addChange(TRANSIT_OPEN, mMainChild) .addChange(TRANSIT_OPEN, mSideChild) .build(); @@ -406,9 +407,9 @@ public class SplitTransitionTests extends ShellTestCase { private void enterSplit() { TransitionInfo enterInfo = createEnterPairInfo(); IBinder enterTransit = mSplitScreenTransitions.startEnterTransition( - TRANSIT_SPLIT_SCREEN_PAIR_OPEN, new WindowContainerTransaction(), + TRANSIT_OPEN, new WindowContainerTransaction(), new RemoteTransition(new TestRemoteTransition(), "Test"), - mStageCoordinator, null, null); + mStageCoordinator, null, null, TRANSIT_SPLIT_SCREEN_PAIR_OPEN); mMainStage.onTaskAppeared(mMainChild, createMockSurface()); mSideStage.onTaskAppeared(mSideChild, createMockSurface()); mStageCoordinator.startAnimation(enterTransit, enterInfo, diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java index 784ad9b006b6..1a1bebd28aef 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java @@ -126,6 +126,12 @@ public final class StageTaskListenerTests extends ShellTestCase { verify(mCallbacks).onStatusChanged(eq(mRootTask.isVisible), eq(true)); } + @Test(expected = IllegalArgumentException.class) + public void testUnknownTaskVanished() { + final ActivityManager.RunningTaskInfo task = new TestRunningTaskInfoBuilder().build(); + mStageTaskListener.onTaskVanished(task); + } + @Test public void testTaskVanished() { // With shell transitions, the transition manages status changes, so skip this test. |