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

Commit d999962e authored by Roman Birg's avatar Roman Birg
Browse files

SystemUI: survive notification update spam



When handling a very high number of incoming notification updates, SystemUI can
choke up at updateNotifications() in PhoneStatusBar. Funnel
updateNotification() calls through the StatusBar's handler and don't
stack them up.

Change-Id: I806d1fd8eac73c4af0820319d127423ae6467f60
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent b92c2ccf
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -220,6 +220,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000;
    private static final int MSG_CLOSE_PANELS = 1001;
    private static final int MSG_OPEN_SETTINGS_PANEL = 1002;
    private static final int MSG_UPDATE_NOTIFICATIONS = 1003;
    // 1020-1040 reserved for BaseStatusBar

    private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true;
@@ -1944,8 +1945,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        mStackScroller.updateSpeedBumpIndex(speedbumpIndex);
    }

    @Override
    protected void updateNotifications() {
    private void handleUpdateNotifications() {
        // TODO: Move this into updateNotificationIcons()?
        if (mNotificationIcons == null) return;

@@ -1955,6 +1955,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        updateNotificationIcons();
    }

    @Override
    protected void updateNotifications() {
        if (!mHandler.hasMessages(MSG_UPDATE_NOTIFICATIONS)) {
            mHandler.sendEmptyMessage(MSG_UPDATE_NOTIFICATIONS);
        }
    }

    private void updateNotificationIcons() {
        final LinearLayout.LayoutParams params
            = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight);
@@ -2608,6 +2615,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                    escalateHeadsUp();
                    setHeadsUpVisibility(false);
                    break;
                case MSG_UPDATE_NOTIFICATIONS:
                    handleUpdateNotifications();
                    break;
            }
        }
    }