Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +6 −17 Original line number Original line Diff line number Diff line Loading @@ -72,7 +72,6 @@ import android.window.TaskOrganizer; import android.window.TaskSnapshot; import android.window.TaskSnapshot; import android.window.WindowContainerToken; import android.window.WindowContainerToken; import android.window.WindowContainerTransaction; import android.window.WindowContainerTransaction; import android.window.WindowContainerTransactionCallback; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.protolog.common.ProtoLog; import com.android.internal.protolog.common.ProtoLog; Loading Loading @@ -139,17 +138,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, // the runnable to execute after WindowContainerTransactions is applied to finish resizing pip // the runnable to execute after WindowContainerTransactions is applied to finish resizing pip private Runnable mPipFinishResizeWCTRunnable; 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 maybePerformFinishResizeCallback(); } }; private void maybePerformFinishResizeCallback() { private void maybePerformFinishResizeCallback() { if (mPipFinishResizeWCTRunnable != null) { if (mPipFinishResizeWCTRunnable != null) { mPipFinishResizeWCTRunnable.run(); mPipFinishResizeWCTRunnable.run(); Loading @@ -175,6 +163,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, final int direction = animator.getTransitionDirection(); final int direction = animator.getTransitionDirection(); if (mIsCancelled) { if (mIsCancelled) { sendOnPipTransitionFinished(direction); sendOnPipTransitionFinished(direction); maybePerformFinishResizeCallback(); return; return; } } final int animationType = animator.getAnimationType(); final int animationType = animator.getAnimationType(); Loading @@ -199,6 +188,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, || isRemovePipDirection(direction); || isRemovePipDirection(direction); if (mPipTransitionState.getTransitionState() != PipTransitionState.EXITING_PIP if (mPipTransitionState.getTransitionState() != PipTransitionState.EXITING_PIP || isExitPipDirection) { || isExitPipDirection) { // execute the finish resize callback if needed after the transaction is committed tx.addTransactionCommittedListener(mMainExecutor, PipTaskOrganizer.this::maybePerformFinishResizeCallback); // Finish resize as long as we're not exiting PIP, or, if we are, only if this is // Finish resize as long as we're not exiting PIP, or, if we are, only if this is // the end of an exit PIP animation. // the end of an exit PIP animation. // This is necessary in case there was a resize animation ongoing when exit PIP // This is necessary in case there was a resize animation ongoing when exit PIP Loading Loading @@ -1614,12 +1607,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, if (direction == TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN) { if (direction == TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN) { mSplitScreenOptional.ifPresent(splitScreenController -> mSplitScreenOptional.ifPresent(splitScreenController -> splitScreenController.enterSplitScreen(mTaskInfo.taskId, wasPipTopLeft, wct)); splitScreenController.enterSplitScreen(mTaskInfo.taskId, wasPipTopLeft, wct)); } else if (direction == TRANSITION_DIRECTION_LEAVE_PIP) { // when leaving PiP we can call the callback without sync maybePerformFinishResizeCallback(); mTaskOrganizer.applyTransaction(wct); } else { } else { mTaskOrganizer.applySyncTransaction(wct, mPipFinishResizeWCTCallback); mTaskOrganizer.applyTransaction(wct); } } } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +10 −4 Original line number Original line Diff line number Diff line Loading @@ -104,6 +104,7 @@ public class PipResizeGestureHandler { private boolean mAllowGesture; private boolean mAllowGesture; private boolean mIsAttached; private boolean mIsAttached; private boolean mIsEnabled; private boolean mIsEnabled; private boolean mEnableTouch; private boolean mEnablePinchResize; private boolean mEnablePinchResize; private boolean mEnableDragCornerResize; private boolean mEnableDragCornerResize; private boolean mIsSysUiStateValid; private boolean mIsSysUiStateValid; Loading Loading @@ -138,6 +139,7 @@ public class PipResizeGestureHandler { mPhonePipMenuController = menuActivityController; mPhonePipMenuController = menuActivityController; mPipUiEventLogger = pipUiEventLogger; mPipUiEventLogger = pipUiEventLogger; mPinchResizingAlgorithm = new PipPinchResizingAlgorithm(); mPinchResizingAlgorithm = new PipPinchResizingAlgorithm(); mEnableTouch = true; mUpdateResizeBoundsCallback = (rect) -> { mUpdateResizeBoundsCallback = (rect) -> { mUserResizeBounds.set(rect); mUserResizeBounds.set(rect); Loading Loading @@ -248,6 +250,11 @@ public class PipResizeGestureHandler { return; return; } } if (!mEnableTouch) { // No need to handle anything if touches are not enabled for resizing. return; } // Don't allow resize when PiP is stashed. // Don't allow resize when PiP is stashed. if (mPipBoundsState.isStashed()) { if (mPipBoundsState.isStashed()) { return; return; Loading Loading @@ -581,14 +588,13 @@ public class PipResizeGestureHandler { mLastResizeBounds, movementBounds); mLastResizeBounds, movementBounds); mPipBoundsAlgorithm.applySnapFraction(mLastResizeBounds, snapFraction); mPipBoundsAlgorithm.applySnapFraction(mLastResizeBounds, snapFraction); // disable the pinch resizing until the final bounds are updated // disable the resizing until the final bounds are updated final boolean prevEnablePinchResize = mEnablePinchResize; mEnableTouch = false; mEnablePinchResize = false; mPipTaskOrganizer.scheduleAnimateResizePip(startBounds, mLastResizeBounds, mPipTaskOrganizer.scheduleAnimateResizePip(startBounds, mLastResizeBounds, PINCH_RESIZE_SNAP_DURATION, mAngle, mUpdateResizeBoundsCallback, () -> { PINCH_RESIZE_SNAP_DURATION, mAngle, mUpdateResizeBoundsCallback, () -> { // reset the pinch resizing to its default state // reset the pinch resizing to its default state mEnablePinchResize = prevEnablePinchResize; mEnableTouch = true; }); }); } else { } else { mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +6 −17 Original line number Original line Diff line number Diff line Loading @@ -72,7 +72,6 @@ import android.window.TaskOrganizer; import android.window.TaskSnapshot; import android.window.TaskSnapshot; import android.window.WindowContainerToken; import android.window.WindowContainerToken; import android.window.WindowContainerTransaction; import android.window.WindowContainerTransaction; import android.window.WindowContainerTransactionCallback; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.protolog.common.ProtoLog; import com.android.internal.protolog.common.ProtoLog; Loading Loading @@ -139,17 +138,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, // the runnable to execute after WindowContainerTransactions is applied to finish resizing pip // the runnable to execute after WindowContainerTransactions is applied to finish resizing pip private Runnable mPipFinishResizeWCTRunnable; 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 maybePerformFinishResizeCallback(); } }; private void maybePerformFinishResizeCallback() { private void maybePerformFinishResizeCallback() { if (mPipFinishResizeWCTRunnable != null) { if (mPipFinishResizeWCTRunnable != null) { mPipFinishResizeWCTRunnable.run(); mPipFinishResizeWCTRunnable.run(); Loading @@ -175,6 +163,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, final int direction = animator.getTransitionDirection(); final int direction = animator.getTransitionDirection(); if (mIsCancelled) { if (mIsCancelled) { sendOnPipTransitionFinished(direction); sendOnPipTransitionFinished(direction); maybePerformFinishResizeCallback(); return; return; } } final int animationType = animator.getAnimationType(); final int animationType = animator.getAnimationType(); Loading @@ -199,6 +188,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, || isRemovePipDirection(direction); || isRemovePipDirection(direction); if (mPipTransitionState.getTransitionState() != PipTransitionState.EXITING_PIP if (mPipTransitionState.getTransitionState() != PipTransitionState.EXITING_PIP || isExitPipDirection) { || isExitPipDirection) { // execute the finish resize callback if needed after the transaction is committed tx.addTransactionCommittedListener(mMainExecutor, PipTaskOrganizer.this::maybePerformFinishResizeCallback); // Finish resize as long as we're not exiting PIP, or, if we are, only if this is // Finish resize as long as we're not exiting PIP, or, if we are, only if this is // the end of an exit PIP animation. // the end of an exit PIP animation. // This is necessary in case there was a resize animation ongoing when exit PIP // This is necessary in case there was a resize animation ongoing when exit PIP Loading Loading @@ -1614,12 +1607,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, if (direction == TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN) { if (direction == TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN) { mSplitScreenOptional.ifPresent(splitScreenController -> mSplitScreenOptional.ifPresent(splitScreenController -> splitScreenController.enterSplitScreen(mTaskInfo.taskId, wasPipTopLeft, wct)); splitScreenController.enterSplitScreen(mTaskInfo.taskId, wasPipTopLeft, wct)); } else if (direction == TRANSITION_DIRECTION_LEAVE_PIP) { // when leaving PiP we can call the callback without sync maybePerformFinishResizeCallback(); mTaskOrganizer.applyTransaction(wct); } else { } else { mTaskOrganizer.applySyncTransaction(wct, mPipFinishResizeWCTCallback); mTaskOrganizer.applyTransaction(wct); } } } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +10 −4 Original line number Original line Diff line number Diff line Loading @@ -104,6 +104,7 @@ public class PipResizeGestureHandler { private boolean mAllowGesture; private boolean mAllowGesture; private boolean mIsAttached; private boolean mIsAttached; private boolean mIsEnabled; private boolean mIsEnabled; private boolean mEnableTouch; private boolean mEnablePinchResize; private boolean mEnablePinchResize; private boolean mEnableDragCornerResize; private boolean mEnableDragCornerResize; private boolean mIsSysUiStateValid; private boolean mIsSysUiStateValid; Loading Loading @@ -138,6 +139,7 @@ public class PipResizeGestureHandler { mPhonePipMenuController = menuActivityController; mPhonePipMenuController = menuActivityController; mPipUiEventLogger = pipUiEventLogger; mPipUiEventLogger = pipUiEventLogger; mPinchResizingAlgorithm = new PipPinchResizingAlgorithm(); mPinchResizingAlgorithm = new PipPinchResizingAlgorithm(); mEnableTouch = true; mUpdateResizeBoundsCallback = (rect) -> { mUpdateResizeBoundsCallback = (rect) -> { mUserResizeBounds.set(rect); mUserResizeBounds.set(rect); Loading Loading @@ -248,6 +250,11 @@ public class PipResizeGestureHandler { return; return; } } if (!mEnableTouch) { // No need to handle anything if touches are not enabled for resizing. return; } // Don't allow resize when PiP is stashed. // Don't allow resize when PiP is stashed. if (mPipBoundsState.isStashed()) { if (mPipBoundsState.isStashed()) { return; return; Loading Loading @@ -581,14 +588,13 @@ public class PipResizeGestureHandler { mLastResizeBounds, movementBounds); mLastResizeBounds, movementBounds); mPipBoundsAlgorithm.applySnapFraction(mLastResizeBounds, snapFraction); mPipBoundsAlgorithm.applySnapFraction(mLastResizeBounds, snapFraction); // disable the pinch resizing until the final bounds are updated // disable the resizing until the final bounds are updated final boolean prevEnablePinchResize = mEnablePinchResize; mEnableTouch = false; mEnablePinchResize = false; mPipTaskOrganizer.scheduleAnimateResizePip(startBounds, mLastResizeBounds, mPipTaskOrganizer.scheduleAnimateResizePip(startBounds, mLastResizeBounds, PINCH_RESIZE_SNAP_DURATION, mAngle, mUpdateResizeBoundsCallback, () -> { PINCH_RESIZE_SNAP_DURATION, mAngle, mUpdateResizeBoundsCallback, () -> { // reset the pinch resizing to its default state // reset the pinch resizing to its default state mEnablePinchResize = prevEnablePinchResize; mEnableTouch = true; }); }); } else { } else { mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, Loading