diff options
Diffstat (limited to 'libs')
15 files changed, 135 insertions, 49 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/TabletopModeController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/TabletopModeController.java index ac6e4c2a6521..53683c67d825 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/TabletopModeController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/TabletopModeController.java @@ -54,14 +54,6 @@ public class TabletopModeController implements DevicePostureController.OnDevicePostureChangedListener, DisplayController.OnDisplaysChangedListener { /** - * When {@code true}, floating windows like PiP would auto move to the position - * specified by {@link #PREFER_TOP_HALF_IN_TABLETOP} when in tabletop mode. - */ - private static final boolean ENABLE_MOVE_FLOATING_WINDOW_IN_TABLETOP = - SystemProperties.getBoolean( - "persist.wm.debug.enable_move_floating_window_in_tabletop", true); - - /** * Prefer the {@link #PREFERRED_TABLETOP_HALF_TOP} if this flag is enabled, * {@link #PREFERRED_TABLETOP_HALF_BOTTOM} otherwise. * See also {@link #getPreferredHalfInTabletopMode()}. @@ -162,14 +154,6 @@ public class TabletopModeController implements } } - /** - * @return {@code true} if floating windows like PiP would auto move to the position - * specified by {@link #getPreferredHalfInTabletopMode()} when in tabletop mode. - */ - public boolean enableMoveFloatingWindowInTabletop() { - return ENABLE_MOVE_FLOATING_WINDOW_IN_TABLETOP; - } - /** @return Preferred half for floating windows like PiP when in tabletop mode. */ @PreferredTabletopHalf public int getPreferredHalfInTabletopMode() { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java index 753dfa7396f8..a9ccdf6a156f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java @@ -293,6 +293,9 @@ public class SplitDecorManager extends WindowlessWindowManager { } if (mResizingIconView == null) { + if (mRunningAnimationCount == 0 && animFinishedCallback != null) { + animFinishedCallback.accept(false); + } return; } @@ -311,6 +314,9 @@ public class SplitDecorManager extends WindowlessWindowManager { releaseDecor(finishT); finishT.apply(); finishT.close(); + if (mRunningAnimationCount == 0 && animFinishedCallback != null) { + animFinishedCallback.accept(true); + } } }); return; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipMediaController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipMediaController.java index 65a12d629c5a..2590cab9ff2e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipMediaController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipMediaController.java @@ -252,13 +252,16 @@ public class PipMediaController { // It can be removed when min_sdk of the app is set to 31 or greater. @SuppressLint("NewApi") private List<RemoteAction> getMediaActions() { - if (mMediaController == null || mMediaController.getPlaybackState() == null) { + // Cache the PlaybackState since it's a Binder call. + final PlaybackState playbackState; + if (mMediaController == null + || (playbackState = mMediaController.getPlaybackState()) == null) { return Collections.emptyList(); } ArrayList<RemoteAction> mediaActions = new ArrayList<>(); - boolean isPlaying = mMediaController.getPlaybackState().isActive(); - long actions = mMediaController.getPlaybackState().getActions(); + boolean isPlaying = playbackState.isActive(); + long actions = playbackState.getActions(); // Prev action mPrevAction.setEnabled((actions & PlaybackState.ACTION_SKIP_TO_PREVIOUS) != 0); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java index bfc1fb905ade..3c7ce3c32a88 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java @@ -249,11 +249,6 @@ public class PipTransition extends PipTransitionController { finishTransaction); } - // Fade in the fadeout PIP when the fixed rotation is finished. - if (mPipTransitionState.isInPip() && !mInFixedRotation && mHasFadeOut) { - fadeExistingPip(true /* show */); - } - return false; } @@ -1056,6 +1051,12 @@ public class PipTransition extends PipTransitionController { .crop(finishTransaction, leash, destBounds) .round(finishTransaction, leash, isInPip) .shadow(finishTransaction, leash, isInPip); + // Make sure the PiP keeps invisible if it was faded out. If it needs to fade in, that will + // be handled by onFixedRotationFinished(). + if (isInPip && mHasFadeOut) { + startTransaction.setAlpha(leash, 0f); + finishTransaction.setAlpha(leash, 0f); + } } /** Hides and shows the existing PIP during fixed rotation transition of other activities. */ diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java index 63181da46b02..6a861ce97431 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java @@ -677,7 +677,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb }); mTabletopModeController.registerOnTabletopModeChangedListener((isInTabletopMode) -> { - if (!mTabletopModeController.enableMoveFloatingWindowInTabletop()) return; final String tag = "tabletop-mode"; if (!isInTabletopMode) { mPipBoundsState.removeNamedUnrestrictedKeepClearArea(tag); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java index 5c9709c756f7..f35eda6caef0 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java @@ -371,7 +371,8 @@ public class RecentTasksController implements TaskStackListenerCallback, * Find the background task that match the given component. */ @Nullable - public ActivityManager.RecentTaskInfo findTaskInBackground(ComponentName componentName) { + public ActivityManager.RecentTaskInfo findTaskInBackground(ComponentName componentName, + int userId) { if (componentName == null) { return null; } @@ -383,7 +384,7 @@ public class RecentTasksController implements TaskStackListenerCallback, if (task.isVisible) { continue; } - if (componentName.equals(task.baseIntent.getComponent())) { + if (componentName.equals(task.baseIntent.getComponent()) && userId == task.userId) { return task; } } 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 34701f1db7b7..ea33a1f1b56d 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 @@ -723,7 +723,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, // in the background with priority. final ActivityManager.RecentTaskInfo taskInfo = mRecentTasksOptional .map(recentTasks -> recentTasks.findTaskInBackground( - intent.getIntent().getComponent())) + intent.getIntent().getComponent(), userId1)) .orElse(null); if (taskInfo != null) { startTask(taskInfo.taskId, position, options); 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 14ea86a8c0e9..d2b0e2800dc9 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 @@ -87,6 +87,14 @@ class SplitScreenTransitions { mStageCoordinator = stageCoordinator; } + private void initTransition(@NonNull IBinder transition, + @NonNull SurfaceControl.Transaction finishTransaction, + @NonNull Transitions.TransitionFinishCallback finishCallback) { + mAnimatingTransition = transition; + mFinishTransaction = finishTransaction; + mFinishCallback = finishCallback; + } + /** Play animation for enter transition or dismiss transition. */ void playAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @@ -94,9 +102,7 @@ class SplitScreenTransitions { @NonNull Transitions.TransitionFinishCallback finishCallback, @NonNull WindowContainerToken mainRoot, @NonNull WindowContainerToken sideRoot, @NonNull WindowContainerToken topRoot) { - mFinishCallback = finishCallback; - mAnimatingTransition = transition; - mFinishTransaction = finishTransaction; + initTransition(transition, finishTransaction, finishCallback); final TransitSession pendingTransition = getPendingTransition(transition); if (pendingTransition != null) { @@ -220,6 +226,45 @@ class SplitScreenTransitions { onFinish(null /* wct */, null /* wctCB */); } + /** Play animation for drag divider dismiss transition. */ + void playDragDismissAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info, + @NonNull SurfaceControl.Transaction startTransaction, + @NonNull SurfaceControl.Transaction finishTransaction, + @NonNull Transitions.TransitionFinishCallback finishCallback, + @NonNull WindowContainerToken toTopRoot, @NonNull SplitDecorManager toTopDecor, + @NonNull WindowContainerToken topRoot) { + initTransition(transition, finishTransaction, finishCallback); + + for (int i = info.getChanges().size() - 1; i >= 0; --i) { + final TransitionInfo.Change change = info.getChanges().get(i); + final SurfaceControl leash = change.getLeash(); + + if (toTopRoot.equals(change.getContainer())) { + startTransaction.setAlpha(leash, 1.f); + startTransaction.show(leash); + + ValueAnimator va = new ValueAnimator(); + mAnimations.add(va); + + toTopDecor.onResized(startTransaction, animated -> { + mAnimations.remove(va); + if (animated) { + mTransitions.getMainExecutor().execute(() -> { + onFinish(null /* wct */, null /* wctCB */); + }); + } + }); + } else if (topRoot.equals(change.getContainer())) { + // Ensure it on top of all changes in transition. + startTransaction.setLayer(leash, Integer.MAX_VALUE); + startTransaction.setAlpha(leash, 1.f); + startTransaction.show(leash); + } + } + startTransaction.apply(); + onFinish(null /* wct */, null /* wctCB */); + } + /** Play animation for resize transition. */ void playResizeAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @@ -227,9 +272,7 @@ class SplitScreenTransitions { @NonNull Transitions.TransitionFinishCallback finishCallback, @NonNull WindowContainerToken mainRoot, @NonNull WindowContainerToken sideRoot, @NonNull SplitDecorManager mainDecor, @NonNull SplitDecorManager sideDecor) { - mFinishCallback = finishCallback; - mAnimatingTransition = transition; - mFinishTransaction = finishTransaction; + initTransition(transition, finishTransaction, finishCallback); for (int i = info.getChanges().size() - 1; i >= 0; --i) { final TransitionInfo.Change change = info.getChanges().get(i); 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 bf20567834e0..e0ffffffa727 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 @@ -1328,8 +1328,6 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, mIsExiting = true; childrenToTop.resetBounds(wct); wct.reorder(childrenToTop.mRootTaskInfo.token, true); - wct.setSmallestScreenWidthDp(childrenToTop.mRootTaskInfo.token, - SMALLEST_SCREEN_WIDTH_DP_UNDEFINED); } wct.setReparentLeafTaskIfRelaunch(mRootTaskInfo.token, false /* reparentLeafTaskIfRelaunch */); @@ -1517,6 +1515,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, void finishEnterSplitScreen(SurfaceControl.Transaction t) { mSplitLayout.update(t); + mMainStage.getSplitDecorManager().inflate(mContext, mMainStage.mRootLeash, + getMainStageBounds()); + mSideStage.getSplitDecorManager().inflate(mContext, mSideStage.mRootLeash, + getSideStageBounds()); setDividerVisibility(true, t); // Ensure divider surface are re-parented back into the hierarchy at the end of the // transition. See Transition#buildFinishTransaction for more detail. @@ -1989,13 +1991,15 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, final boolean mainStageToTop = bottomOrRight ? mSideStagePosition == SPLIT_POSITION_BOTTOM_OR_RIGHT : mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT; + final StageTaskListener toTopStage = mainStageToTop ? mMainStage : mSideStage; if (!ENABLE_SHELL_TRANSITIONS) { - exitSplitScreen(mainStageToTop ? mMainStage : mSideStage, reason); + exitSplitScreen(toTopStage, reason); return; } final int dismissTop = mainStageToTop ? STAGE_TYPE_MAIN : STAGE_TYPE_SIDE; final WindowContainerTransaction wct = new WindowContainerTransaction(); + toTopStage.resetBounds(wct); prepareExitSplitScreen(dismissTop, wct); if (mRootTaskInfo != null) { wct.setDoNotPip(mRootTaskInfo.token); @@ -2531,8 +2535,17 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, shouldAnimate = startPendingEnterAnimation( mSplitTransitions.mPendingEnter, info, startTransaction, finishTransaction); } else if (mSplitTransitions.isPendingDismiss(transition)) { + final SplitScreenTransitions.DismissSession dismiss = mSplitTransitions.mPendingDismiss; shouldAnimate = startPendingDismissAnimation( - mSplitTransitions.mPendingDismiss, info, startTransaction, finishTransaction); + dismiss, info, startTransaction, finishTransaction); + if (shouldAnimate && dismiss.mReason == EXIT_REASON_DRAG_DIVIDER) { + final StageTaskListener toTopStage = + dismiss.mDismissTop == STAGE_TYPE_MAIN ? mMainStage : mSideStage; + mSplitTransitions.playDragDismissAnimation(transition, info, startTransaction, + finishTransaction, finishCallback, toTopStage.mRootTaskInfo.token, + toTopStage.getSplitDecorManager(), mRootTaskInfo.token); + return true; + } } else if (mSplitTransitions.isPendingResize(transition)) { mSplitTransitions.playResizeAnimation(transition, info, startTransaction, finishTransaction, finishCallback, mMainStage.mRootTaskInfo.token, @@ -2787,6 +2800,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, mSplitTransitions.mPendingDismiss = null; return false; } + dismissTransition.setFinishedCallback((callbackWct, callbackT) -> { + mMainStage.getSplitDecorManager().release(callbackT); + mSideStage.getSplitDecorManager().release(callbackT); + }); addDividerBarToTransition(info, false /* show */); return true; 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 e2e9270cd6cc..da7d18641a97 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 @@ -19,6 +19,7 @@ package com.android.wm.shell.splitscreen; import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; +import static android.content.res.Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED; import static android.view.RemoteAnimationTarget.MODE_OPENING; import static com.android.wm.shell.common.split.SplitScreenConstants.CONTROLLED_ACTIVITY_TYPES; @@ -201,7 +202,7 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener { public void onTaskInfoChanged(ActivityManager.RunningTaskInfo taskInfo) { if (mRootTaskInfo.taskId == taskInfo.taskId) { // Inflates split decor view only when the root task is visible. - if (mRootTaskInfo.isVisible != taskInfo.isVisible) { + if (!ENABLE_SHELL_TRANSITIONS && mRootTaskInfo.isVisible != taskInfo.isVisible) { if (taskInfo.isVisible) { mSplitDecorManager.inflate(mContext, mRootLeash, taskInfo.configuration.windowConfiguration.getBounds()); @@ -385,6 +386,7 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener { void resetBounds(WindowContainerTransaction wct) { wct.setBounds(mRootTaskInfo.token, null); wct.setAppBounds(mRootTaskInfo.token, null); + wct.setSmallestScreenWidthDp(mRootTaskInfo.token, SMALLEST_SCREEN_WIDTH_DP_UNDEFINED); } void onSplitScreenListenerRegistered(SplitScreen.SplitScreenListener listener, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java index d16b497b5aca..3b306e793640 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java @@ -191,6 +191,12 @@ public class Transitions implements RemoteCallable<Transitions>, */ private static final int SYNC_ALLOWANCE_MS = 120; + /** + * Keyguard gets a more generous timeout to finish its animations, because we are always holding + * a sleep token during occlude/unocclude transitions and we want them to finish playing cleanly + */ + private static final int SYNC_ALLOWANCE_KEYGUARD_MS = 2000; + /** For testing only. Disables the force-finish timeout on sync. */ private boolean mDisableForceSync = false; @@ -673,7 +679,7 @@ public class Transitions implements RemoteCallable<Transitions>, // Sleep starts a process of forcing all prior transitions to finish immediately ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "Start finish-for-sync track %d", i); - finishForSync(i, null /* forceFinish */); + finishForSync(active, i, null /* forceFinish */); } if (hadPreceding) { return false; @@ -1021,6 +1027,9 @@ public class Transitions implements RemoteCallable<Transitions>, for (int i = 0; i < mPendingTransitions.size(); ++i) { if (mPendingTransitions.get(i).mToken == token) return true; } + for (int i = 0; i < mReadyDuringSync.size(); ++i) { + if (mReadyDuringSync.get(i).mToken == token) return true; + } for (int t = 0; t < mTracks.size(); ++t) { final Track tr = mTracks.get(t); for (int i = 0; i < tr.mReadyTransitions.size(); ++i) { @@ -1107,10 +1116,17 @@ public class Transitions implements RemoteCallable<Transitions>, * * This is then repeated until there are no more pending sleep transitions. * + * @param reason The SLEEP transition that triggered this round of finishes. We will continue + * looping round finishing transitions as long as this is still waiting. * @param forceFinish When non-null, this is the transition that we last sent the SLEEP merge * signal to -- so it will be force-finished if it's still running. */ - private void finishForSync(int trackIdx, @Nullable ActiveTransition forceFinish) { + private void finishForSync(ActiveTransition reason, + int trackIdx, @Nullable ActiveTransition forceFinish) { + if (!isTransitionKnown(reason.mToken)) { + Log.d(TAG, "finishForSleep: already played sync transition " + reason); + return; + } final Track track = mTracks.get(trackIdx); if (forceFinish != null) { final Track trk = mTracks.get(forceFinish.getTrack()); @@ -1154,8 +1170,11 @@ public class Transitions implements RemoteCallable<Transitions>, if (track.mActiveTransition == playing) { if (!mDisableForceSync) { // Give it a short amount of time to process it before forcing. - mMainExecutor.executeDelayed(() -> finishForSync(trackIdx, playing), - SYNC_ALLOWANCE_MS); + final int tolerance = KeyguardTransitionHandler.handles(playing.mInfo) + ? SYNC_ALLOWANCE_KEYGUARD_MS + : SYNC_ALLOWANCE_MS; + mMainExecutor.executeDelayed( + () -> finishForSync(reason, trackIdx, playing), tolerance); } break; } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java index 9189d3dd0327..fb17d8799bda 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java @@ -223,7 +223,7 @@ public class SplitScreenControllerTests extends ShellTestCase { doReturn(topRunningTask).when(mRecentTasks).getTopRunningTask(); // Put the same component into a task in the background ActivityManager.RecentTaskInfo sameTaskInfo = new ActivityManager.RecentTaskInfo(); - doReturn(sameTaskInfo).when(mRecentTasks).findTaskInBackground(any()); + doReturn(sameTaskInfo).when(mRecentTasks).findTaskInBackground(any(), anyInt()); mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, SPLIT_POSITION_TOP_OR_LEFT, null); @@ -247,7 +247,7 @@ public class SplitScreenControllerTests extends ShellTestCase { SPLIT_POSITION_BOTTOM_OR_RIGHT); // Put the same component into a task in the background doReturn(new ActivityManager.RecentTaskInfo()).when(mRecentTasks) - .findTaskInBackground(any()); + .findTaskInBackground(any(), anyInt()); mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, SPLIT_POSITION_TOP_OR_LEFT, null); diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTestUtils.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTestUtils.java index ae69b3ddd042..4e446c684d86 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTestUtils.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTestUtils.java @@ -44,11 +44,15 @@ public class SplitTestUtils { static SplitLayout createMockSplitLayout() { final Rect dividerBounds = new Rect(48, 0, 52, 100); + final Rect bounds1 = new Rect(0, 0, 40, 100); + final Rect bounds2 = new Rect(60, 0, 100, 100); final SurfaceControl leash = createMockSurface(); SplitLayout out = mock(SplitLayout.class); doReturn(dividerBounds).when(out).getDividerBounds(); doReturn(dividerBounds).when(out).getRefDividerBounds(); doReturn(leash).when(out).getDividerLeash(); + doReturn(bounds1).when(out).getBounds1(); + doReturn(bounds2).when(out).getBounds2(); return out; } 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 80384531e9ae..60c0e5535568 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 @@ -42,6 +42,7 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import android.annotation.NonNull; import android.app.ActivityManager; @@ -72,6 +73,7 @@ import com.android.wm.shell.common.DisplayInsetsController; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.common.TransactionPool; +import com.android.wm.shell.common.split.SplitDecorManager; import com.android.wm.shell.common.split.SplitLayout; import com.android.wm.shell.transition.Transitions; @@ -117,13 +119,13 @@ public class SplitTransitionTests extends ShellTestCase { doReturn(mockExecutor).when(mTransitions).getAnimExecutor(); doReturn(mock(SurfaceControl.Transaction.class)).when(mTransactionPool).acquire(); mSplitLayout = SplitTestUtils.createMockSplitLayout(); - mMainStage = new MainStage(mContext, mTaskOrganizer, DEFAULT_DISPLAY, mock( + mMainStage = spy(new MainStage(mContext, mTaskOrganizer, DEFAULT_DISPLAY, mock( StageTaskListener.StageListenerCallbacks.class), mSyncQueue, mSurfaceSession, - mIconProvider); + mIconProvider)); mMainStage.onTaskAppeared(new TestRunningTaskInfoBuilder().build(), createMockSurface()); - mSideStage = new SideStage(mContext, mTaskOrganizer, DEFAULT_DISPLAY, mock( + mSideStage = spy(new SideStage(mContext, mTaskOrganizer, DEFAULT_DISPLAY, mock( StageTaskListener.StageListenerCallbacks.class), mSyncQueue, mSurfaceSession, - mIconProvider); + mIconProvider)); mSideStage.onTaskAppeared(new TestRunningTaskInfoBuilder().build(), createMockSurface()); mStageCoordinator = new SplitTestUtils.TestStageCoordinator(mContext, DEFAULT_DISPLAY, mSyncQueue, mTaskOrganizer, mMainStage, mSideStage, mDisplayController, @@ -137,6 +139,8 @@ public class SplitTransitionTests extends ShellTestCase { .setParentTaskId(mMainStage.mRootTaskInfo.taskId).build(); mSideChild = new TestRunningTaskInfoBuilder() .setParentTaskId(mSideStage.mRootTaskInfo.taskId).build(); + doReturn(mock(SplitDecorManager.class)).when(mMainStage).getSplitDecorManager(); + doReturn(mock(SplitDecorManager.class)).when(mSideStage).getSplitDecorManager(); } @Test diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java index 6621ab8ce0d8..66b6c62f1dd6 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java @@ -68,6 +68,7 @@ import com.android.wm.shell.common.DisplayInsetsController; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.common.TransactionPool; +import com.android.wm.shell.common.split.SplitDecorManager; import com.android.wm.shell.common.split.SplitLayout; import com.android.wm.shell.splitscreen.SplitScreen.SplitScreenListener; import com.android.wm.shell.sysui.ShellController; @@ -145,6 +146,8 @@ public class StageCoordinatorTests extends ShellTestCase { mSideStage.mRootTaskInfo = new TestRunningTaskInfoBuilder().build(); mMainStage.mRootTaskInfo = new TestRunningTaskInfoBuilder().build(); + doReturn(mock(SplitDecorManager.class)).when(mMainStage).getSplitDecorManager(); + doReturn(mock(SplitDecorManager.class)).when(mSideStage).getSplitDecorManager(); } @Test |