Defer rotation change while running display change transition
This aligns the behavior of shell transition with legacy transition.
The rotation change will be skipped if there is a display change
transition. And then after the transition is finished, check again
if there is still a change to send.
The benefits:
1. If the new transition will cancel previous transition (current
behavior), it can avoid jump cut that the display transition
will go to the end state directly.
2. If the new transition will be queued, it may avoid unnecessary
temporal states change from preempting CPU with animation.
3. It may make some tests stabler that the sync state and async
rotation controller won't need to worry about crossing transition
if the tests request changing various rotations in a short time.
Also optimize WMS#updateRotationUnchecked a bit, which eliminates an
unnecessary surface placement if nothing is changed.
Bug: 234585256
Bug: 209920544
Test: AppConfigurationTests
Change-Id: I6a0e9ae7449dc361998e1f8066a76dd4647ae0b0
This commit is contained in:
@@ -399,9 +399,8 @@ public class DisplayRotation {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ScreenRotationAnimation screenRotationAnimation =
|
||||
mDisplayContent.getRotationAnimation();
|
||||
if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) {
|
||||
if (mDisplayContent.inTransition()
|
||||
&& !mDisplayContent.mTransitionController.useShellTransitionsRotation()) {
|
||||
// Rotation updates cannot be performed while the previous rotation change animation
|
||||
// is still in progress. Skip this update. We will try updating again after the
|
||||
// animation is finished and the display is unfrozen.
|
||||
|
||||
@@ -622,9 +622,11 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
throw new IllegalStateException("Can't finish a non-playing transition " + mSyncId);
|
||||
}
|
||||
|
||||
boolean hasParticipatedDisplay = false;
|
||||
// Commit all going-invisible containers
|
||||
for (int i = 0; i < mParticipants.size(); ++i) {
|
||||
final ActivityRecord ar = mParticipants.valueAt(i).asActivityRecord();
|
||||
final WindowContainer<?> participant = mParticipants.valueAt(i);
|
||||
final ActivityRecord ar = participant.asActivityRecord();
|
||||
if (ar != null) {
|
||||
boolean visibleAtTransitionEnd = mVisibleAtTransitionEndTokens.contains(ar);
|
||||
// We need both the expected visibility AND current requested-visibility to be
|
||||
@@ -656,8 +658,13 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
// Legacy dispatch relies on this (for now).
|
||||
ar.mEnteringAnimation = visibleAtTransitionEnd;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
final WallpaperWindowToken wt = mParticipants.valueAt(i).asWallpaperToken();
|
||||
if (participant.asDisplayContent() != null) {
|
||||
hasParticipatedDisplay = true;
|
||||
continue;
|
||||
}
|
||||
final WallpaperWindowToken wt = participant.asWallpaperToken();
|
||||
if (wt != null) {
|
||||
final boolean visibleAtTransitionEnd = mVisibleAtTransitionEndTokens.contains(wt);
|
||||
if (!visibleAtTransitionEnd && !wt.isVisibleRequested()) {
|
||||
@@ -737,6 +744,12 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
|
||||
mState = STATE_FINISHED;
|
||||
mController.mTransitionTracer.logState(this);
|
||||
// Rotation change may be deferred while there is a display change transition, so check
|
||||
// again in case there is a new pending change.
|
||||
if (hasParticipatedDisplay && !mController.useShellTransitionsRotation()) {
|
||||
mController.mAtm.mWindowManager.updateRotation(false /* alwaysSendConfiguration */,
|
||||
false /* forceRelayout */);
|
||||
}
|
||||
}
|
||||
|
||||
void abort() {
|
||||
|
||||
@@ -4290,7 +4290,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
// Even if alwaysSend, we are waiting for a transition or remote to provide
|
||||
// updated configuration, so we can't update configuration yet.
|
||||
if (!pendingRemoteDisplayChange) {
|
||||
if (!rotationChanged || forceRelayout) {
|
||||
// The layout-needed flag will be set if there is a rotation change, so
|
||||
// only set it if the caller requests to force relayout.
|
||||
if (forceRelayout) {
|
||||
displayContent.setLayoutNeeded();
|
||||
layoutNeeded = true;
|
||||
}
|
||||
|
||||
@@ -2464,6 +2464,7 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
activity.addWindow(appWindow);
|
||||
spyOn(appWindow);
|
||||
doNothing().when(appWindow).onStartFreezingScreen();
|
||||
doNothing().when(mWm).startFreezingDisplay(anyInt(), anyInt(), any(), anyInt());
|
||||
|
||||
// Set initial orientation and update.
|
||||
performRotation(displayRotation, Surface.ROTATION_90);
|
||||
@@ -2472,8 +2473,6 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
// Update the rotation to perform 180 degree rotation and check that resize was reported.
|
||||
performRotation(displayRotation, Surface.ROTATION_270);
|
||||
assertTrue(appWindow.mResizeReported);
|
||||
|
||||
appWindow.removeImmediately();
|
||||
}
|
||||
|
||||
private void performRotation(DisplayRotation spiedRotation, int rotationToReport) {
|
||||
|
||||
@@ -1820,19 +1820,18 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testRemoteRotation() {
|
||||
DisplayContent dc = createNewDisplay();
|
||||
|
||||
final DisplayContent dc = mDisplayContent;
|
||||
final DisplayRotation dr = dc.getDisplayRotation();
|
||||
doCallRealMethod().when(dr).updateRotationUnchecked(anyBoolean());
|
||||
spyOn(dr);
|
||||
// Rotate 180 degree so the display doesn't have configuration change. This condition is
|
||||
// used for the later verification of stop-freezing (without setting mWaitingForConfig).
|
||||
doReturn((dr.getRotation() + 2) % 4).when(dr).rotationForOrientation(anyInt(), anyInt());
|
||||
final boolean[] continued = new boolean[1];
|
||||
doAnswer(
|
||||
invocation -> {
|
||||
continued[0] = true;
|
||||
return true;
|
||||
}).when(dc).updateDisplayOverrideConfigurationLocked();
|
||||
doAnswer(invocation -> {
|
||||
continued[0] = true;
|
||||
mAtm.addWindowLayoutReasons(ActivityTaskManagerService.LAYOUT_REASON_CONFIG_CHANGED);
|
||||
return true;
|
||||
}).when(dc).updateDisplayOverrideConfigurationLocked();
|
||||
final boolean[] called = new boolean[1];
|
||||
mWm.mDisplayChangeController =
|
||||
new IDisplayChangeWindowController.Stub() {
|
||||
|
||||
Reference in New Issue
Block a user