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

Commit fc0f9377 authored by Selim Cinek's avatar Selim Cinek
Browse files

Waiting for reinflating the notifications until the user switched

Previously we would react to density changes immediately even if
we were still switching users, which could apply a new density
to the wrong notifications.
We're now waiting until we actually switched.

Test: add notifications on different user with different density, switch
Change-Id: Ieb0094ba6740bd5b9c53b275127bd128bc19236e
Fixes: 30839163
parent 24176c33
Loading
Loading
Loading
Loading
+25 −11
Original line number Original line Diff line number Diff line
@@ -718,6 +718,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    private NotificationIconAreaController mNotificationIconAreaController;
    private NotificationIconAreaController mNotificationIconAreaController;
    private ConfigurationListener mConfigurationListener;
    private ConfigurationListener mConfigurationListener;
    private InflationExceptionHandler mInflationExceptionHandler = this::handleInflationException;
    private InflationExceptionHandler mInflationExceptionHandler = this::handleInflationException;
    private boolean mReinflateNotificationsOnUserSwitched;


    private void recycleAllVisibilityObjects(ArraySet<NotificationVisibility> array) {
    private void recycleAllVisibilityObjects(ArraySet<NotificationVisibility> array) {
        final int N = array.size();
        final int N = array.size();
@@ -1277,16 +1278,10 @@ public class StatusBar extends SystemUI implements DemoMode,


    protected void onDensityOrFontScaleChanged() {
    protected void onDensityOrFontScaleChanged() {
        // start old BaseStatusBar.onDensityOrFontScaleChanged().
        // start old BaseStatusBar.onDensityOrFontScaleChanged().
        ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
        if (!KeyguardUpdateMonitor.getInstance(mContext).isSwitchingUser()) {
        for (int i = 0; i < activeNotifications.size(); i++) {
            updateNotificationsOnDensityOrFontScaleChanged();
            Entry entry = activeNotifications.get(i);
        } else {
            boolean exposedGuts = mNotificationGutsExposed != null
            mReinflateNotificationsOnUserSwitched = true;
                    && entry.row.getGuts() == mNotificationGutsExposed;
            entry.row.onDensityOrFontScaleChanged();
            if (exposedGuts) {
                mNotificationGutsExposed = entry.row.getGuts();
                bindGuts(entry.row, mGutsMenuItem);
            }
        }
        }
        // end old BaseStatusBar.onDensityOrFontScaleChanged().
        // end old BaseStatusBar.onDensityOrFontScaleChanged().
        mScrimController.onDensityOrFontScaleChanged();
        mScrimController.onDensityOrFontScaleChanged();
@@ -1311,6 +1306,20 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
        }
    }
    }


    private void updateNotificationsOnDensityOrFontScaleChanged() {
        ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
        for (int i = 0; i < activeNotifications.size(); i++) {
            Entry entry = activeNotifications.get(i);
            boolean exposedGuts = mNotificationGutsExposed != null
                    && entry.row.getGuts() == mNotificationGutsExposed;
            entry.row.onDensityOrFontScaleChanged();
            if (exposedGuts) {
                mNotificationGutsExposed = entry.row.getGuts();
                bindGuts(entry.row, mGutsMenuItem);
            }
        }
    }

    private void inflateSignalClusters() {
    private void inflateSignalClusters() {
        reinflateSignalCluster(mKeyguardStatusBar);
        reinflateSignalCluster(mKeyguardStatusBar);
    }
    }
@@ -3601,7 +3610,12 @@ public class StatusBar extends SystemUI implements DemoMode,
        if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId);
        if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId);
        animateCollapsePanels();
        animateCollapsePanels();
        updatePublicMode();
        updatePublicMode();
        updateNotifications();
        mNotificationData.filterAndSort();
        if (mReinflateNotificationsOnUserSwitched) {
            updateNotificationsOnDensityOrFontScaleChanged();
            mReinflateNotificationsOnUserSwitched = false;
        }
        updateNotificationShade();
        clearCurrentMediaNotification();
        clearCurrentMediaNotification();
        setLockscreenUser(newUserId);
        setLockscreenUser(newUserId);
    }
    }