Merge "Ensure to reset seamless transform after transition"

This commit is contained in:
Riddle Hsu
2023-02-13 05:46:43 +00:00
committed by Android (Google) Code Review
3 changed files with 19 additions and 27 deletions

View File

@@ -223,7 +223,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume
if (op == null) return;
if (op.mDrawTransaction != null) {
// Unblock the window to show its latest content.
mDisplayContent.getPendingTransaction().merge(op.mDrawTransaction);
windowToken.getSyncTransaction().merge(op.mDrawTransaction);
op.mDrawTransaction = null;
if (DEBUG) Slog.d(TAG, "finishOp merge transaction " + windowToken.getTopChild());
}
@@ -235,7 +235,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume
} else if (op.mAction == Operation.ACTION_SEAMLESS && mRotator != null
&& op.mLeash != null && op.mLeash.isValid()) {
if (DEBUG) Slog.d(TAG, "finishOp undo seamless " + windowToken.getTopChild());
mRotator.setIdentityMatrix(mDisplayContent.getPendingTransaction(), op.mLeash);
mRotator.setIdentityMatrix(windowToken.getSyncTransaction(), op.mLeash);
}
}
@@ -322,7 +322,8 @@ class AsyncRotationController extends FadeAnimationController implements Consume
if (mTimeoutRunnable == null) {
mTimeoutRunnable = () -> {
synchronized (mService.mGlobalLock) {
Slog.i(TAG, "Async rotation timeout: " + mTargetWindowTokens);
Slog.i(TAG, "Async rotation timeout: " + (!mIsStartTransactionCommitted
? " start transaction is not committed" : mTargetWindowTokens));
mIsStartTransactionCommitted = true;
mDisplayContent.finishAsyncRotationIfPossible();
mService.mWindowPlacerLocked.performSurfacePlacement();
@@ -484,12 +485,17 @@ class AsyncRotationController extends FadeAnimationController implements Consume
* by this controller.
*/
boolean handleFinishDrawing(WindowState w, SurfaceControl.Transaction postDrawTransaction) {
if (mTransitionOp == OP_LEGACY || postDrawTransaction == null || !mIsSyncDrawRequested) {
if (mTransitionOp == OP_LEGACY) {
return false;
}
final Operation op = mTargetWindowTokens.get(w.mToken);
if (op == null || op.canDrawBeforeStartTransaction()) return false;
if (op == null) return false;
if (DEBUG) Slog.d(TAG, "handleFinishDrawing " + w);
if (postDrawTransaction == null || !mIsSyncDrawRequested
|| op.canDrawBeforeStartTransaction()) {
mDisplayContent.finishAsyncRotation(w.mToken);
return false;
}
if (op.mDrawTransaction == null) {
if (w.isClientLocal()) {
// Use a new transaction to merge the draw transaction of local window because the

View File

@@ -2137,6 +2137,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
if (!shellTransitions) {
forAllWindows(w -> {
w.seamlesslyRotateIfAllowed(transaction, oldRotation, rotation, rotateSeamlessly);
if (!rotateSeamlessly && w.mHasSurface) {
ProtoLog.v(WM_DEBUG_ORIENTATION, "Set mOrientationChanging of %s", w);
w.setOrientationChanging(true);
}
}, true /* traverseTopToBottom */);
mPinnedTaskController.startSeamlessRotationIfNeeded(transaction, oldRotation, rotation);
if (!mDisplayRotation.hasSeamlessRotatingWindow()) {
@@ -2148,14 +2152,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
mWmService.mDisplayManagerInternal.performTraversal(transaction);
scheduleAnimation();
forAllWindows(w -> {
if (!w.mHasSurface) return;
if (!rotateSeamlessly) {
ProtoLog.v(WM_DEBUG_ORIENTATION, "Set mOrientationChanging of %s", w);
w.setOrientationChanging(true);
}
}, true /* traverseTopToBottom */);
for (int i = mWmService.mRotationWatchers.size() - 1; i >= 0; i--) {
final WindowManagerService.RotationWatcher rotationWatcher
= mWmService.mRotationWatchers.get(i);

View File

@@ -867,9 +867,6 @@ public class TransitionTests extends WindowTestsBase {
final AsyncRotationController asyncRotationController =
mDisplayContent.getAsyncRotationController();
assertNotNull(asyncRotationController);
for (WindowState w : windows) {
w.setOrientationChanging(true);
}
player.startTransition();
assertFalse(mDisplayContent.mTransitionController.isCollecting(statusBar.mToken));
@@ -879,15 +876,11 @@ public class TransitionTests extends WindowTestsBase {
assertTrue(asyncRotationController.isTargetToken(decorToken));
assertShouldFreezeInsetsPosition(asyncRotationController, statusBar, true);
if (TransitionController.SYNC_METHOD != BLASTSyncEngine.METHOD_BLAST) {
// Only seamless window syncs its draw transaction with transition.
assertFalse(asyncRotationController.handleFinishDrawing(statusBar, mMockT));
assertTrue(asyncRotationController.handleFinishDrawing(screenDecor, mMockT));
}
screenDecor.setOrientationChanging(false);
// Only seamless window syncs its draw transaction with transition.
assertTrue(asyncRotationController.handleFinishDrawing(screenDecor, mMockT));
// Status bar finishes drawing before the start transaction. Its fade-in animation will be
// executed until the transaction is committed, so it is still in target tokens.
statusBar.setOrientationChanging(false);
assertFalse(asyncRotationController.handleFinishDrawing(statusBar, mMockT));
assertTrue(asyncRotationController.isTargetToken(statusBar.mToken));
final SurfaceControl.Transaction startTransaction = mock(SurfaceControl.Transaction.class);
@@ -901,7 +894,7 @@ public class TransitionTests extends WindowTestsBase {
// Navigation bar finishes drawing after the start transaction, so its fade-in animation
// can execute directly.
navBar.setOrientationChanging(false);
asyncRotationController.handleFinishDrawing(navBar, mMockT);
assertFalse(asyncRotationController.isTargetToken(navBar.mToken));
assertNull(mDisplayContent.getAsyncRotationController());
}
@@ -935,7 +928,6 @@ public class TransitionTests extends WindowTestsBase {
assertNotNull(asyncRotationController);
assertShouldFreezeInsetsPosition(asyncRotationController, statusBar, true);
statusBar.setOrientationChanging(true);
player.startTransition();
// Non-app windows should not be collected.
assertFalse(statusBar.mToken.inTransition());
@@ -998,7 +990,6 @@ public class TransitionTests extends WindowTestsBase {
mDisplayContent.mTransitionController.dispatchLegacyAppTransitionFinished(app);
assertTrue(mDisplayContent.hasTopFixedRotationLaunchingApp());
statusBar.setOrientationChanging(true);
player.startTransition();
// Non-app windows should not be collected.
assertFalse(mDisplayContent.mTransitionController.isCollecting(statusBar.mToken));
@@ -1010,7 +1001,6 @@ public class TransitionTests extends WindowTestsBase {
// The controller should be cleared if the target windows are drawn.
statusBar.finishDrawing(mWm.mTransactionFactory.get(), Integer.MAX_VALUE);
statusBar.setOrientationChanging(false);
assertNull(mDisplayContent.getAsyncRotationController());
}