Update APP_TRANSITION_STATE for Shell transition

Before, when we have transition collecting or queueing, the app
transition state may be IDLE, with which some flicker/cts tests may not
wait until the previous action is finished.

Fix: 216074588
Test: pass existing
Change-Id: Ibfc91397cbf70500c16cf594d6a265c65df24ad9
This commit is contained in:
Chris Li
2022-01-27 17:27:32 +08:00
parent 11f0f946fc
commit 7934a69c3a
2 changed files with 10 additions and 2 deletions

View File

@@ -1328,7 +1328,7 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
}
boolean getLegacyIsReady() {
return mState == STATE_STARTED && mSyncId >= 0 && mSyncEngine.isReady(mSyncId);
return (mState == STATE_STARTED || mState == STATE_COLLECTING) && mSyncId >= 0;
}
static Transition fromBinder(IBinder binder) {

View File

@@ -94,6 +94,9 @@ class TransitionController {
// TODO(b/188595497): remove when not needed.
final StatusBarManagerInternal mStatusBar;
/** Pending transitions from Shell that are waiting the SyncEngine to be free. */
private final ArrayList<PendingStartTransition> mPendingTransitions = new ArrayList<>();
TransitionController(ActivityTaskManagerService atm,
TaskSnapshotController taskSnapshotController) {
mAtm = atm;
@@ -160,9 +163,11 @@ class TransitionController {
}
final PendingStartTransition out = new PendingStartTransition(new Transition(type,
0 /* flags */, this, mAtm.mWindowManager.mSyncEngine));
mPendingTransitions.add(out);
// We want to start collecting immediately when the engine is free, otherwise it may
// be busy again.
out.setStartSync(() -> {
mPendingTransitions.remove(out);
moveToCollecting(out.mTransition);
});
ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS, "Creating PendingTransition: %s",
@@ -530,7 +535,10 @@ class TransitionController {
int state = LEGACY_STATE_IDLE;
if (!mPlayingTransitions.isEmpty()) {
state = LEGACY_STATE_RUNNING;
} else if (mCollectingTransition != null && mCollectingTransition.getLegacyIsReady()) {
} else if ((mCollectingTransition != null && mCollectingTransition.getLegacyIsReady())
|| !mPendingTransitions.isEmpty()) {
// The transition may not be "ready", but we have transition waiting to start, so it
// can't be IDLE for test purpose. Ideally, we should have a STATE_COLLECTING.
state = LEGACY_STATE_READY;
}
proto.write(AppTransitionProto.APP_TRANSITION_STATE, state);