From fc0f937722dd306ba9d077b0e9894331804ffafd Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Fri, 3 Mar 2017 12:31:05 -0800 Subject: [PATCH] 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 --- .../systemui/statusbar/phone/StatusBar.java | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 87389add8c50d..b691f7c515212 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -718,6 +718,7 @@ public class StatusBar extends SystemUI implements DemoMode, private NotificationIconAreaController mNotificationIconAreaController; private ConfigurationListener mConfigurationListener; private InflationExceptionHandler mInflationExceptionHandler = this::handleInflationException; + private boolean mReinflateNotificationsOnUserSwitched; private void recycleAllVisibilityObjects(ArraySet array) { final int N = array.size(); @@ -1277,16 +1278,10 @@ public class StatusBar extends SystemUI implements DemoMode, protected void onDensityOrFontScaleChanged() { // start old BaseStatusBar.onDensityOrFontScaleChanged(). - ArrayList 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); - } + if (!KeyguardUpdateMonitor.getInstance(mContext).isSwitchingUser()) { + updateNotificationsOnDensityOrFontScaleChanged(); + } else { + mReinflateNotificationsOnUserSwitched = true; } // end old BaseStatusBar.onDensityOrFontScaleChanged(). mScrimController.onDensityOrFontScaleChanged(); @@ -1311,6 +1306,20 @@ public class StatusBar extends SystemUI implements DemoMode, } } + private void updateNotificationsOnDensityOrFontScaleChanged() { + ArrayList 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() { reinflateSignalCluster(mKeyguardStatusBar); } @@ -3601,7 +3610,12 @@ public class StatusBar extends SystemUI implements DemoMode, if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId); animateCollapsePanels(); updatePublicMode(); - updateNotifications(); + mNotificationData.filterAndSort(); + if (mReinflateNotificationsOnUserSwitched) { + updateNotificationsOnDensityOrFontScaleChanged(); + mReinflateNotificationsOnUserSwitched = false; + } + updateNotificationShade(); clearCurrentMediaNotification(); setLockscreenUser(newUserId); }