Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +18 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,7 @@ public class NotificationData { private final ArrayMap<String, Entry> mEntries = new ArrayMap<>(); private final ArrayList<Entry> mSortedAndFiltered = new ArrayList<>(); private final ArrayList<Entry> mFilteredForUser = new ArrayList<>(); private NotificationGroupManager mGroupManager; Loading Loading @@ -429,6 +430,23 @@ public class NotificationData { return mSortedAndFiltered; } public ArrayList<Entry> getNotificationsForCurrentUser() { mFilteredForUser.clear(); synchronized (mEntries) { final int N = mEntries.size(); for (int i = 0; i < N; i++) { Entry entry = mEntries.valueAt(i); final StatusBarNotification sbn = entry.notification; if (!mEnvironment.isNotificationForCurrentProfiles(sbn)) { continue; } mFilteredForUser.add(entry); } } return mFilteredForUser; } public Entry get(String key) { return mEntries.get(key); } Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -681,10 +681,10 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } public void updateNotificationsOnDensityOrFontScaleChanged() { ArrayList<NotificationData.Entry> activeNotifications = mNotificationData.getActiveNotifications(); for (int i = 0; i < activeNotifications.size(); i++) { NotificationData.Entry entry = activeNotifications.get(i); ArrayList<NotificationData.Entry> userNotifications = mNotificationData.getNotificationsForCurrentUser(); for (int i = 0; i < userNotifications.size(); i++) { NotificationData.Entry entry = userNotifications.get(i); boolean exposedGuts = mGutsManager.getExposedGuts() != null && entry.row.getGuts() == mGutsManager.getExposedGuts(); entry.row.onDensityOrFontScaleChanged(); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java +20 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,6 @@ import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.support.test.annotation.UiThreadTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper.RunWithLooper; import android.util.ArraySet; Loading @@ -62,6 +61,8 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.ArrayList; @SmallTest @RunWith(AndroidTestingRunner.class) @RunWithLooper(setAsMainLooper = true) Loading Loading @@ -279,6 +280,24 @@ public class NotificationDataTest extends SysuiTestCase { assertFalse(mNotificationData.shouldFilterOut(entry)); } @Test public void testGetNotificationsForCurrentUser_shouldFilterNonCurrentUserNotifications() throws Exception { mNotificationData.add(mRow.getEntry()); ExpandableNotificationRow row2 = new NotificationTestHelper(getContext()).createRow(); mNotificationData.add(row2.getEntry()); when(mEnvironment.isNotificationForCurrentProfiles( mRow.getEntry().notification)).thenReturn(false); when(mEnvironment.isNotificationForCurrentProfiles( row2.getEntry().notification)).thenReturn(true); ArrayList<NotificationData.Entry> reuslt = mNotificationData.getNotificationsForCurrentUser(); assertEquals(reuslt.size(), 1); assertEquals(reuslt.get(0), row2.getEntry()); } @Test public void testIsExemptFromDndVisualSuppression_foreground() { initStatusBarNotification(false); Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +18 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,7 @@ public class NotificationData { private final ArrayMap<String, Entry> mEntries = new ArrayMap<>(); private final ArrayList<Entry> mSortedAndFiltered = new ArrayList<>(); private final ArrayList<Entry> mFilteredForUser = new ArrayList<>(); private NotificationGroupManager mGroupManager; Loading Loading @@ -429,6 +430,23 @@ public class NotificationData { return mSortedAndFiltered; } public ArrayList<Entry> getNotificationsForCurrentUser() { mFilteredForUser.clear(); synchronized (mEntries) { final int N = mEntries.size(); for (int i = 0; i < N; i++) { Entry entry = mEntries.valueAt(i); final StatusBarNotification sbn = entry.notification; if (!mEnvironment.isNotificationForCurrentProfiles(sbn)) { continue; } mFilteredForUser.add(entry); } } return mFilteredForUser; } public Entry get(String key) { return mEntries.get(key); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -681,10 +681,10 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } public void updateNotificationsOnDensityOrFontScaleChanged() { ArrayList<NotificationData.Entry> activeNotifications = mNotificationData.getActiveNotifications(); for (int i = 0; i < activeNotifications.size(); i++) { NotificationData.Entry entry = activeNotifications.get(i); ArrayList<NotificationData.Entry> userNotifications = mNotificationData.getNotificationsForCurrentUser(); for (int i = 0; i < userNotifications.size(); i++) { NotificationData.Entry entry = userNotifications.get(i); boolean exposedGuts = mGutsManager.getExposedGuts() != null && entry.row.getGuts() == mGutsManager.getExposedGuts(); entry.row.onDensityOrFontScaleChanged(); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java +20 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,6 @@ import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.support.test.annotation.UiThreadTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper.RunWithLooper; import android.util.ArraySet; Loading @@ -62,6 +61,8 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.ArrayList; @SmallTest @RunWith(AndroidTestingRunner.class) @RunWithLooper(setAsMainLooper = true) Loading Loading @@ -279,6 +280,24 @@ public class NotificationDataTest extends SysuiTestCase { assertFalse(mNotificationData.shouldFilterOut(entry)); } @Test public void testGetNotificationsForCurrentUser_shouldFilterNonCurrentUserNotifications() throws Exception { mNotificationData.add(mRow.getEntry()); ExpandableNotificationRow row2 = new NotificationTestHelper(getContext()).createRow(); mNotificationData.add(row2.getEntry()); when(mEnvironment.isNotificationForCurrentProfiles( mRow.getEntry().notification)).thenReturn(false); when(mEnvironment.isNotificationForCurrentProfiles( row2.getEntry().notification)).thenReturn(true); ArrayList<NotificationData.Entry> reuslt = mNotificationData.getNotificationsForCurrentUser(); assertEquals(reuslt.size(), 1); assertEquals(reuslt.get(0), row2.getEntry()); } @Test public void testIsExemptFromDndVisualSuppression_foreground() { initStatusBarNotification(false); Loading