Separate split layout shifting callback from layout changed callback
So that split implementation can have a better idea about whether it should apply resizing transition or shifting transition. Bug: 201653912 Bug: 202334667 Test: manul check Test: atest WMShellUnitTests Change-Id: Ia39c15536ed3ed5851120ca9a576cc1426736d79
This commit is contained in:
@@ -232,7 +232,7 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.SplitLayou
|
||||
|
||||
if (mSplitLayout != null
|
||||
&& mSplitLayout.updateConfiguration(mRootTaskInfo.configuration)) {
|
||||
onLayoutChanged(mSplitLayout);
|
||||
onLayoutSizeChanged(mSplitLayout);
|
||||
}
|
||||
} else if (taskInfo.taskId == getTaskId1()) {
|
||||
mTaskInfo1 = taskInfo;
|
||||
@@ -313,13 +313,19 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.SplitLayou
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanging(SplitLayout layout) {
|
||||
public void onLayoutPositionChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t ->
|
||||
layout.applySurfaceChanges(t, mTaskLeash1, mTaskLeash2, mDimLayer1, mDimLayer2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanged(SplitLayout layout) {
|
||||
public void onLayoutSizeChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t ->
|
||||
layout.applySurfaceChanges(t, mTaskLeash1, mTaskLeash2, mDimLayer1, mDimLayer2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutSizeChanged(SplitLayout layout) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
layout.applyTaskChanges(wct, mTaskInfo1, mTaskInfo2);
|
||||
mSyncQueue.queue(wct);
|
||||
@@ -328,9 +334,9 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.SplitLayou
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutShifted(int offsetX, int offsetY, SplitLayout layout) {
|
||||
public void setLayoutOffsetTarget(int offsetX, int offsetY, SplitLayout layout) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
layout.applyLayoutShifted(wct, offsetX, offsetY, mTaskInfo1, mTaskInfo2);
|
||||
layout.applyLayoutOffsetTarget(wct, offsetX, offsetY, mTaskInfo1, mTaskInfo2);
|
||||
mController.getTaskOrganizer().applyTransaction(wct);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,13 +291,13 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
void updateDivideBounds(int position) {
|
||||
updateBounds(position);
|
||||
mSplitWindowManager.setResizingSplits(true);
|
||||
mSplitLayoutHandler.onLayoutChanging(this);
|
||||
mSplitLayoutHandler.onLayoutSizeChanging(this);
|
||||
}
|
||||
|
||||
void setDividePosition(int position) {
|
||||
mDividePosition = position;
|
||||
updateBounds(mDividePosition);
|
||||
mSplitLayoutHandler.onLayoutChanged(this);
|
||||
mSplitLayoutHandler.onLayoutSizeChanged(this);
|
||||
mSplitWindowManager.setResizingSplits(false);
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
* Shift configuration bounds to prevent client apps get configuration changed or relaunch. And
|
||||
* restore shifted configuration bounds if it's no longer shifted.
|
||||
*/
|
||||
public void applyLayoutShifted(WindowContainerTransaction wct, int offsetX, int offsetY,
|
||||
public void applyLayoutOffsetTarget(WindowContainerTransaction wct, int offsetX, int offsetY,
|
||||
ActivityManager.RunningTaskInfo taskInfo1, ActivityManager.RunningTaskInfo taskInfo2) {
|
||||
if (offsetX == 0 && offsetY == 0) {
|
||||
wct.setBounds(taskInfo1.token, mBounds1);
|
||||
@@ -492,19 +492,43 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
/** Calls when dismissing split. */
|
||||
void onSnappedToDismiss(boolean snappedToEnd);
|
||||
|
||||
/** Calls when the bounds is changing due to animation or dragging divider bar. */
|
||||
void onLayoutChanging(SplitLayout layout);
|
||||
|
||||
/** Calls when the target bounds changed. */
|
||||
void onLayoutChanged(SplitLayout layout);
|
||||
/**
|
||||
* Calls when resizing the split bounds.
|
||||
*
|
||||
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
||||
* SurfaceControl, SurfaceControl)
|
||||
*/
|
||||
void onLayoutSizeChanging(SplitLayout layout);
|
||||
|
||||
/**
|
||||
* Notifies when the layout shifted. So the layout handler can shift configuration
|
||||
* bounds correspondingly to make sure client apps won't get configuration changed or
|
||||
* relaunch. If the layout is no longer shifted, layout handler should restore shifted
|
||||
* configuration bounds.
|
||||
* Calls when finish resizing the split bounds.
|
||||
*
|
||||
* @see #applyTaskChanges(WindowContainerTransaction, ActivityManager.RunningTaskInfo,
|
||||
* ActivityManager.RunningTaskInfo)
|
||||
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
||||
* SurfaceControl, SurfaceControl)
|
||||
*/
|
||||
void onLayoutShifted(int offsetX, int offsetY, SplitLayout layout);
|
||||
void onLayoutSizeChanged(SplitLayout layout);
|
||||
|
||||
/**
|
||||
* Calls when re-positioning the split bounds. Like moving split bounds while showing IME
|
||||
* panel.
|
||||
*
|
||||
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
||||
* SurfaceControl, SurfaceControl)
|
||||
*/
|
||||
void onLayoutPositionChanging(SplitLayout layout);
|
||||
|
||||
/**
|
||||
* Notifies the target offset for shifting layout. So layout handler can shift configuration
|
||||
* bounds correspondingly to make sure client apps won't get configuration changed or
|
||||
* relaunched. If the layout is no longer shifted, layout handler should restore shifted
|
||||
* configuration bounds.
|
||||
*
|
||||
* @see #applyLayoutOffsetTarget(WindowContainerTransaction, int, int,
|
||||
* ActivityManager.RunningTaskInfo, ActivityManager.RunningTaskInfo)
|
||||
*/
|
||||
void setLayoutOffsetTarget(int offsetX, int offsetY, SplitLayout layout);
|
||||
|
||||
/** Calls when user double tapped on the divider bar. */
|
||||
default void onDoubleTappedDivider() {
|
||||
@@ -674,9 +698,9 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
// changed or relaunch. This is required to make sure client apps will calculate
|
||||
// insets properly after layout shifted.
|
||||
if (mTargetYOffset == 0) {
|
||||
mSplitLayoutHandler.onLayoutShifted(0, 0, SplitLayout.this);
|
||||
mSplitLayoutHandler.setLayoutOffsetTarget(0, 0, SplitLayout.this);
|
||||
} else {
|
||||
mSplitLayoutHandler.onLayoutShifted(0, mTargetYOffset - mLastYOffset,
|
||||
mSplitLayoutHandler.setLayoutOffsetTarget(0, mTargetYOffset - mLastYOffset,
|
||||
SplitLayout.this);
|
||||
}
|
||||
}
|
||||
@@ -695,7 +719,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
public void onImePositionChanged(int displayId, int imeTop, SurfaceControl.Transaction t) {
|
||||
if (displayId != mDisplayId) return;
|
||||
onProgress(getProgress(imeTop));
|
||||
mSplitLayoutHandler.onLayoutChanging(SplitLayout.this);
|
||||
mSplitLayoutHandler.onLayoutPositionChanging(SplitLayout.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -703,7 +727,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
SurfaceControl.Transaction t) {
|
||||
if (displayId != mDisplayId || cancel) return;
|
||||
onProgress(1.0f);
|
||||
mSplitLayoutHandler.onLayoutChanging(SplitLayout.this);
|
||||
mSplitLayoutHandler.onLayoutPositionChanging(SplitLayout.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -713,7 +737,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
if (!controlling && mImeShown) {
|
||||
reset();
|
||||
mSplitWindowManager.setInteractive(true);
|
||||
mSplitLayoutHandler.onLayoutChanging(SplitLayout.this);
|
||||
mSplitLayoutHandler.onLayoutPositionChanging(SplitLayout.this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -471,7 +471,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
if (mSideStageListener.mVisible && updateBounds) {
|
||||
if (wct == null) {
|
||||
// onLayoutChanged builds/applies a wct with the contents of updateWindowBounds.
|
||||
onLayoutChanged(mSplitLayout);
|
||||
onLayoutSizeChanged(mSplitLayout);
|
||||
} else {
|
||||
updateWindowBounds(mSplitLayout, wct);
|
||||
updateUnfoldBounds();
|
||||
@@ -799,13 +799,18 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanging(SplitLayout layout) {
|
||||
public void onLayoutPositionChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutSizeChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
||||
mSideStage.setOutlineVisibility(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanged(SplitLayout layout) {
|
||||
public void onLayoutSizeChanged(SplitLayout layout) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
updateWindowBounds(layout, wct);
|
||||
updateUnfoldBounds();
|
||||
@@ -859,13 +864,13 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutShifted(int offsetX, int offsetY, SplitLayout layout) {
|
||||
public void setLayoutOffsetTarget(int offsetX, int offsetY, SplitLayout layout) {
|
||||
final StageTaskListener topLeftStage =
|
||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mSideStage : mMainStage;
|
||||
final StageTaskListener bottomRightStage =
|
||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mMainStage : mSideStage;
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
layout.applyLayoutShifted(wct, offsetX, offsetY, topLeftStage.mRootTaskInfo,
|
||||
layout.applyLayoutOffsetTarget(wct, offsetX, offsetY, topLeftStage.mRootTaskInfo,
|
||||
bottomRightStage.mRootTaskInfo);
|
||||
mTaskOrganizer.applyTransaction(wct);
|
||||
}
|
||||
@@ -897,7 +902,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
if (mSplitLayout != null
|
||||
&& mSplitLayout.updateConfiguration(mDisplayAreaInfo.configuration)
|
||||
&& mMainStage.isActive()) {
|
||||
onLayoutChanged(mSplitLayout);
|
||||
onLayoutSizeChanged(mSplitLayout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -470,8 +470,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
|
||||
if (mSideStageListener.mVisible && updateBounds) {
|
||||
if (wct == null) {
|
||||
// onLayoutChanged builds/applies a wct with the contents of updateWindowBounds.
|
||||
onLayoutChanged(mSplitLayout);
|
||||
// onLayoutSizeChanged builds/applies a wct with the contents of updateWindowBounds.
|
||||
onLayoutSizeChanged(mSplitLayout);
|
||||
} else {
|
||||
updateWindowBounds(mSplitLayout, wct);
|
||||
updateUnfoldBounds();
|
||||
@@ -800,13 +800,18 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanging(SplitLayout layout) {
|
||||
public void onLayoutPositionChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutSizeChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
||||
mSideStage.setOutlineVisibility(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanged(SplitLayout layout) {
|
||||
public void onLayoutSizeChanged(SplitLayout layout) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
updateWindowBounds(layout, wct);
|
||||
updateUnfoldBounds();
|
||||
@@ -860,13 +865,13 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutShifted(int offsetX, int offsetY, SplitLayout layout) {
|
||||
public void setLayoutOffsetTarget(int offsetX, int offsetY, SplitLayout layout) {
|
||||
final StageTaskListener topLeftStage =
|
||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mSideStage : mMainStage;
|
||||
final StageTaskListener bottomRightStage =
|
||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mMainStage : mSideStage;
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
layout.applyLayoutShifted(wct, offsetX, offsetY, topLeftStage.mRootTaskInfo,
|
||||
layout.applyLayoutOffsetTarget(wct, offsetX, offsetY, topLeftStage.mRootTaskInfo,
|
||||
bottomRightStage.mRootTaskInfo);
|
||||
mTaskOrganizer.applyTransaction(wct);
|
||||
}
|
||||
@@ -898,7 +903,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
if (mSplitLayout != null
|
||||
&& mSplitLayout.updateConfiguration(mDisplayAreaInfo.configuration)
|
||||
&& mMainStage.isActive()) {
|
||||
onLayoutChanged(mSplitLayout);
|
||||
onLayoutSizeChanged(mSplitLayout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,13 +95,13 @@ public class SplitLayoutTests extends ShellTestCase {
|
||||
@Test
|
||||
public void testUpdateDivideBounds() {
|
||||
mSplitLayout.updateDivideBounds(anyInt());
|
||||
verify(mSplitLayoutHandler).onLayoutChanging(any(SplitLayout.class));
|
||||
verify(mSplitLayoutHandler).onLayoutSizeChanging(any(SplitLayout.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetDividePosition() {
|
||||
mSplitLayout.setDividePosition(anyInt());
|
||||
verify(mSplitLayoutHandler).onLayoutChanged(any(SplitLayout.class));
|
||||
verify(mSplitLayoutHandler).onLayoutSizeChanged(any(SplitLayout.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,9 +18,11 @@ package com.android.wm.shell.splitscreen;
|
||||
|
||||
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import static com.android.internal.util.FrameworkStatsLog.SPLITSCREEN_UICHANGED__EXIT_REASON__RETURN_HOME;
|
||||
import static com.android.wm.shell.common.split.SplitLayout.SPLIT_POSITION_BOTTOM_OR_RIGHT;
|
||||
import static com.android.wm.shell.common.split.SplitLayout.SPLIT_POSITION_TOP_OR_LEFT;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
@@ -130,7 +132,7 @@ public class StageCoordinatorTests extends ShellTestCase {
|
||||
mStageCoordinator.setSideStagePosition(SPLIT_POSITION_TOP_OR_LEFT, null);
|
||||
clearInvocations(mMainUnfoldController, mSideUnfoldController);
|
||||
|
||||
mStageCoordinator.onLayoutChanged(mSplitLayout);
|
||||
mStageCoordinator.onLayoutSizeChanged(mSplitLayout);
|
||||
|
||||
verify(mMainUnfoldController).onLayoutChanged(mBounds2);
|
||||
verify(mSideUnfoldController).onLayoutChanged(mBounds1);
|
||||
@@ -142,7 +144,7 @@ public class StageCoordinatorTests extends ShellTestCase {
|
||||
mStageCoordinator.setSideStagePosition(SPLIT_POSITION_BOTTOM_OR_RIGHT, null);
|
||||
clearInvocations(mMainUnfoldController, mSideUnfoldController);
|
||||
|
||||
mStageCoordinator.onLayoutChanged(mSplitLayout);
|
||||
mStageCoordinator.onLayoutSizeChanged(mSplitLayout);
|
||||
|
||||
verify(mMainUnfoldController).onLayoutChanged(mBounds1);
|
||||
verify(mSideUnfoldController).onLayoutChanged(mBounds2);
|
||||
|
||||
Reference in New Issue
Block a user