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

Commit fae51908 authored by Matt Pietal's avatar Matt Pietal
Browse files

Add synchronized check around async inflation callback

Turns out multiple threads may invoke the call to
get view.

Fixes: 392080592
Test: manual - race condition fix
Flag: EXEMPT bugfix
Change-Id: Ia0f3921fe798cf33d9978035bcf61d7f23586e16
parent 8006649e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -111,7 +111,9 @@ public class KeyguardSecurityViewFlipperController

        // Prevent multiple inflations for the same security mode. Instead, add callback to a list
        // and then notify each in order when the view is inflated.
        synchronized (mOnViewInflatedListeners) {
            mOnViewInflatedListeners.add(onViewInflatedCallback);
        }
        if (!mSecurityModeInProgress.contains(securityMode)) {
            mSecurityModeInProgress.add(securityMode);
            asynchronouslyInflateView(securityMode, keyguardSecurityCallback);
@@ -145,10 +147,14 @@ public class KeyguardSecurityViewFlipperController
                        childController.init();
                        mChildren.add(childController);

                        for (OnViewInflatedCallback callback : mOnViewInflatedListeners) {
                        List<OnViewInflatedCallback> callbacks;
                        synchronized (mOnViewInflatedListeners) {
                            callbacks = new ArrayList<>(mOnViewInflatedListeners);
                            mOnViewInflatedListeners.clear();
                        }
                        for (OnViewInflatedCallback callback : callbacks) {
                            callback.onViewInflated(childController);
                        }
                        mOnViewInflatedListeners.clear();

                        // Single bouncer constrains are default
                        if (mFeatureFlags.isEnabled(LOCKSCREEN_ENABLE_LANDSCAPE)) {