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

Commit 3de03437 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

[DO NOT MERGE] Bail early if mToken.asBinder() not found

Not able to reproduce what's in the original bug report, this null check
is added as a safe guard. A possible scenario is
PipTaskOrganizer#exitPip is called twice and there is a race condition
that the first applySyncTransaction is not ready yet and leave the
internal state as it was, the second call tries to get configuration and
it is null, which leads to a NPE.

Bug: 169173459
Test: N/A
Change-Id: Ie5292e8749bc186fba930dfee59c26d10ea680cd
parent 7d2354bd
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -303,15 +303,20 @@ public class PipTaskOrganizer extends TaskOrganizer implements
     * @param animationDurationMs duration in millisecond for the exiting PiP transition
     */
    public void exitPip(int animationDurationMs) {
        if (!mState.isInPip() || mState == State.EXITING_PIP || mToken == null) {
        if (!mState.isInPip() || mToken == null) {
            Log.wtf(TAG, "Not allowed to exitPip in current state"
                    + " mState=" + mState + " mToken=" + mToken);
            return;
        }

        final PipWindowConfigurationCompact config = mCompactState.remove(mToken.asBinder());
        if (config == null) {
            Log.wtf(TAG, "Token not in record, this should not happen mToken=" + mToken);
            return;
        }

        mPipUiEventLoggerLogger.log(
                PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_EXPAND_TO_FULLSCREEN);
        final PipWindowConfigurationCompact config = mCompactState.remove(mToken.asBinder());
        config.syncWithScreenOrientation(mRequestedOrientation,
                mPipBoundsHandler.getDisplayRotation());
        final boolean orientationDiffers = config.getRotation()