Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -499,10 +499,10 @@ public class NotificationEntryManager implements if (rankingMap == null) { return; } NotificationListenerService.Ranking tmpRanking = new NotificationListenerService.Ranking(); NotificationListenerService.Ranking ranking = new NotificationListenerService.Ranking(); for (NotificationEntry pendingNotification : mPendingNotifications.values()) { rankingMap.getRanking(pendingNotification.key, tmpRanking); pendingNotification.populateFromRanking(tmpRanking); rankingMap.getRanking(pendingNotification.key, ranking); pendingNotification.setRanking(ranking); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java +9 −15 Original line number Diff line number Diff line Loading @@ -213,7 +213,7 @@ public class NotificationData { StatusBarNotification notification) { updateRanking(ranking); final StatusBarNotification oldNotification = entry.notification; entry.notification = notification; entry.setNotification(notification); mGroupManager.onEntryUpdated(entry, oldNotification); } Loading Loading @@ -325,14 +325,6 @@ public class NotificationData { return NotificationManager.IMPORTANCE_UNSPECIFIED; } public String getOverrideGroupKey(String key) { if (mRankingMap != null) { getRanking(key, mTmpRanking); return mTmpRanking.getOverrideGroupKey(); } return null; } public List<SnoozeCriterion> getSnoozeCriteria(String key) { if (mRankingMap != null) { getRanking(key, mTmpRanking); Loading Loading @@ -365,23 +357,25 @@ public class NotificationData { return false; } private void updateRankingAndSort(RankingMap ranking) { if (ranking != null) { mRankingMap = ranking; private void updateRankingAndSort(RankingMap rankingMap) { if (rankingMap != null) { mRankingMap = rankingMap; synchronized (mEntries) { final int len = mEntries.size(); for (int i = 0; i < len; i++) { NotificationEntry entry = mEntries.valueAt(i); if (!getRanking(entry.key, mTmpRanking)) { Ranking newRanking = new Ranking(); if (!getRanking(entry.key, newRanking)) { continue; } entry.setRanking(newRanking); final StatusBarNotification oldSbn = entry.notification.cloneLight(); final String overrideGroupKey = getOverrideGroupKey(entry.key); final String overrideGroupKey = newRanking.getOverrideGroupKey(); if (!Objects.equals(oldSbn.getOverrideGroupKey(), overrideGroupKey)) { entry.notification.setOverrideGroupKey(overrideGroupKey); mGroupManager.onEntryUpdated(entry, oldSbn); } entry.populateFromRanking(mTmpRanking); entry.setIsHighPriority(isHighPriority(entry.notification)); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +72 −11 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.Parcelable; import android.os.SystemClock; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.SnoozeCriterion; import android.service.notification.StatusBarNotification; import android.text.TextUtils; Loading Loading @@ -88,6 +88,8 @@ public final class NotificationEntry { private static final int COLOR_INVALID = 1; public final String key; public StatusBarNotification notification; private Ranking mRanking; public NotificationChannel channel; public long lastAudiblyAlertedMs; public boolean noisy; Loading @@ -103,7 +105,7 @@ public final class NotificationEntry { private long lastFullScreenIntentLaunchTime = NOT_LAUNCHED_YET; public CharSequence remoteInputText; public List<SnoozeCriterion> snoozeCriteria; public int userSentiment = NotificationListenerService.Ranking.USER_SENTIMENT_NEUTRAL; public int userSentiment = Ranking.USER_SENTIMENT_NEUTRAL; /** Smart Actions provided by the NotificationAssistantService. */ @NonNull public List<Notification.Action> systemGeneratedSmartActions = Collections.emptyList(); Loading Loading @@ -181,21 +183,80 @@ public final class NotificationEntry { private boolean mAutoHeadsUp; private boolean mPulseSupressed; public NotificationEntry(StatusBarNotification n) { this(n, null); public NotificationEntry( StatusBarNotification sbn, @NonNull Ranking ranking) { this(sbn, ranking, false); } public NotificationEntry( StatusBarNotification n, @Nullable NotificationListenerService.Ranking ranking) { this.key = n.getKey(); this.notification = n; private NotificationEntry( StatusBarNotification sbn, Ranking ranking, boolean isTest) { this.key = sbn.getKey(); this.notification = sbn; // TODO: Update tests to no longer need to pass null ranking if (ranking != null) { populateFromRanking(ranking); setRanking(ranking); } else if (!isTest) { throw new IllegalArgumentException("Ranking cannot be null"); } } /** * Method for old tests that build NotificationEntries with a ranking. * * @deprecated New tests should pass a ranking object as well. */ @VisibleForTesting @Deprecated public static NotificationEntry buildForTest(StatusBarNotification sbn) { // TODO START here this will NPE on all tests return new NotificationEntry(sbn, null, true); } /** The key for this notification. Guaranteed to be immutable and unique */ public String key() { return key; } /** * The StatusBarNotification that represents one half of a NotificationEntry (the other half * being the Ranking). This object is swapped out whenever a notification is updated. */ public StatusBarNotification sbn() { return notification; } /** * Should only be called by NotificationEntryManager and friends. * TODO: Make this package-private */ public void setNotification(StatusBarNotification sbn) { if (!sbn.getKey().equals(key)) { throw new IllegalArgumentException("New key " + sbn.getKey() + " doesn't match existing key " + key); } notification = sbn; } public void populateFromRanking(@NonNull NotificationListenerService.Ranking ranking) { /** * The Ranking that represents one half of a NotificationEntry (the other half being the * StatusBarNotification). This object is swapped out whenever a the ranking is updated (which * generally occurs whenever anything changes in the notification list). */ public Ranking ranking() { return mRanking; } /** * Should only be called by NotificationEntryManager and friends. * TODO: Make this package-private */ public void setRanking(@NonNull Ranking ranking) { mRanking = ranking; channel = ranking.getChannel(); lastAudiblyAlertedMs = ranking.getLastAudiblyAlertedMillis(); importance = ranking.getImportance(); Loading packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -392,18 +392,18 @@ public class ForegroundServiceControllerTest extends SysuiTestCase { } private void entryRemoved(StatusBarNotification notification) { mEntryListener.onEntryRemoved(new NotificationEntry(notification), mEntryListener.onEntryRemoved(NotificationEntry.buildForTest(notification), null, false); } private void entryAdded(StatusBarNotification notification, int importance) { NotificationEntry entry = new NotificationEntry(notification); NotificationEntry entry = NotificationEntry.buildForTest(notification); entry.importance = importance; mEntryListener.onPendingEntryAdded(entry); } private void entryUpdated(StatusBarNotification notification, int importance) { NotificationEntry entry = new NotificationEntry(notification); NotificationEntry entry = NotificationEntry.buildForTest(notification); entry.importance = importance; mEntryListener.onPostEntryUpdated(entry); } Loading packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -878,7 +878,7 @@ public class BubbleDataTest extends SysuiTestCase { when(sbn.getNotification()).thenReturn(notification); // NotificationEntry -> StatusBarNotification -> Notification -> BubbleMetadata return new NotificationEntry(sbn); return NotificationEntry.buildForTest(sbn); } private void setCurrentTime(long time) { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -499,10 +499,10 @@ public class NotificationEntryManager implements if (rankingMap == null) { return; } NotificationListenerService.Ranking tmpRanking = new NotificationListenerService.Ranking(); NotificationListenerService.Ranking ranking = new NotificationListenerService.Ranking(); for (NotificationEntry pendingNotification : mPendingNotifications.values()) { rankingMap.getRanking(pendingNotification.key, tmpRanking); pendingNotification.populateFromRanking(tmpRanking); rankingMap.getRanking(pendingNotification.key, ranking); pendingNotification.setRanking(ranking); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java +9 −15 Original line number Diff line number Diff line Loading @@ -213,7 +213,7 @@ public class NotificationData { StatusBarNotification notification) { updateRanking(ranking); final StatusBarNotification oldNotification = entry.notification; entry.notification = notification; entry.setNotification(notification); mGroupManager.onEntryUpdated(entry, oldNotification); } Loading Loading @@ -325,14 +325,6 @@ public class NotificationData { return NotificationManager.IMPORTANCE_UNSPECIFIED; } public String getOverrideGroupKey(String key) { if (mRankingMap != null) { getRanking(key, mTmpRanking); return mTmpRanking.getOverrideGroupKey(); } return null; } public List<SnoozeCriterion> getSnoozeCriteria(String key) { if (mRankingMap != null) { getRanking(key, mTmpRanking); Loading Loading @@ -365,23 +357,25 @@ public class NotificationData { return false; } private void updateRankingAndSort(RankingMap ranking) { if (ranking != null) { mRankingMap = ranking; private void updateRankingAndSort(RankingMap rankingMap) { if (rankingMap != null) { mRankingMap = rankingMap; synchronized (mEntries) { final int len = mEntries.size(); for (int i = 0; i < len; i++) { NotificationEntry entry = mEntries.valueAt(i); if (!getRanking(entry.key, mTmpRanking)) { Ranking newRanking = new Ranking(); if (!getRanking(entry.key, newRanking)) { continue; } entry.setRanking(newRanking); final StatusBarNotification oldSbn = entry.notification.cloneLight(); final String overrideGroupKey = getOverrideGroupKey(entry.key); final String overrideGroupKey = newRanking.getOverrideGroupKey(); if (!Objects.equals(oldSbn.getOverrideGroupKey(), overrideGroupKey)) { entry.notification.setOverrideGroupKey(overrideGroupKey); mGroupManager.onEntryUpdated(entry, oldSbn); } entry.populateFromRanking(mTmpRanking); entry.setIsHighPriority(isHighPriority(entry.notification)); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +72 −11 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.Parcelable; import android.os.SystemClock; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.SnoozeCriterion; import android.service.notification.StatusBarNotification; import android.text.TextUtils; Loading Loading @@ -88,6 +88,8 @@ public final class NotificationEntry { private static final int COLOR_INVALID = 1; public final String key; public StatusBarNotification notification; private Ranking mRanking; public NotificationChannel channel; public long lastAudiblyAlertedMs; public boolean noisy; Loading @@ -103,7 +105,7 @@ public final class NotificationEntry { private long lastFullScreenIntentLaunchTime = NOT_LAUNCHED_YET; public CharSequence remoteInputText; public List<SnoozeCriterion> snoozeCriteria; public int userSentiment = NotificationListenerService.Ranking.USER_SENTIMENT_NEUTRAL; public int userSentiment = Ranking.USER_SENTIMENT_NEUTRAL; /** Smart Actions provided by the NotificationAssistantService. */ @NonNull public List<Notification.Action> systemGeneratedSmartActions = Collections.emptyList(); Loading Loading @@ -181,21 +183,80 @@ public final class NotificationEntry { private boolean mAutoHeadsUp; private boolean mPulseSupressed; public NotificationEntry(StatusBarNotification n) { this(n, null); public NotificationEntry( StatusBarNotification sbn, @NonNull Ranking ranking) { this(sbn, ranking, false); } public NotificationEntry( StatusBarNotification n, @Nullable NotificationListenerService.Ranking ranking) { this.key = n.getKey(); this.notification = n; private NotificationEntry( StatusBarNotification sbn, Ranking ranking, boolean isTest) { this.key = sbn.getKey(); this.notification = sbn; // TODO: Update tests to no longer need to pass null ranking if (ranking != null) { populateFromRanking(ranking); setRanking(ranking); } else if (!isTest) { throw new IllegalArgumentException("Ranking cannot be null"); } } /** * Method for old tests that build NotificationEntries with a ranking. * * @deprecated New tests should pass a ranking object as well. */ @VisibleForTesting @Deprecated public static NotificationEntry buildForTest(StatusBarNotification sbn) { // TODO START here this will NPE on all tests return new NotificationEntry(sbn, null, true); } /** The key for this notification. Guaranteed to be immutable and unique */ public String key() { return key; } /** * The StatusBarNotification that represents one half of a NotificationEntry (the other half * being the Ranking). This object is swapped out whenever a notification is updated. */ public StatusBarNotification sbn() { return notification; } /** * Should only be called by NotificationEntryManager and friends. * TODO: Make this package-private */ public void setNotification(StatusBarNotification sbn) { if (!sbn.getKey().equals(key)) { throw new IllegalArgumentException("New key " + sbn.getKey() + " doesn't match existing key " + key); } notification = sbn; } public void populateFromRanking(@NonNull NotificationListenerService.Ranking ranking) { /** * The Ranking that represents one half of a NotificationEntry (the other half being the * StatusBarNotification). This object is swapped out whenever a the ranking is updated (which * generally occurs whenever anything changes in the notification list). */ public Ranking ranking() { return mRanking; } /** * Should only be called by NotificationEntryManager and friends. * TODO: Make this package-private */ public void setRanking(@NonNull Ranking ranking) { mRanking = ranking; channel = ranking.getChannel(); lastAudiblyAlertedMs = ranking.getLastAudiblyAlertedMillis(); importance = ranking.getImportance(); Loading
packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -392,18 +392,18 @@ public class ForegroundServiceControllerTest extends SysuiTestCase { } private void entryRemoved(StatusBarNotification notification) { mEntryListener.onEntryRemoved(new NotificationEntry(notification), mEntryListener.onEntryRemoved(NotificationEntry.buildForTest(notification), null, false); } private void entryAdded(StatusBarNotification notification, int importance) { NotificationEntry entry = new NotificationEntry(notification); NotificationEntry entry = NotificationEntry.buildForTest(notification); entry.importance = importance; mEntryListener.onPendingEntryAdded(entry); } private void entryUpdated(StatusBarNotification notification, int importance) { NotificationEntry entry = new NotificationEntry(notification); NotificationEntry entry = NotificationEntry.buildForTest(notification); entry.importance = importance; mEntryListener.onPostEntryUpdated(entry); } Loading
packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -878,7 +878,7 @@ public class BubbleDataTest extends SysuiTestCase { when(sbn.getNotification()).thenReturn(notification); // NotificationEntry -> StatusBarNotification -> Notification -> BubbleMetadata return new NotificationEntry(sbn); return NotificationEntry.buildForTest(sbn); } private void setCurrentTime(long time) { Loading