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

Commit 2c9b1e97 authored by Andy Mast's avatar Andy Mast
Browse files

SystemUI: Fix crash during notification/theme change

Fixes crashing that could occur when a notification is created
during a theme change. Entries were attempting to be added
to views which did not have a layout pass yet, causing it to fail.

When a theme change occurs, the fix is to halt the ticker and command queue
until a layout occurs.

BUGDUMP-151925

Change-Id: Ic19d26178df673a1d52981a8617415e6fbcb219d
parent d66033ca
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public class CommandQueue extends IStatusBar.Stub {
    private StatusBarIconList mList;
    private Callbacks mCallbacks;
    private Handler mHandler = new H();
    private boolean mPaused = false;

    private class NotificationQueueEntry {
        IBinder key;
@@ -232,8 +233,20 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    public void pause() {
        mPaused = true;
    }

    public void resume() {
        mPaused = false;
    }

    private final class H extends Handler {
        public void handleMessage(Message msg) {
            if (mPaused) {
                this.sendMessage(Message.obtain(msg));
                return;
            }
            final int what = msg.what & MSG_MASK;
            switch (what) {
                case MSG_ICON: {
+18 −1
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewPropertyAnimator;
import android.view.ViewStub;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
@@ -3476,6 +3477,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        copyNotifications(notifications, mNotificationData);
        mNotificationData.clear();

        // Halts the old ticker. A new ticker is created in makeStatusBarView() so
        // this MUST happen before makeStatusBarView();
        mTicker.halt();

        makeStatusBarView();
        repositionNavigationBar();
        addHeadsUpView();
@@ -3506,8 +3511,20 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,

        updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
        checkBarModes();

        // Stop the command queue until the new status bar container settles and has a layout pass
        mCommandQueue.pause();
        mStatusBarContainer.requestLayout();
        mStatusBarContainer.getViewTreeObserver().addOnGlobalLayoutListener(
                new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                mStatusBarContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                mCommandQueue.resume();
                mRecreating = false;
            }
        });
    }

    private void removeAllViews(ViewGroup parent) {
        int N = parent.getChildCount();