Support playNow on queued SLEEP transits
When a transition is queued, we usually post the onCollectStarted
callback to avoid ordering issues w/ the prior transition. This
means that anything in the handler queue will execute before
onCollectStarted. Again, this is desired normally and it means
those actions will be collected in the new transition.
However, SLEEP transitions are currently treated as empty
sentinels (at-least today). While there's nothing wrong with
collecting changes in SLEEP transitions, we still have some
transitions (eg. around keyguard) that can race with it, so
to reduce those races short-term, this adds a check for SLEEP
when dequeuing and start that immediately vs. posting.
Bug: 304713150
Test: Existing tests pass.
Change-Id: Id234414c220367a2e971fa29cf03ba631c7564f1
diff --git a/services/core/java/com/android/server/wm/TransitionController.java b/services/core/java/com/android/server/wm/TransitionController.java
index 7109137..ba4b3f0 100644
--- a/services/core/java/com/android/server/wm/TransitionController.java
+++ b/services/core/java/com/android/server/wm/TransitionController.java
@@ -1005,12 +1005,20 @@
// legacy sync
mSyncEngine.startSyncSet(queued.mLegacySync);
}
- // Post this so that the now-playing transition logic isn't interrupted.
- mAtm.mH.post(() -> {
- synchronized (mAtm.mGlobalLock) {
- queued.mOnStartCollect.onCollectStarted(true /* deferred */);
- }
- });
+ if (queued.mTransition != null
+ && queued.mTransition.mType == WindowManager.TRANSIT_SLEEP) {
+ // SLEEP transitions are special in that they don't collect anything (in fact if they
+ // do collect things it can cause problems). So, we need to run it's onCollectStarted
+ // immediately.
+ queued.mOnStartCollect.onCollectStarted(true /* deferred */);
+ } else {
+ // Post this so that the now-playing transition logic isn't interrupted.
+ mAtm.mH.post(() -> {
+ synchronized (mAtm.mGlobalLock) {
+ queued.mOnStartCollect.onCollectStarted(true /* deferred */);
+ }
+ });
+ }
}
void moveToPlaying(Transition transition) {