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

Commit 441086ba authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
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 am: 0bd4256d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23573736



Change-Id: I40b6d155a7bf0aea48356970261d2445cdde2d65
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents b4edc35c 0bd4256d
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -104,7 +104,11 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask

    @Override
    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(),
                    mLayerView.get(), mIconFactory, mBubble, mSkipInflation);
        } else {
@@ -118,7 +122,11 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask
        if (isCancelled() || viewInfo == null) {
            return;
        }

        mMainExecutor.execute(() -> {
            if (!verifyState()) {
                return;
            }
            mBubble.setViewInfo(viewInfo);
            if (mCallback != null) {
                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.
     */