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

Commit 0bd4256d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update BubbleViewInfoTask to verify that the state hasn't changed after...

Merge "Update BubbleViewInfoTask to verify that the state hasn't changed after the task was scheduled or while it is running. Without this there is a race condition that causes the task to inflate a bubble incorrectly, e.g. without a dot path, which then leads to an NPE trying to render the dot." into udc-qpr-dev
parents 0648e271 065c12c7
Loading
Loading
Loading
Loading
+17 −1
Original line number Original line Diff line number Diff line
@@ -104,7 +104,11 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask


    @Override
    @Override
    protected BubbleViewInfo doInBackground(Void... voids) {
    protected BubbleViewInfo doInBackground(Void... voids) {
        if (mController.get().isShowingAsBubbleBar()) {
        if (!verifyState()) {
            // If we're in an inconsistent state, then switched modes and should just bail now.
            return null;
        }
        if (mLayerView.get() != null) {
            return BubbleViewInfo.populateForBubbleBar(mContext.get(), mController.get(),
            return BubbleViewInfo.populateForBubbleBar(mContext.get(), mController.get(),
                    mLayerView.get(), mIconFactory, mBubble, mSkipInflation);
                    mLayerView.get(), mIconFactory, mBubble, mSkipInflation);
        } else {
        } else {
@@ -118,7 +122,11 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask
        if (isCancelled() || viewInfo == null) {
        if (isCancelled() || viewInfo == null) {
            return;
            return;
        }
        }

        mMainExecutor.execute(() -> {
        mMainExecutor.execute(() -> {
            if (!verifyState()) {
                return;
            }
            mBubble.setViewInfo(viewInfo);
            mBubble.setViewInfo(viewInfo);
            if (mCallback != null) {
            if (mCallback != null) {
                mCallback.onBubbleViewsReady(mBubble);
                mCallback.onBubbleViewsReady(mBubble);
@@ -126,6 +134,14 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask
        });
        });
    }
    }


    private boolean verifyState() {
        if (mController.get().isShowingAsBubbleBar()) {
            return mLayerView.get() != null;
        } else {
            return mStackView.get() != null;
        }
    }

    /**
    /**
     * Info necessary to render a bubble.
     * Info necessary to render a bubble.
     */
     */