Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +34 −1 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ import android.window.TaskOrganizer; import android.window.TaskSnapshot; import android.window.WindowContainerToken; import android.window.WindowContainerTransaction; import android.window.WindowContainerTransactionCallback; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.protolog.common.ProtoLog; Loading Loading @@ -144,6 +145,23 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, protected final ShellTaskOrganizer mTaskOrganizer; protected final ShellExecutor mMainExecutor; // the runnable to execute after WindowContainerTransactions is applied to finish resizing pip private Runnable mPipFinishResizeWCTRunnable; private final WindowContainerTransactionCallback mPipFinishResizeWCTCallback = new WindowContainerTransactionCallback() { @Override public void onTransactionReady(int id, SurfaceControl.Transaction t) { t.apply(); // execute the runnable if non-null after WCT is applied to finish resizing pip if (mPipFinishResizeWCTRunnable != null) { mPipFinishResizeWCTRunnable.run(); mPipFinishResizeWCTRunnable = null; } } }; // These callbacks are called on the update thread private final PipAnimationController.PipAnimationCallback mPipAnimationCallback = new PipAnimationController.PipAnimationCallback() { Loading Loading @@ -1251,8 +1269,23 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, /** * Animates resizing of the pinned stack given the duration and start bounds. * This is used when the starting bounds is not the current PiP bounds. * * @param pipFinishResizeWCTRunnable callback to run after window updates are complete */ public void scheduleAnimateResizePip(Rect fromBounds, Rect toBounds, int duration, float startingAngle, Consumer<Rect> updateBoundsCallback, Runnable pipFinishResizeWCTRunnable) { mPipFinishResizeWCTRunnable = pipFinishResizeWCTRunnable; if (mPipFinishResizeWCTRunnable != null) { ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "mPipFinishResizeWCTRunnable is set to be called once window updates"); } scheduleAnimateResizePip(fromBounds, toBounds, duration, startingAngle, updateBoundsCallback); } private void scheduleAnimateResizePip(Rect fromBounds, Rect toBounds, int duration, float startingAngle, Consumer<Rect> updateBoundsCallback) { if (mWaitForFixedRotation) { ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, Loading Loading @@ -1557,7 +1590,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, mSplitScreenOptional.ifPresent(splitScreenController -> splitScreenController.enterSplitScreen(mTaskInfo.taskId, wasPipTopLeft, wct)); } else { mTaskOrganizer.applyTransaction(wct); mTaskOrganizer.applySyncTransaction(wct, mPipFinishResizeWCTCallback); } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +9 −1 Original line number Diff line number Diff line Loading @@ -580,8 +580,16 @@ public class PipResizeGestureHandler { final float snapFraction = mPipBoundsAlgorithm.getSnapFraction( mLastResizeBounds, movementBounds); mPipBoundsAlgorithm.applySnapFraction(mLastResizeBounds, snapFraction); // disable the pinch resizing until the final bounds are updated final boolean prevEnablePinchResize = mEnablePinchResize; mEnablePinchResize = false; mPipTaskOrganizer.scheduleAnimateResizePip(startBounds, mLastResizeBounds, PINCH_RESIZE_SNAP_DURATION, mAngle, mUpdateResizeBoundsCallback); PINCH_RESIZE_SNAP_DURATION, mAngle, mUpdateResizeBoundsCallback, () -> { // reset the pinch resizing to its default state mEnablePinchResize = prevEnablePinchResize; }); } else { mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, PipAnimationController.TRANSITION_DIRECTION_USER_RESIZE, Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipResizeGestureHandlerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -155,7 +155,7 @@ public class PipResizeGestureHandlerTest extends ShellTestCase { mPipResizeGestureHandler.onPinchResize(upEvent); verify(mPipTaskOrganizer, times(1)) .scheduleAnimateResizePip(any(), any(), anyInt(), anyFloat(), any()); .scheduleAnimateResizePip(any(), any(), anyInt(), anyFloat(), any(), any()); assertTrue("The new size should be bigger than the original PiP size.", mPipResizeGestureHandler.getLastResizeBounds().width() Loading Loading @@ -194,7 +194,7 @@ public class PipResizeGestureHandlerTest extends ShellTestCase { mPipResizeGestureHandler.onPinchResize(upEvent); verify(mPipTaskOrganizer, times(1)) .scheduleAnimateResizePip(any(), any(), anyInt(), anyFloat(), any()); .scheduleAnimateResizePip(any(), any(), anyInt(), anyFloat(), any(), any()); assertTrue("The new size should be smaller than the original PiP size.", mPipResizeGestureHandler.getLastResizeBounds().width() Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +34 −1 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ import android.window.TaskOrganizer; import android.window.TaskSnapshot; import android.window.WindowContainerToken; import android.window.WindowContainerTransaction; import android.window.WindowContainerTransactionCallback; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.protolog.common.ProtoLog; Loading Loading @@ -144,6 +145,23 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, protected final ShellTaskOrganizer mTaskOrganizer; protected final ShellExecutor mMainExecutor; // the runnable to execute after WindowContainerTransactions is applied to finish resizing pip private Runnable mPipFinishResizeWCTRunnable; private final WindowContainerTransactionCallback mPipFinishResizeWCTCallback = new WindowContainerTransactionCallback() { @Override public void onTransactionReady(int id, SurfaceControl.Transaction t) { t.apply(); // execute the runnable if non-null after WCT is applied to finish resizing pip if (mPipFinishResizeWCTRunnable != null) { mPipFinishResizeWCTRunnable.run(); mPipFinishResizeWCTRunnable = null; } } }; // These callbacks are called on the update thread private final PipAnimationController.PipAnimationCallback mPipAnimationCallback = new PipAnimationController.PipAnimationCallback() { Loading Loading @@ -1251,8 +1269,23 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, /** * Animates resizing of the pinned stack given the duration and start bounds. * This is used when the starting bounds is not the current PiP bounds. * * @param pipFinishResizeWCTRunnable callback to run after window updates are complete */ public void scheduleAnimateResizePip(Rect fromBounds, Rect toBounds, int duration, float startingAngle, Consumer<Rect> updateBoundsCallback, Runnable pipFinishResizeWCTRunnable) { mPipFinishResizeWCTRunnable = pipFinishResizeWCTRunnable; if (mPipFinishResizeWCTRunnable != null) { ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "mPipFinishResizeWCTRunnable is set to be called once window updates"); } scheduleAnimateResizePip(fromBounds, toBounds, duration, startingAngle, updateBoundsCallback); } private void scheduleAnimateResizePip(Rect fromBounds, Rect toBounds, int duration, float startingAngle, Consumer<Rect> updateBoundsCallback) { if (mWaitForFixedRotation) { ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, Loading Loading @@ -1557,7 +1590,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, mSplitScreenOptional.ifPresent(splitScreenController -> splitScreenController.enterSplitScreen(mTaskInfo.taskId, wasPipTopLeft, wct)); } else { mTaskOrganizer.applyTransaction(wct); mTaskOrganizer.applySyncTransaction(wct, mPipFinishResizeWCTCallback); } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +9 −1 Original line number Diff line number Diff line Loading @@ -580,8 +580,16 @@ public class PipResizeGestureHandler { final float snapFraction = mPipBoundsAlgorithm.getSnapFraction( mLastResizeBounds, movementBounds); mPipBoundsAlgorithm.applySnapFraction(mLastResizeBounds, snapFraction); // disable the pinch resizing until the final bounds are updated final boolean prevEnablePinchResize = mEnablePinchResize; mEnablePinchResize = false; mPipTaskOrganizer.scheduleAnimateResizePip(startBounds, mLastResizeBounds, PINCH_RESIZE_SNAP_DURATION, mAngle, mUpdateResizeBoundsCallback); PINCH_RESIZE_SNAP_DURATION, mAngle, mUpdateResizeBoundsCallback, () -> { // reset the pinch resizing to its default state mEnablePinchResize = prevEnablePinchResize; }); } else { mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, PipAnimationController.TRANSITION_DIRECTION_USER_RESIZE, Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipResizeGestureHandlerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -155,7 +155,7 @@ public class PipResizeGestureHandlerTest extends ShellTestCase { mPipResizeGestureHandler.onPinchResize(upEvent); verify(mPipTaskOrganizer, times(1)) .scheduleAnimateResizePip(any(), any(), anyInt(), anyFloat(), any()); .scheduleAnimateResizePip(any(), any(), anyInt(), anyFloat(), any(), any()); assertTrue("The new size should be bigger than the original PiP size.", mPipResizeGestureHandler.getLastResizeBounds().width() Loading Loading @@ -194,7 +194,7 @@ public class PipResizeGestureHandlerTest extends ShellTestCase { mPipResizeGestureHandler.onPinchResize(upEvent); verify(mPipTaskOrganizer, times(1)) .scheduleAnimateResizePip(any(), any(), anyInt(), anyFloat(), any()); .scheduleAnimateResizePip(any(), any(), anyInt(), anyFloat(), any(), any()); assertTrue("The new size should be smaller than the original PiP size.", mPipResizeGestureHandler.getLastResizeBounds().width() Loading