Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40cd4d19 authored by Evan Rosky's avatar Evan Rosky
Browse files

Properly abort queued transitions during clean-up

When cleaning-up/flushing transitions due to player
disconnect, it is possible for queued transitions to have
moved to collecting but still have posted the actual
work on the handler. If sysui dies/disconnects in between,
then we can accidentally run logic that assumes the
transition is still valid after it has been aborted.

So, add a check to skip this work if transition has been
aborted.

Bug: 439829314
Test: observe test metrics
Flag: EXEMPT bugfix
Change-Id: I5a7df2e891e4d8940cbcf16259506df6902bba66
parent 80166f36
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -194,6 +194,11 @@ class TransitionController {
            mOnStartCollect = onStartCollect;
            mLegacySync = legacySync;
        }

        boolean isAborted(BLASTSyncEngine syncEngine) {
            return mTransition == null ? syncEngine.getSyncSet(mLegacySync.mSyncId) == null
                    : mTransition.isAborted();
        }
    }

    private final ArrayList<QueuedTransition> mQueuedTransitions = new ArrayList<>();
@@ -1232,6 +1237,8 @@ class TransitionController {
            // Post this so that the now-playing transition logic isn't interrupted.
            mAtm.mH.post(() -> {
                synchronized (mAtm.mGlobalLock) {
                    // The transition/sync may be aborted if the transition player died.
                    if (queued.isAborted(mSyncEngine)) return;
                    queued.mOnStartCollect.onCollectStarted(true /* deferred */);
                }
            });