Merge "Revert "Fix pip update transaction out of order"" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2899ff81c2
@@ -23,7 +23,6 @@ import static android.view.WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
|
|||||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
|
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityManager.RunningTaskInfo;
|
import android.app.ActivityManager.RunningTaskInfo;
|
||||||
import android.app.RemoteAction;
|
import android.app.RemoteAction;
|
||||||
@@ -70,11 +69,6 @@ public interface PipMenuController {
|
|||||||
*/
|
*/
|
||||||
void setAppActions(List<RemoteAction> appActions, RemoteAction closeAction);
|
void setAppActions(List<RemoteAction> appActions, RemoteAction closeAction);
|
||||||
|
|
||||||
/**
|
|
||||||
* Wait until the next frame to run the given Runnable.
|
|
||||||
*/
|
|
||||||
void runWithNextFrame(@NonNull Runnable runnable);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize the PiP menu with the given bounds. The PiP SurfaceControl is given if there is a
|
* Resize the PiP menu with the given bounds. The PiP SurfaceControl is given if there is a
|
||||||
* need to synchronize the movements on the same frame as PiP.
|
* need to synchronize the movements on the same frame as PiP.
|
||||||
|
|||||||
@@ -179,10 +179,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
// 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
|
||||||
// started, in which case the first resize will be skipped to let the exit
|
// started, in which case the first resize will be skipped to let the exit
|
||||||
// operation handle the final resize out of PIP mode. See b/185306679.
|
// operation handle the final resize out of PIP mode. See b/185306679.
|
||||||
finishResizeDelayedIfNeeded(() -> {
|
|
||||||
finishResize(tx, destinationBounds, direction, animationType);
|
finishResize(tx, destinationBounds, direction, animationType);
|
||||||
sendOnPipTransitionFinished(direction);
|
sendOnPipTransitionFinished(direction);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,34 +196,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Finishes resizing the PiP, delaying the operation if it has to be synced with the PiP menu.
|
|
||||||
*
|
|
||||||
* This is done to avoid a race condition between the last transaction applied in
|
|
||||||
* onAnimationUpdate and the finishResize in onAnimationEnd. finishResize creates a
|
|
||||||
* WindowContainerTransaction, which is to be applied by WmCore later. It may happen that it
|
|
||||||
* gets applied before the transaction created by the last onAnimationUpdate. As a result of
|
|
||||||
* this, the PiP surface may get scaled after the new bounds are applied by WmCore, which
|
|
||||||
* makes the PiP surface have unexpected bounds. To avoid this, we delay the finishResize
|
|
||||||
* operation until the next frame. This aligns the last onAnimationUpdate transaction with the
|
|
||||||
* WCT application.
|
|
||||||
*
|
|
||||||
* The race only happens when the PiP surface transaction has to be synced with the PiP menu
|
|
||||||
* due to the necessity for a delay when syncing the PiP surface, the PiP menu surface and
|
|
||||||
* the PiP menu contents.
|
|
||||||
*/
|
|
||||||
private void finishResizeDelayedIfNeeded(Runnable finishResizeRunnable) {
|
|
||||||
if (!shouldSyncPipTransactionWithMenu()) {
|
|
||||||
finishResizeRunnable.run();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mPipMenuController.runWithNextFrame(finishResizeRunnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean shouldSyncPipTransactionWithMenu() {
|
|
||||||
return mPipMenuController.isMenuVisible();
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final PipTransitionController.PipTransitionCallback mPipTransitionCallback =
|
final PipTransitionController.PipTransitionCallback mPipTransitionCallback =
|
||||||
new PipTransitionController.PipTransitionCallback() {
|
new PipTransitionController.PipTransitionCallback() {
|
||||||
@@ -251,7 +221,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
@Override
|
@Override
|
||||||
public boolean handlePipTransaction(SurfaceControl leash,
|
public boolean handlePipTransaction(SurfaceControl leash,
|
||||||
SurfaceControl.Transaction tx, Rect destinationBounds) {
|
SurfaceControl.Transaction tx, Rect destinationBounds) {
|
||||||
if (shouldSyncPipTransactionWithMenu()) {
|
if (mPipMenuController.isMenuVisible()) {
|
||||||
mPipMenuController.movePipMenu(leash, tx, destinationBounds);
|
mPipMenuController.movePipMenu(leash, tx, destinationBounds);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1253,7 +1223,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
mSurfaceTransactionHelper
|
mSurfaceTransactionHelper
|
||||||
.crop(tx, mLeash, toBounds)
|
.crop(tx, mLeash, toBounds)
|
||||||
.round(tx, mLeash, mPipTransitionState.isInPip());
|
.round(tx, mLeash, mPipTransitionState.isInPip());
|
||||||
if (shouldSyncPipTransactionWithMenu()) {
|
if (mPipMenuController.isMenuVisible()) {
|
||||||
mPipMenuController.resizePipMenu(mLeash, tx, toBounds);
|
mPipMenuController.resizePipMenu(mLeash, tx, toBounds);
|
||||||
} else {
|
} else {
|
||||||
tx.apply();
|
tx.apply();
|
||||||
@@ -1295,7 +1265,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
mSurfaceTransactionHelper
|
mSurfaceTransactionHelper
|
||||||
.scale(tx, mLeash, startBounds, toBounds, degrees)
|
.scale(tx, mLeash, startBounds, toBounds, degrees)
|
||||||
.round(tx, mLeash, startBounds, toBounds);
|
.round(tx, mLeash, startBounds, toBounds);
|
||||||
if (shouldSyncPipTransactionWithMenu()) {
|
if (mPipMenuController.isMenuVisible()) {
|
||||||
mPipMenuController.movePipMenu(mLeash, tx, toBounds);
|
mPipMenuController.movePipMenu(mLeash, tx, toBounds);
|
||||||
} else {
|
} else {
|
||||||
tx.apply();
|
tx.apply();
|
||||||
|
|||||||
@@ -305,18 +305,6 @@ public class PhonePipMenuController implements PipMenuController {
|
|||||||
showResizeHandle);
|
showResizeHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void runWithNextFrame(Runnable runnable) {
|
|
||||||
if (mPipMenuView == null || mPipMenuView.getViewRootImpl() == null) {
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
mPipMenuView.getViewRootImpl().registerRtFrameCallback(frame -> {
|
|
||||||
mMainHandler.post(runnable);
|
|
||||||
});
|
|
||||||
mPipMenuView.invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the PiP menu, which does a translation and possibly a scale transformation.
|
* Move the PiP menu, which does a translation and possibly a scale transformation.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -465,18 +465,6 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
|
|||||||
return mSystemWindows.getViewSurface(v);
|
return mSystemWindows.getViewSurface(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void runWithNextFrame(Runnable runnable) {
|
|
||||||
if (mPipMenuView == null || mPipMenuView.getViewRootImpl() == null) {
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
mPipMenuView.getViewRootImpl().registerRtFrameCallback(frame -> {
|
|
||||||
mMainHandler.post(runnable);
|
|
||||||
});
|
|
||||||
mPipMenuView.invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void movePipMenu(SurfaceControl pipLeash, SurfaceControl.Transaction transaction,
|
public void movePipMenu(SurfaceControl pipLeash, SurfaceControl.Transaction transaction,
|
||||||
Rect pipDestBounds) {
|
Rect pipDestBounds) {
|
||||||
|
|||||||
Reference in New Issue
Block a user