Ensure transition is ready after applying display change

Previously, the ready state of display change (e.g. rotation) relied
on TRANSACT_EFFECTS_LIFECYCLE to call resumeFocusedTasksTopActivities
that will call executeAppTransition if all activities are already
resumed. But if not, the transition will wait until timeout with
message "timed-out because not ready".

And because sendNewConfiguration already ensures configuration,
visibility of activities and requests traversal, only need to ensure
it is ready then the transition animation can start when the sync
group is finished.

Bug: 266711229
Test: atest DisplayContentTests#testShellTransitRotation
Change-Id: I9c441f97e5e0a0bf66c1fa73fae45755890ff463
This commit is contained in:
Riddle Hsu
2023-02-08 13:41:50 +00:00
parent e1c119c76a
commit 85afcfa54d
3 changed files with 7 additions and 9 deletions

View File

@@ -2010,17 +2010,15 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
return mainWin.getAttrs().rotationAnimation;
}
/** Applies the new configuration and returns {@code true} if there is a display change. */
boolean applyDisplayChangeIfNeeded() {
boolean changed = false;
/** Applies the new configuration for the changed displays. */
void applyDisplayChangeIfNeeded() {
for (int i = mParticipants.size() - 1; i >= 0; --i) {
final WindowContainer<?> wc = mParticipants.valueAt(i);
final DisplayContent dc = wc.asDisplayContent();
if (dc == null || !mChanges.get(dc).hasChanged()) continue;
dc.sendNewConfiguration();
changed = true;
setReady(dc, true);
}
return changed;
}
boolean getLegacyIsReady() {

View File

@@ -494,8 +494,8 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
mService.deferWindowLayout();
mService.mTaskSupervisor.setDeferRootVisibilityUpdate(true /* deferUpdate */);
try {
if (transition != null && transition.applyDisplayChangeIfNeeded()) {
effects |= TRANSACT_EFFECTS_LIFECYCLE;
if (transition != null) {
transition.applyDisplayChangeIfNeeded();
}
final List<WindowContainerTransaction.HierarchyOp> hops = t.getHierarchyOps();
final int hopSize = hops.size();

View File

@@ -2020,13 +2020,13 @@ public class DisplayContentTests extends WindowTestsBase {
assertEquals(origRot, dc.getConfiguration().windowConfiguration.getRotation());
// Once transition starts, rotation is applied and transition shows DC rotating.
testPlayer.start();
testPlayer.startTransition();
assertNotEquals(origRot, dc.getConfiguration().windowConfiguration.getRotation());
assertNotNull(testPlayer.mLastReady);
assertTrue(testPlayer.mController.isPlaying());
WindowContainerToken dcToken = dc.mRemoteToken.toWindowContainerToken();
assertNotEquals(testPlayer.mLastReady.getChange(dcToken).getEndRotation(),
testPlayer.mLastReady.getChange(dcToken).getStartRotation());
assertTrue(testPlayer.mLastTransit.applyDisplayChangeIfNeeded());
testPlayer.finish();
}