diff options
61 files changed, 568 insertions, 522 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ForegroundServiceLifetimeExtender.java b/packages/SystemUI/src/com/android/systemui/ForegroundServiceLifetimeExtender.java index 5c561e5bf6f2..362014f51e36 100644 --- a/packages/SystemUI/src/com/android/systemui/ForegroundServiceLifetimeExtender.java +++ b/packages/SystemUI/src/com/android/systemui/ForegroundServiceLifetimeExtender.java @@ -50,13 +50,13 @@ public class ForegroundServiceLifetimeExtender implements NotificationLifetimeEx @Override public boolean shouldExtendLifetime(@NonNull NotificationEntry entry) { - if ((entry.notification.getNotification().flags + if ((entry.getSbn().getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) == 0) { return false; } long currentTime = System.currentTimeMillis(); - return currentTime - entry.notification.getPostTime() < MIN_FGS_TIME_MS; + return currentTime - entry.getSbn().getPostTime() < MIN_FGS_TIME_MS; } @Override @@ -79,12 +79,12 @@ public class ForegroundServiceLifetimeExtender implements NotificationLifetimeEx if (mManagedEntries.contains(entry)) { mManagedEntries.remove(entry); if (mNotificationSafeToRemoveCallback != null) { - mNotificationSafeToRemoveCallback.onSafeToRemove(entry.key); + mNotificationSafeToRemoveCallback.onSafeToRemove(entry.getKey()); } } }; long delayAmt = MIN_FGS_TIME_MS - - (System.currentTimeMillis() - entry.notification.getPostTime()); + - (System.currentTimeMillis() - entry.getSbn().getPostTime()); mHandler.postDelayed(r, delayAmt); } } diff --git a/packages/SystemUI/src/com/android/systemui/ForegroundServiceNotificationListener.java b/packages/SystemUI/src/com/android/systemui/ForegroundServiceNotificationListener.java index f9d877142d21..4a3b6df6ac90 100644 --- a/packages/SystemUI/src/com/android/systemui/ForegroundServiceNotificationListener.java +++ b/packages/SystemUI/src/com/android/systemui/ForegroundServiceNotificationListener.java @@ -50,12 +50,12 @@ public class ForegroundServiceNotificationListener { notificationEntryManager.addNotificationEntryListener(new NotificationEntryListener() { @Override public void onPendingEntryAdded(NotificationEntry entry) { - addNotification(entry.notification, entry.getImportance()); + addNotification(entry.getSbn(), entry.getImportance()); } @Override public void onPostEntryUpdated(NotificationEntry entry) { - updateNotification(entry.notification, entry.getImportance()); + updateNotification(entry.getSbn(), entry.getImportance()); } @Override @@ -63,7 +63,7 @@ public class ForegroundServiceNotificationListener { NotificationEntry entry, NotificationVisibility visibility, boolean removedByUser) { - removeNotification(entry.notification); + removeNotification(entry.getSbn()); } }); diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java index c3cee35d37fb..7600b2f3ed7a 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java @@ -83,23 +83,23 @@ class Bubble { private boolean mSuppressFlyout; public static String groupId(NotificationEntry entry) { - UserHandle user = entry.notification.getUser(); - return user.getIdentifier() + "|" + entry.notification.getPackageName(); + UserHandle user = entry.getSbn().getUser(); + return user.getIdentifier() + "|" + entry.getSbn().getPackageName(); } /** Used in tests when no UI is required. */ @VisibleForTesting(visibility = PRIVATE) Bubble(Context context, NotificationEntry e) { mEntry = e; - mKey = e.key; - mLastUpdated = e.notification.getPostTime(); + mKey = e.getKey(); + mLastUpdated = e.getSbn().getPostTime(); mGroupId = groupId(e); PackageManager pm = context.getPackageManager(); ApplicationInfo info; try { info = pm.getApplicationInfo( - mEntry.notification.getPackageName(), + mEntry.getSbn().getPackageName(), PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.MATCH_DIRECT_BOOT_UNAWARE @@ -107,10 +107,10 @@ class Bubble { if (info != null) { mAppName = String.valueOf(pm.getApplicationLabel(info)); } - Drawable appIcon = pm.getApplicationIcon(mEntry.notification.getPackageName()); - mUserBadgedAppIcon = pm.getUserBadgedIcon(appIcon, mEntry.notification.getUser()); + Drawable appIcon = pm.getApplicationIcon(mEntry.getSbn().getPackageName()); + mUserBadgedAppIcon = pm.getUserBadgedIcon(appIcon, mEntry.getSbn().getUser()); } catch (PackageManager.NameNotFoundException unused) { - mAppName = mEntry.notification.getPackageName(); + mAppName = mEntry.getSbn().getPackageName(); } } @@ -127,7 +127,7 @@ class Bubble { } public String getPackageName() { - return mEntry.notification.getPackageName(); + return mEntry.getSbn().getPackageName(); } public String getAppName() { @@ -190,7 +190,7 @@ class Bubble { void updateEntry(NotificationEntry entry) { mEntry = entry; - mLastUpdated = entry.notification.getPostTime(); + mLastUpdated = entry.getSbn().getPostTime(); if (mInflated) { mIconView.update(this); mExpandedView.update(this); @@ -287,7 +287,7 @@ class Bubble { * is an ongoing bubble. */ boolean isOngoing() { - int flags = mEntry.notification.getNotification().flags; + int flags = mEntry.getSbn().getNotification().flags; return (flags & Notification.FLAG_FOREGROUND_SERVICE) != 0; } @@ -296,8 +296,8 @@ class Bubble { boolean useRes = data.getDesiredHeightResId() != 0; if (useRes) { return getDimenForPackageUser(context, data.getDesiredHeightResId(), - mEntry.notification.getPackageName(), - mEntry.notification.getUser().getIdentifier()); + mEntry.getSbn().getPackageName(), + mEntry.getSbn().getUser().getIdentifier()); } else { return data.getDesiredHeight() * context.getResources().getDisplayMetrics().density; @@ -316,7 +316,7 @@ class Bubble { @Nullable PendingIntent getBubbleIntent(Context context) { - Notification notif = mEntry.notification.getNotification(); + Notification notif = mEntry.getSbn().getNotification(); Notification.BubbleMetadata data = notif.getBubbleMetadata(); if (BubbleController.canLaunchInActivityView(context, mEntry) && data != null) { return data.getIntent(); @@ -327,7 +327,7 @@ class Bubble { Intent getSettingsIntent() { final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS); intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName()); - intent.putExtra(Settings.EXTRA_APP_UID, mEntry.notification.getUid()); + intent.putExtra(Settings.EXTRA_APP_UID, mEntry.getSbn().getUid()); intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); @@ -339,7 +339,7 @@ class Bubble { * notification, based on its type. Returns null if there should not be an update message. */ CharSequence getUpdateMessage(Context context) { - final Notification underlyingNotif = mEntry.notification.getNotification(); + final Notification underlyingNotif = mEntry.getSbn().getNotification(); final Class<? extends Notification.Style> style = underlyingNotif.getNotificationStyle(); try { diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index 9568a18e5ca3..0231b562ad04 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -262,7 +262,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi // More notifications could be added causing summary to no longer // be suppressed -- in this case need to remove the key. final String groupKey = group.summary != null - ? group.summary.notification.getGroupKey() + ? group.summary.getSbn().getGroupKey() : null; if (!suppressed && groupKey != null && mBubbleData.isSummarySuppressed(groupKey)) { @@ -346,7 +346,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi return; } for (NotificationEntry e : notificationData.getNotificationsForCurrentUser()) { - if (savedBubbleKeys.contains(e.key) + if (savedBubbleKeys.contains(e.getKey()) && mNotificationInterruptionStateProvider.shouldBubbleUp(e) && canLaunchInActivityView(mContext, e)) { updateBubble(e, /* suppressFlyout= */ true); @@ -445,7 +445,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi boolean isBubbleAndSuppressed = mBubbleData.hasBubbleWithKey(key) && !mBubbleData.getBubbleWithKey(key).showInShadeWhenBubble(); NotificationEntry entry = mNotificationEntryManager.getNotificationData().get(key); - String groupKey = entry != null ? entry.notification.getGroupKey() : null; + String groupKey = entry != null ? entry.getSbn().getGroupKey() : null; boolean isSuppressedSummary = mBubbleData.isSummarySuppressed(groupKey); boolean isSummary = key.equals(mBubbleData.getSummaryKey(groupKey)); return (isSummary && isSuppressedSummary) || isBubbleAndSuppressed; @@ -528,14 +528,14 @@ public class BubbleController implements ConfigurationController.ConfigurationLi @Override public boolean onNotificationRemoveRequested(String key, int reason) { NotificationEntry entry = mNotificationEntryManager.getNotificationData().get(key); - String groupKey = entry != null ? entry.notification.getGroupKey() : null; + String groupKey = entry != null ? entry.getSbn().getGroupKey() : null; ArrayList<Bubble> bubbleChildren = mBubbleData.getBubblesInGroup(groupKey); boolean inBubbleData = mBubbleData.hasBubbleWithKey(key); boolean isSuppressedSummary = (mBubbleData.isSummarySuppressed(groupKey) && mBubbleData.getSummaryKey(groupKey).equals(key)); boolean isSummary = entry != null - && entry.notification.getNotification().isGroupSummary(); + && entry.getSbn().getNotification().isGroupSummary(); boolean isSummaryOfBubbles = (isSuppressedSummary || isSummary) && bubbleChildren != null && !bubbleChildren.isEmpty(); @@ -566,7 +566,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi bubble.setShowInShadeWhenBubble(false); bubble.setShowBubbleDot(false); if (mStackView != null) { - mStackView.updateDotVisibility(entry.key); + mStackView.updateDotVisibility(entry.getKey()); } mNotificationEntryManager.updateNotifications( "BubbleController.onNotificationRemoveRequested"); @@ -582,7 +582,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi private boolean handleSummaryRemovalInterception(NotificationEntry summary, boolean userRemovedNotif) { - String groupKey = summary.notification.getGroupKey(); + String groupKey = summary.getSbn().getGroupKey(); ArrayList<Bubble> bubbleChildren = mBubbleData.getBubblesInGroup(groupKey); if (userRemovedNotif) { @@ -603,11 +603,11 @@ public class BubbleController implements ConfigurationController.ConfigurationLi // If the summary was auto-generated we don't need to keep that notification around // because apps can't cancel it; so we only intercept & suppress real summaries. - boolean isAutogroupSummary = (summary.notification.getNotification().flags + boolean isAutogroupSummary = (summary.getSbn().getNotification().flags & FLAG_AUTOGROUP_SUMMARY) != 0; if (!isAutogroupSummary) { - mBubbleData.addSummaryToSuppress(summary.notification.getGroupKey(), - summary.key); + mBubbleData.addSummaryToSuppress(summary.getSbn().getGroupKey(), + summary.getKey()); // Tell shade to update for the suppression mNotificationEntryManager.updateNotifications( "BubbleController.handleSummaryRemovalInterception"); @@ -641,11 +641,11 @@ public class BubbleController implements ConfigurationController.ConfigurationLi public void onPreEntryUpdated(NotificationEntry entry) { boolean shouldBubble = mNotificationInterruptionStateProvider.shouldBubbleUp(entry) && canLaunchInActivityView(mContext, entry); - if (!shouldBubble && mBubbleData.hasBubbleWithKey(entry.key)) { + if (!shouldBubble && mBubbleData.hasBubbleWithKey(entry.getKey())) { // It was previously a bubble but no longer a bubble -- lets remove it - removeBubble(entry.key, DISMISS_NO_LONGER_BUBBLE); + removeBubble(entry.getKey(), DISMISS_NO_LONGER_BUBBLE); } else if (shouldBubble) { - Bubble b = mBubbleData.getBubbleWithKey(entry.key); + Bubble b = mBubbleData.getBubbleWithKey(entry.getKey()); updateBubble(entry); } } @@ -695,10 +695,10 @@ public class BubbleController implements ConfigurationController.ConfigurationLi && !bubble.showInShadeWhenBubble()) { // The bubble is gone & the notification is gone, time to actually remove it mNotificationEntryManager.performRemoveNotification( - bubble.getEntry().notification, UNDEFINED_DISMISS_REASON); + bubble.getEntry().getSbn(), UNDEFINED_DISMISS_REASON); } else { // Update the flag for SysUI - bubble.getEntry().notification.getNotification().flags &= ~FLAG_BUBBLE; + bubble.getEntry().getSbn().getNotification().flags &= ~FLAG_BUBBLE; // Make sure NoMan knows it's not a bubble anymore so anyone querying it // will get right result back @@ -712,7 +712,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi // Check if removed bubble has an associated suppressed group summary that needs // to be removed now. - final String groupKey = bubble.getEntry().notification.getGroupKey(); + final String groupKey = bubble.getEntry().getSbn().getGroupKey(); if (mBubbleData.isSummarySuppressed(groupKey) && mBubbleData.getBubblesInGroup(groupKey).isEmpty()) { // Time to actually remove the summary. @@ -721,20 +721,21 @@ public class BubbleController implements ConfigurationController.ConfigurationLi NotificationEntry entry = mNotificationEntryManager.getNotificationData().get(notifKey); mNotificationEntryManager.performRemoveNotification( - entry.notification, UNDEFINED_DISMISS_REASON); + entry.getSbn(), UNDEFINED_DISMISS_REASON); } // Check if summary should be removed from NoManGroup NotificationEntry summary = mNotificationGroupManager.getLogicalGroupSummary( - bubble.getEntry().notification); + bubble.getEntry().getSbn()); if (summary != null) { ArrayList<NotificationEntry> summaryChildren = - mNotificationGroupManager.getLogicalChildren(summary.notification); - boolean isSummaryThisNotif = summary.key.equals(bubble.getEntry().key); + mNotificationGroupManager.getLogicalChildren(summary.getSbn()); + boolean isSummaryThisNotif = summary.getKey().equals( + bubble.getEntry().getKey()); if (!isSummaryThisNotif && (summaryChildren == null || summaryChildren.isEmpty())) { mNotificationEntryManager.performRemoveNotification( - summary.notification, UNDEFINED_DISMISS_REASON); + summary.getSbn(), UNDEFINED_DISMISS_REASON); } } } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java index d43e030ed9eb..2f7f47b6cda7 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java @@ -183,7 +183,7 @@ public class BubbleData { if (DEBUG_BUBBLE_DATA) { Log.d(TAG, "notificationEntryUpdated: " + entry); } - Bubble bubble = getBubbleWithKey(entry.key); + Bubble bubble = getBubbleWithKey(entry.getKey()); suppressFlyout = !entry.isVisuallyInterruptive || suppressFlyout; if (bubble == null) { @@ -217,7 +217,7 @@ public class BubbleData { if (DEBUG_BUBBLE_DATA) { Log.d(TAG, "notificationEntryRemoved: entry=" + entry + " reason=" + reason); } - doRemove(entry.key, reason); + doRemove(entry.getKey(), reason); dispatchPendingChanges(); } @@ -290,7 +290,7 @@ public class BubbleData { return bubbleChildren; } for (Bubble b : mBubbles) { - if (groupKey.equals(b.getEntry().notification.getGroupKey())) { + if (groupKey.equals(b.getEntry().getSbn().getGroupKey())) { bubbleChildren.add(b); } } @@ -633,7 +633,8 @@ public class BubbleData { try { deleteIntent.send(); } catch (PendingIntent.CanceledException e) { - Log.w(TAG, "Failed to send delete intent for bubble with key: " + entry.key); + Log.w(TAG, "Failed to send delete intent for bubble with key: " + + entry.getKey()); } } } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java index 6f953d584589..1d9f6b27fcdd 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java @@ -501,7 +501,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList if (id == R.id.settings_button) { Intent intent = mBubble.getSettingsIntent(); mStackView.collapseStack(() -> { - mContext.startActivityAsUser(intent, mBubble.getEntry().notification.getUser()); + mContext.startActivityAsUser(intent, mBubble.getEntry().getSbn().getUser()); logBubbleClickEvent(mBubble, StatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_SETTINGS); }); @@ -609,7 +609,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList * @param action the user interaction enum. */ private void logBubbleClickEvent(Bubble bubble, int action) { - StatusBarNotification notification = bubble.getEntry().notification; + StatusBarNotification notification = bubble.getEntry().getSbn(); StatsLog.write(StatsLog.BUBBLE_UI_CHANGED, notification.getPackageName(), notification.getNotification().getChannelId(), diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index 340dced1043f..e5af3897dff2 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -629,7 +629,7 @@ public class BubbleStackView extends FrameLayout { } Bubble topBubble = mBubbleData.getBubbles().get(0); String appName = topBubble.getAppName(); - Notification notification = topBubble.getEntry().notification.getNotification(); + Notification notification = topBubble.getEntry().getSbn().getNotification(); CharSequence titleCharSeq = notification.extras.getCharSequence(Notification.EXTRA_TITLE); String titleStr = getResources().getString(R.string.stream_notification); if (titleCharSeq != null) { @@ -1681,7 +1681,7 @@ public class BubbleStackView extends FrameLayout { */ private void logBubbleEvent(@Nullable Bubble bubble, int action) { if (bubble == null || bubble.getEntry() == null - || bubble.getEntry().notification == null) { + || bubble.getEntry().getSbn() == null) { StatsLog.write(StatsLog.BUBBLE_UI_CHANGED, null /* package name */, null /* notification channel */, @@ -1695,7 +1695,7 @@ public class BubbleStackView extends FrameLayout { false /* on-going bubble */, false /* isAppForeground (unused) */); } else { - StatusBarNotification notification = bubble.getEntry().notification; + StatusBarNotification notification = bubble.getEntry().getSbn(); StatsLog.write(StatsLog.BUBBLE_UI_CHANGED, notification.getPackageName(), notification.getNotification().getChannelId(), diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java index 4512aa822e3b..780c3148a324 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java @@ -230,7 +230,7 @@ public class BubbleView extends FrameLayout { } // Update icon. Notification.BubbleMetadata metadata = mBubble.getEntry().getBubbleMetadata(); - Notification n = mBubble.getEntry().notification.getNotification(); + Notification n = mBubble.getEntry().getSbn().getNotification(); Icon ic = metadata.getIcon(); boolean needsTint = ic.getType() != Icon.TYPE_ADAPTIVE_BITMAP; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java index 33bcefb323f8..e24a3625769c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java @@ -65,7 +65,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim Log.v(TAG, "showNotification"); } addAlertEntry(entry); - updateNotification(entry.key, true /* alert */); + updateNotification(entry.getKey(), true /* alert */); entry.setInterruption(); } @@ -182,7 +182,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim protected final void addAlertEntry(@NonNull NotificationEntry entry) { AlertEntry alertEntry = createAlertEntry(); alertEntry.setEntry(entry); - mAlertEntries.put(entry.key, alertEntry); + mAlertEntries.put(entry.getKey(), alertEntry); onAlertEntryAdded(alertEntry); entry.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); } @@ -251,7 +251,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim @Override public boolean shouldExtendLifetime(NotificationEntry entry) { - return !canRemoveImmediately(entry.key); + return !canRemoveImmediately(entry.getKey()); } @Override @@ -260,7 +260,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim mExtendedLifetimeAlertEntries.add(entry); // We need to make sure that entries are stopping to alert eventually, let's remove // this as soon as possible. - AlertEntry alertEntry = mAlertEntries.get(entry.key); + AlertEntry alertEntry = mAlertEntries.get(entry.getKey()); alertEntry.removeAsSoonAsPossible(); } else { mExtendedLifetimeAlertEntries.remove(entry); @@ -276,7 +276,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim @Nullable protected Runnable mRemoveAlertRunnable; public void setEntry(@NonNull final NotificationEntry entry) { - setEntry(entry, () -> removeAlertEntry(entry.key)); + setEntry(entry, () -> removeAlertEntry(entry.getKey())); } public void setEntry(@NonNull final NotificationEntry entry, @@ -332,7 +332,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim public int compareTo(@NonNull AlertEntry alertEntry) { return (mPostTime < alertEntry.mPostTime) ? 1 : ((mPostTime == alertEntry.mPostTime) - ? mEntry.key.compareTo(alertEntry.mEntry.key) : -1); + ? mEntry.getKey().compareTo(alertEntry.mEntry.getKey()) : -1); } public void reset() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java index 6ffea79c420a..7adf7af89f0d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java @@ -323,7 +323,7 @@ public class NotificationLockscreenUserManagerImpl implements exceedsPriorityThreshold = entry.getBucket() != BUCKET_SILENT; } else { exceedsPriorityThreshold = - !getEntryManager().getNotificationData().isAmbient(entry.key); + !getEntryManager().getNotificationData().isAmbient(entry.getKey()); } return mShowLockscreenNotifications && exceedsPriorityThreshold; } @@ -445,15 +445,15 @@ public class NotificationLockscreenUserManagerImpl implements /** @return true if the entry needs redaction when on the lockscreen. */ public boolean needsRedaction(NotificationEntry ent) { - int userId = ent.notification.getUserId(); + int userId = ent.getSbn().getUserId(); boolean currentUserWantsRedaction = !userAllowsPrivateNotificationsInPublic(mCurrentUserId); boolean notiUserWantsRedaction = !userAllowsPrivateNotificationsInPublic(userId); boolean redactedLockscreen = currentUserWantsRedaction || notiUserWantsRedaction; boolean notificationRequestsRedaction = - ent.notification.getNotification().visibility == Notification.VISIBILITY_PRIVATE; - boolean userForcesRedaction = packageHasVisibilityOverride(ent.notification.getKey()); + ent.getSbn().getNotification().visibility == Notification.VISIBILITY_PRIVATE; + boolean userForcesRedaction = packageHasVisibilityOverride(ent.getSbn().getKey()); return userForcesRedaction || notificationRequestsRedaction && redactedLockscreen; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java index 3616b541741c..0988e347945c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java @@ -204,7 +204,7 @@ public class NotificationMediaManager implements Dumpable { NotificationEntry entry, NotificationVisibility visibility, boolean removedByUser) { - onNotificationRemoved(entry.key); + onNotificationRemoved(entry.getKey()); } }); @@ -284,7 +284,7 @@ public class NotificationMediaManager implements Dumpable { if (entry.isMediaNotification()) { final MediaSession.Token token = - entry.notification.getNotification().extras.getParcelable( + entry.getSbn().getNotification().extras.getParcelable( Notification.EXTRA_MEDIA_SESSION); if (token != null) { MediaController aController = new MediaController(mContext, token); @@ -292,7 +292,7 @@ public class NotificationMediaManager implements Dumpable { getMediaControllerPlaybackState(aController)) { if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " - + entry.notification.getKey()); + + entry.getSbn().getKey()); } mediaNotification = entry; controller = aController; @@ -321,10 +321,10 @@ public class NotificationMediaManager implements Dumpable { for (int i = 0; i < N; i++) { final NotificationEntry entry = activeNotifications.get(i); - if (entry.notification.getPackageName().equals(pkg)) { + if (entry.getSbn().getPackageName().equals(pkg)) { if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: found controller matching " - + entry.notification.getKey()); + + entry.getSbn().getKey()); } controller = aController; mediaNotification = entry; @@ -351,8 +351,8 @@ public class NotificationMediaManager implements Dumpable { } if (mediaNotification != null - && !mediaNotification.notification.getKey().equals(mMediaNotificationKey)) { - mMediaNotificationKey = mediaNotification.notification.getKey(); + && !mediaNotification.getSbn().getKey().equals(mMediaNotificationKey)) { + mMediaNotificationKey = mediaNotification.getSbn().getKey(); if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" + mMediaNotificationKey); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java index c9050d492191..23968d59d58f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java @@ -293,7 +293,7 @@ public class NotificationRemoteInputManager implements Dumpable { mSmartReplyController.stopSending(entry); if (removedByUser && entry != null) { - onPerformRemoveNotification(entry, entry.key); + onPerformRemoveNotification(entry, entry.getKey()); } } }); @@ -307,8 +307,8 @@ public class NotificationRemoteInputManager implements Dumpable { @Override public void onRemoteInputSent(NotificationEntry entry) { if (FORCE_REMOTE_INPUT_HISTORY - && isNotificationKeptForRemoteInputHistory(entry.key)) { - mNotificationLifetimeFinishedCallback.onSafeToRemove(entry.key); + && isNotificationKeptForRemoteInputHistory(entry.getKey())) { + mNotificationLifetimeFinishedCallback.onSafeToRemove(entry.getKey()); } else if (mEntriesKeptForRemoteInputActive.contains(entry)) { // We're currently holding onto this notification, but from the apps point of // view it is already canceled, so we'll need to cancel it on the apps behalf @@ -316,18 +316,18 @@ public class NotificationRemoteInputManager implements Dumpable { // bit. mMainHandler.postDelayed(() -> { if (mEntriesKeptForRemoteInputActive.remove(entry)) { - mNotificationLifetimeFinishedCallback.onSafeToRemove(entry.key); + mNotificationLifetimeFinishedCallback.onSafeToRemove(entry.getKey()); } }, REMOTE_INPUT_KEPT_ENTRY_AUTO_CANCEL_DELAY); } try { - mBarService.onNotificationDirectReplied(entry.notification.getKey()); + mBarService.onNotificationDirectReplied(entry.getSbn().getKey()); if (entry.editedSuggestionInfo != null) { boolean modifiedBeforeSending = !TextUtils.equals(entry.remoteInputText, entry.editedSuggestionInfo.originalText); mBarService.onNotificationSmartReplySent( - entry.notification.getKey(), + entry.getSbn().getKey(), entry.editedSuggestionInfo.index, entry.editedSuggestionInfo.originalText, NotificationLogger @@ -487,7 +487,7 @@ public class NotificationRemoteInputManager implements Dumpable { NotificationEntry entry = mEntriesKeptForRemoteInputActive.valueAt(i); mRemoteInputController.removeRemoteInput(entry, null); if (mNotificationLifetimeFinishedCallback != null) { - mNotificationLifetimeFinishedCallback.onSafeToRemove(entry.key); + mNotificationLifetimeFinishedCallback.onSafeToRemove(entry.getKey()); } } mEntriesKeptForRemoteInputActive.clear(); @@ -501,14 +501,15 @@ public class NotificationRemoteInputManager implements Dumpable { if (!FORCE_REMOTE_INPUT_HISTORY) { return false; } - return (mRemoteInputController.isSpinning(entry.key) || entry.hasJustSentRemoteInput()); + return (mRemoteInputController.isSpinning(entry.getKey()) + || entry.hasJustSentRemoteInput()); } public boolean shouldKeepForSmartReplyHistory(NotificationEntry entry) { if (!FORCE_REMOTE_INPUT_HISTORY) { return false; } - return mSmartReplyController.isSendingSmartReply(entry.key); + return mSmartReplyController.isSendingSmartReply(entry.getKey()); } public void checkRemoteInputOutside(MotionEvent event) { @@ -529,7 +530,7 @@ public class NotificationRemoteInputManager implements Dumpable { @VisibleForTesting StatusBarNotification rebuildNotificationWithRemoteInput(NotificationEntry entry, CharSequence remoteInputText, boolean showSpinner) { - StatusBarNotification sbn = entry.notification; + StatusBarNotification sbn = entry.getSbn(); Notification.Builder b = Notification.Builder .recoverBuilder(mContext, sbn.getNotification().clone()); @@ -637,12 +638,12 @@ public class NotificationRemoteInputManager implements Dumpable { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Keeping notification around after sending remote input " - + entry.key); + + entry.getKey()); } - mKeysKeptForRemoteInputHistory.add(entry.key); + mKeysKeptForRemoteInputHistory.add(entry.getKey()); } else { - mKeysKeptForRemoteInputHistory.remove(entry.key); + mKeysKeptForRemoteInputHistory.remove(entry.getKey()); } } } @@ -675,12 +676,12 @@ public class NotificationRemoteInputManager implements Dumpable { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Keeping notification around after sending smart reply " - + entry.key); + + entry.getKey()); } - mKeysKeptForRemoteInputHistory.add(entry.key); + mKeysKeptForRemoteInputHistory.add(entry.getKey()); } else { - mKeysKeptForRemoteInputHistory.remove(entry.key); + mKeysKeptForRemoteInputHistory.remove(entry.getKey()); mSmartReplyController.stopSending(entry); } } @@ -701,7 +702,7 @@ public class NotificationRemoteInputManager implements Dumpable { if (shouldExtend) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Keeping notification around while remote input active " - + entry.key); + + entry.getKey()); } mEntriesKeptForRemoteInputActive.add(entry); } else { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationUiAdjustment.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationUiAdjustment.java index 266fe8dc2708..564d8bc14c8c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationUiAdjustment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationUiAdjustment.java @@ -54,7 +54,7 @@ public class NotificationUiAdjustment { public static NotificationUiAdjustment extractFromNotificationEntry( NotificationEntry entry) { return new NotificationUiAdjustment( - entry.key, entry.getSmartActions(), entry.getSmartReplies()); + entry.getKey(), entry.getSmartActions(), entry.getSmartReplies()); } public static boolean needReinflate( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java index 50d9bae77bea..c2bb5b7693c2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java @@ -147,13 +147,13 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle for (int i = 0; i < N; i++) { NotificationEntry ent = activeNotifications.get(i); if (ent.isRowDismissed() || ent.isRowRemoved() - || mBubbleController.isBubbleNotificationSuppressedFromShade(ent.key)) { + || mBubbleController.isBubbleNotificationSuppressedFromShade(ent.getKey())) { // we don't want to update removed notifications because they could // temporarily become children if they were isolated before. continue; } - int userId = ent.notification.getUserId(); + int userId = ent.getSbn().getUserId(); // Display public version of the notification if we need to redact. // TODO: This area uses a lot of calls into NotificationLockscreenUserManager. @@ -174,8 +174,8 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle currentUserId); ent.setSensitive(sensitive, deviceSensitive); ent.getRow().setNeedsRedaction(needsRedaction); - if (mGroupManager.isChildInGroupWithSummary(ent.notification)) { - NotificationEntry summary = mGroupManager.getGroupSummary(ent.notification); + if (mGroupManager.isChildInGroupWithSummary(ent.getSbn())) { + NotificationEntry summary = mGroupManager.getGroupSummary(ent.getSbn()); List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(summary.getRow()); if (orderedChildren == null) { @@ -382,7 +382,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle ExpandableNotificationRow row = stack.pop(); NotificationEntry entry = row.getEntry(); boolean isChildNotification = - mGroupManager.isChildInGroupWithSummary(entry.notification); + mGroupManager.isChildInGroupWithSummary(entry.getSbn()); row.setOnKeyguard(onKeyguard); @@ -394,15 +394,15 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle && !row.isLowPriority())); } - int userId = entry.notification.getUserId(); + int userId = entry.getSbn().getUserId(); boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup( - entry.notification) && !entry.isRowRemoved(); + entry.getSbn()) && !entry.isRowRemoved(); boolean showOnKeyguard = mLockscreenUserManager.shouldShowOnKeyguard(entry); if (!showOnKeyguard) { // min priority notifications should show if their summary is showing - if (mGroupManager.isChildInGroupWithSummary(entry.notification)) { + if (mGroupManager.isChildInGroupWithSummary(entry.getSbn())) { NotificationEntry summary = mGroupManager.getLogicalGroupSummary( - entry.notification); + entry.getSbn()); if (summary != null && mLockscreenUserManager.shouldShowOnKeyguard(summary)) { showOnKeyguard = true; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java b/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java index 736b9ebea5c3..7bdb21d0eac5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java @@ -58,9 +58,9 @@ public class SmartReplyController { public void smartReplySent(NotificationEntry entry, int replyIndex, CharSequence reply, int notificationLocation, boolean modifiedBeforeSending) { mCallback.onSmartReplySent(entry, reply); - mSendingKeys.add(entry.key); + mSendingKeys.add(entry.getKey()); try { - mBarService.onNotificationSmartReplySent(entry.notification.getKey(), replyIndex, reply, + mBarService.onNotificationSmartReplySent(entry.getSbn().getKey(), replyIndex, reply, notificationLocation, modifiedBeforeSending); } catch (RemoteException e) { // Nothing to do, system going down @@ -74,14 +74,14 @@ public class SmartReplyController { NotificationEntry entry, int actionIndex, Notification.Action action, boolean generatedByAssistant) { final int count = mEntryManager.getNotificationData().getActiveNotifications().size(); - final int rank = mEntryManager.getNotificationData().getRank(entry.key); + final int rank = mEntryManager.getNotificationData().getRank(entry.getKey()); NotificationVisibility.NotificationLocation location = NotificationLogger.getNotificationLocation(entry); final NotificationVisibility nv = NotificationVisibility.obtain( - entry.key, rank, count, true, location); + entry.getKey(), rank, count, true, location); try { mBarService.onNotificationActionClick( - entry.key, actionIndex, action, nv, generatedByAssistant); + entry.getKey(), actionIndex, action, nv, generatedByAssistant); } catch (RemoteException e) { // Nothing to do, system going down } @@ -101,7 +101,7 @@ public class SmartReplyController { public void smartSuggestionsAdded(final NotificationEntry entry, int replyCount, int actionCount, boolean generatedByAssistant, boolean editBeforeSending) { try { - mBarService.onNotificationSmartSuggestionsAdded(entry.notification.getKey(), replyCount, + mBarService.onNotificationSmartSuggestionsAdded(entry.getSbn().getKey(), replyCount, actionCount, generatedByAssistant, editBeforeSending); } catch (RemoteException e) { // Nothing to do, system going down @@ -110,7 +110,7 @@ public class SmartReplyController { public void stopSending(final NotificationEntry entry) { if (entry != null) { - mSendingKeys.remove(entry.notification.getKey()); + mSendingKeys.remove(entry.getSbn().getKey()); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java index d71d40781f2e..005f01dc8df0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java @@ -80,7 +80,7 @@ public class NotificationAlertingManager { NotificationEntry entry, NotificationVisibility visibility, boolean removedByUser) { - stopAlerting(entry.key); + stopAlerting(entry.getKey()); } }); } @@ -104,7 +104,7 @@ public class NotificationAlertingManager { mHeadsUpManager.showNotification(entry); if (!mShadeController.get().isDozing()) { // Mark as seen immediately - setNotificationShown(entry.notification); + setNotificationShown(entry.getSbn()); } } else { entry.freeContentViewWhenSafe(FLAG_CONTENT_VIEW_HEADS_UP); @@ -113,16 +113,16 @@ public class NotificationAlertingManager { } private void updateAlertState(NotificationEntry entry) { - boolean alertAgain = alertAgain(entry, entry.notification.getNotification()); + boolean alertAgain = alertAgain(entry, entry.getSbn().getNotification()); boolean shouldAlert; shouldAlert = mNotificationInterruptionStateProvider.shouldHeadsUp(entry); - final boolean wasAlerting = mHeadsUpManager.isAlerting(entry.key); + final boolean wasAlerting = mHeadsUpManager.isAlerting(entry.getKey()); if (wasAlerting) { if (shouldAlert) { - mHeadsUpManager.updateNotification(entry.key, alertAgain); - } else if (!mHeadsUpManager.isEntryAutoHeadsUpped(entry.key)) { + mHeadsUpManager.updateNotification(entry.getKey(), alertAgain); + } else if (!mHeadsUpManager.isEntryAutoHeadsUpped(entry.getKey())) { // We don't want this to be interrupting anymore, let's remove it - mHeadsUpManager.removeNotification(entry.key, false /* removeImmediately */); + mHeadsUpManager.removeNotification(entry.getKey(), false /* removeImmediately */); } } else if (shouldAlert && alertAgain) { // This notification was updated to be alerting, show it! diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index 936ac49090f7..f56586802a68 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -110,7 +110,7 @@ public class NotificationEntryManager implements pw.println("null"); } else { for (NotificationEntry entry : mPendingNotifications.values()) { - pw.println(entry.notification); + pw.println(entry.getSbn()); } } pw.println(" Lifetime-extended notifications:"); @@ -119,7 +119,7 @@ public class NotificationEntryManager implements } else { for (Map.Entry<NotificationEntry, NotificationLifetimeExtender> entry : mRetainedNotifications.entrySet()) { - pw.println(" " + entry.getKey().notification + " retained by " + pw.println(" " + entry.getKey().getSbn() + " retained by " + entry.getValue().getClass().getName()); } } @@ -242,11 +242,11 @@ public class NotificationEntryManager implements @Override public void onAsyncInflationFinished(NotificationEntry entry, @InflationFlag int inflatedFlags) { - mPendingNotifications.remove(entry.key); + mPendingNotifications.remove(entry.getKey()); // If there was an async task started after the removal, we don't want to add it back to // the list, otherwise we might get leaks. if (!entry.isRowRemoved()) { - boolean isNew = mNotificationData.get(entry.key) == null; + boolean isNew = mNotificationData.get(entry.getKey()) == null; if (isNew) { for (NotificationEntryListener listener : mNotificationEntryListeners) { listener.onEntryInflated(entry, inflatedFlags); @@ -372,7 +372,7 @@ public class NotificationEntryManager implements private void handleGroupSummaryRemoved(String key) { NotificationEntry entry = mNotificationData.get(key); if (entry != null && entry.rowExists() && entry.isSummaryWithChildren()) { - if (entry.notification.getOverrideGroupKey() != null && !entry.isRowDismissed()) { + if (entry.getSbn().getOverrideGroupKey() != null && !entry.isRowDismissed()) { // We don't want to remove children for autobundled notifications as they are not // always cancelled. We only remove them if they were dismissed by the user. return; @@ -383,7 +383,7 @@ public class NotificationEntryManager implements } for (int i = 0; i < childEntries.size(); i++) { NotificationEntry childEntry = childEntries.get(i); - boolean isForeground = (entry.notification.getNotification().flags + boolean isForeground = (entry.getSbn().getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0; boolean keepForReply = getRemoteInputManager().shouldKeepForRemoteInputHistory(childEntry) @@ -507,8 +507,8 @@ public class NotificationEntryManager implements for (NotificationEntry entry : entries) { NotificationUiAdjustment adjustment = NotificationUiAdjustment.extractFromNotificationEntry(entry); - oldAdjustments.put(entry.key, adjustment); - oldImportances.put(entry.key, entry.getImportance()); + oldAdjustments.put(entry.getKey(), adjustment); + oldImportances.put(entry.getKey(), entry.getImportance()); } // Populate notification entries from the new rankings. @@ -519,8 +519,8 @@ public class NotificationEntryManager implements for (NotificationEntry entry : entries) { requireBinder().onNotificationRankingUpdated( entry, - oldImportances.get(entry.key), - oldAdjustments.get(entry.key), + oldImportances.get(entry.getKey()), + oldAdjustments.get(entry.getKey()), NotificationUiAdjustment.extractFromNotificationEntry(entry)); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationFilter.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationFilter.java index 5a0b88cbdc28..b1164093acdd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationFilter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationFilter.java @@ -85,7 +85,7 @@ public class NotificationFilter { * @return true if the provided notification should NOT be shown right now. */ public boolean shouldFilterOut(NotificationEntry entry) { - final StatusBarNotification sbn = entry.notification; + final StatusBarNotification sbn = entry.getSbn(); if (!(getEnvironment().isDeviceProvisioned() || showNotificationEvenIfUnprovisioned(sbn))) { return true; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInterruptionStateProvider.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInterruptionStateProvider.java index eadec6a45895..7d09932dcad0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInterruptionStateProvider.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInterruptionStateProvider.java @@ -164,7 +164,7 @@ public class NotificationInterruptionStateProvider { * @return true if the entry should bubble up, false otherwise */ public boolean shouldBubbleUp(NotificationEntry entry) { - final StatusBarNotification sbn = entry.notification; + final StatusBarNotification sbn = entry.getSbn(); if (!canAlertCommon(entry)) { return false; @@ -216,7 +216,7 @@ public class NotificationInterruptionStateProvider { } private boolean shouldHeadsUpWhenAwake(NotificationEntry entry) { - StatusBarNotification sbn = entry.notification; + StatusBarNotification sbn = entry.getSbn(); if (!mUseHeadsUp) { if (DEBUG_HEADS_UP) { @@ -289,7 +289,7 @@ public class NotificationInterruptionStateProvider { * @return true if the entry should ambient pulse, false otherwise */ private boolean shouldHeadsUpWhenDozing(NotificationEntry entry) { - StatusBarNotification sbn = entry.notification; + StatusBarNotification sbn = entry.getSbn(); if (!mAmbientDisplayConfiguration.pulseOnNotificationEnabled(UserHandle.USER_CURRENT)) { if (DEBUG_HEADS_UP) { @@ -336,7 +336,7 @@ public class NotificationInterruptionStateProvider { */ @VisibleForTesting public boolean canAlertCommon(NotificationEntry entry) { - StatusBarNotification sbn = entry.notification; + StatusBarNotification sbn = entry.getSbn(); if (mNotificationFilter.shouldFilterOut(entry)) { if (DEBUG || DEBUG_HEADS_UP) { @@ -363,7 +363,7 @@ public class NotificationInterruptionStateProvider { */ @VisibleForTesting public boolean canAlertAwakeCommon(NotificationEntry entry) { - StatusBarNotification sbn = entry.notification; + StatusBarNotification sbn = entry.getSbn(); if (mPresenter.isDeviceInVrMode()) { if (DEBUG_HEADS_UP) { @@ -423,7 +423,7 @@ public class NotificationInterruptionStateProvider { * @return {@code true} if we should launch the full screen intent */ public boolean shouldLaunchFullScreenIntentWhenAdded(NotificationEntry entry) { - return entry.notification.getNotification().fullScreenIntent != null + return entry.getSbn().getNotification().fullScreenIntent != null && (!shouldHeadsUp(entry) || mStatusBarStateController.getState() == StatusBarState.KEYGUARD); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationListController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationListController.java index 970cbf9aa1e2..533dfb6ee4aa 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationListController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationListController.java @@ -73,7 +73,7 @@ public class NotificationListController { @Override public void onBeforeNotificationAdded(NotificationEntry entry) { - tagForeground(entry.notification); + tagForeground(entry.getSbn()); } }; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java index b8881efc6324..b5513529d7ba 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java @@ -199,7 +199,7 @@ public class NotifCollection { // need to keep its lifetime extended. cancelLifetimeExtension(entry); - entry.setNotification(sbn); + entry.setSbn(sbn); applyRanking(rankingMap); dispatchOnEntryUpdated(entry); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java index 505d46b96e12..623ccca249a5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java @@ -93,10 +93,10 @@ public class NotificationData { new Comparator<NotificationEntry>() { @Override public int compare(NotificationEntry a, NotificationEntry b) { - final StatusBarNotification na = a.notification; - final StatusBarNotification nb = b.notification; - int aRank = getRank(a.key); - int bRank = getRank(b.key); + final StatusBarNotification na = a.getSbn(); + final StatusBarNotification nb = b.getSbn(); + int aRank = getRank(a.getKey()); + int bRank = getRank(b.getKey()); boolean aMedia = isImportantMedia(a); boolean bMedia = isImportantMedia(b); @@ -164,7 +164,7 @@ public class NotificationData { final int len = mEntries.size(); for (int i = 0; i < len; i++) { NotificationEntry entry = mEntries.valueAt(i); - final StatusBarNotification sbn = entry.notification; + final StatusBarNotification sbn = entry.getSbn(); if (!getEnvironment().isNotificationForCurrentProfiles(sbn)) { continue; } @@ -180,7 +180,7 @@ public class NotificationData { public void add(NotificationEntry entry) { synchronized (mEntries) { - mEntries.put(entry.notification.getKey(), entry); + mEntries.put(entry.getSbn().getKey(), entry); } mGroupManager.onEntryAdded(entry); @@ -205,8 +205,8 @@ public class NotificationData { StatusBarNotification notification, String reason) { updateRanking(ranking, reason); - final StatusBarNotification oldNotification = entry.notification; - entry.setNotification(notification); + final StatusBarNotification oldNotification = entry.getSbn(); + entry.setSbn(notification); mGroupManager.onEntryUpdated(entry, oldNotification); } @@ -222,9 +222,9 @@ public class NotificationData { final int len = mEntries.size(); for (int i = 0; i < len; i++) { NotificationEntry entry = mEntries.valueAt(i); - if (uid == entry.notification.getUid() - && pkg.equals(entry.notification.getPackageName()) - && key.equals(entry.key)) { + if (uid == entry.getSbn().getUid() + && pkg.equals(entry.getSbn().getPackageName()) + && key.equals(entry.getKey())) { if (showIcon) { entry.mActiveAppOps.add(appOp); } else { @@ -251,7 +251,7 @@ public class NotificationData { final ArrayList<NotificationEntry> logicalChildren = mGroupManager.getLogicalChildren(statusBarNotification); for (NotificationEntry child : logicalChildren) { - if (isHighPriority(child.notification)) { + if (isHighPriority(child.getSbn())) { return true; } } @@ -339,7 +339,7 @@ public class NotificationData { private boolean isImportantMedia(NotificationEntry e) { int importance = e.getRanking().getImportance(); - boolean media = e.key.equals(getMediaManager().getMediaNotificationKey()) + boolean media = e.getKey().equals(getMediaManager().getMediaNotificationKey()) && importance > NotificationManager.IMPORTANCE_MIN; return media; @@ -348,7 +348,7 @@ public class NotificationData { private boolean isSystemMax(NotificationEntry e) { int importance = e.getRanking().getImportance(); boolean sys = importance >= NotificationManager.IMPORTANCE_HIGH - && isSystemNotification(e.notification); + && isSystemNotification(e.getSbn()); return sys; } @@ -369,18 +369,18 @@ public class NotificationData { for (int i = 0; i < len; i++) { NotificationEntry entry = mEntries.valueAt(i); Ranking newRanking = new Ranking(); - if (!getRanking(entry.key, newRanking)) { + if (!getRanking(entry.getKey(), newRanking)) { continue; } entry.setRanking(newRanking); - final StatusBarNotification oldSbn = entry.notification.cloneLight(); + final StatusBarNotification oldSbn = entry.getSbn().cloneLight(); final String overrideGroupKey = newRanking.getOverrideGroupKey(); if (!Objects.equals(oldSbn.getOverrideGroupKey(), overrideGroupKey)) { - entry.notification.setOverrideGroupKey(overrideGroupKey); + entry.getSbn().setOverrideGroupKey(overrideGroupKey); mGroupManager.onEntryUpdated(entry, oldSbn); } - entry.setIsHighPriority(isHighPriority(entry.notification)); + entry.setIsHighPriority(isHighPriority(entry.getSbn())); } } } @@ -481,10 +481,10 @@ public class NotificationData { } private void dumpEntry(PrintWriter pw, String indent, int i, NotificationEntry e) { - getRanking(e.key, mTmpRanking); + getRanking(e.getKey(), mTmpRanking); pw.print(indent); - pw.println(" [" + i + "] key=" + e.key + " icon=" + e.icon); - StatusBarNotification n = e.notification; + pw.println(" [" + i + "] key=" + e.getKey() + " icon=" + e.icon); + StatusBarNotification n = e.getSbn(); pw.print(indent); pw.println(" pkg=" + n.getPackageName() + " id=" + n.getId() + " importance=" + mTmpRanking.getImportance()); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index 076c2af0665e..e004ca7d1f1d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -30,6 +30,7 @@ import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICAT import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR; +import static com.android.internal.util.Preconditions.checkNotNull; import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_ALERTING; import android.annotation.NonNull; @@ -90,8 +91,8 @@ public final class NotificationEntry { private static final long NOT_LAUNCHED_YET = -LAUNCH_COOLDOWN; private static final int COLOR_INVALID = 1; - public final String key; - public StatusBarNotification notification; + private final String mKey; + private StatusBarNotification mSbn; private Ranking mRanking; @@ -175,14 +176,18 @@ public final class NotificationEntry { public NotificationEntry( @NonNull StatusBarNotification sbn, @NonNull Ranking ranking) { - this.key = sbn.getKey(); - setNotification(sbn); + checkNotNull(sbn); + checkNotNull(sbn.getKey()); + checkNotNull(ranking); + + mKey = sbn.getKey(); + setSbn(sbn); setRanking(ranking); } /** The key for this notification. Guaranteed to be immutable and unique */ public String getKey() { - return key; + return mKey; } /** @@ -190,19 +195,23 @@ public final class NotificationEntry { * being the Ranking). This object is swapped out whenever a notification is updated. */ public StatusBarNotification getSbn() { - return notification; + return mSbn; } /** * Should only be called by NotificationEntryManager and friends. * TODO: Make this package-private */ - public void setNotification(StatusBarNotification sbn) { - if (sbn.getKey() != null && key != null && !sbn.getKey().equals(key)) { + public void setSbn(@NonNull StatusBarNotification sbn) { + checkNotNull(sbn); + checkNotNull(sbn.getKey()); + + if (!sbn.getKey().equals(mKey)) { throw new IllegalArgumentException("New key " + sbn.getKey() - + " doesn't match existing key " + key); + + " doesn't match existing key " + mKey); } - notification = sbn; + + mSbn = sbn; updatePeopleList(); } @@ -220,9 +229,12 @@ public final class NotificationEntry { * TODO: Make this package-private */ public void setRanking(@NonNull Ranking ranking) { - if (!ranking.getKey().equals(key)) { + checkNotNull(ranking); + checkNotNull(ranking.getKey()); + + if (!ranking.getKey().equals(mKey)) { throw new IllegalArgumentException("New key " + ranking.getKey() - + " doesn't match existing key " + key); + + " doesn't match existing key " + mKey); } mRanking = ranking; isVisuallyInterruptive = ranking.visuallyInterruptive(); @@ -292,13 +304,13 @@ public final class NotificationEntry { } public boolean isBubble() { - return (notification.getNotification().flags & FLAG_BUBBLE) != 0; + return (mSbn.getNotification().flags & FLAG_BUBBLE) != 0; } private void updatePeopleList() { mAssociatedPeople.clear(); - Bundle extras = notification.getNotification().extras; + Bundle extras = mSbn.getNotification().extras; if (extras == null) { return; } @@ -310,7 +322,7 @@ public final class NotificationEntry { } if (Notification.MessagingStyle.class.equals( - notification.getNotification().getNotificationStyle())) { + mSbn.getNotification().getNotificationStyle())) { final Parcelable[] messages = extras.getParcelableArray(EXTRA_MESSAGES); if (!ArrayUtils.isEmpty(messages)) { for (Notification.MessagingStyle.Message message : @@ -330,7 +342,7 @@ public final class NotificationEntry { * Returns the data needed for a bubble for this notification, if it exists. */ public Notification.BubbleMetadata getBubbleMetadata() { - return notification.getNotification().getBubbleMetadata(); + return mSbn.getNotification().getBubbleMetadata(); } /** @@ -452,7 +464,7 @@ public final class NotificationEntry { }); // Construct the centered icon - if (notification.getNotification().isMediaNotification()) { + if (mSbn.getNotification().isMediaNotification()) { centeredIcon = new StatusBarIconView(context, sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId()), sbn); centeredIcon.setScaleType(ImageView.ScaleType.CENTER_INSIDE); @@ -492,8 +504,8 @@ public final class NotificationEntry { // Update the icon Notification n = sbn.getNotification(); final StatusBarIcon ic = new StatusBarIcon( - notification.getUser(), - notification.getPackageName(), + mSbn.getUser(), + mSbn.getPackageName(), n.getSmallIcon(), n.iconLevel, n.number, @@ -517,7 +529,7 @@ public final class NotificationEntry { public int getContrastedColor(Context context, boolean isLowPriority, int backgroundColor) { int rawColor = isLowPriority ? Notification.COLOR_DEFAULT : - notification.getNotification().color; + mSbn.getNotification().color; if (mCachedContrastColorIsFor == rawColor && mCachedContrastColor != COLOR_INVALID) { return mCachedContrastColor; } @@ -583,7 +595,7 @@ public final class NotificationEntry { if (!hasSentReply) { return false; } - Bundle extras = notification.getNotification().extras; + Bundle extras = mSbn.getNotification().extras; CharSequence[] replyTexts = extras.getCharSequenceArray( Notification.EXTRA_REMOTE_INPUT_HISTORY); if (!ArrayUtils.isEmpty(replyTexts)) { @@ -785,7 +797,7 @@ public final class NotificationEntry { * @see #canViewBeDismissed() */ public boolean isClearable() { - if (notification == null || !notification.isClearable()) { + if (!mSbn.isClearable()) { return false; } @@ -808,15 +820,15 @@ public final class NotificationEntry { @VisibleForTesting boolean isExemptFromDndVisualSuppression() { - if (isNotificationBlockedByPolicy(notification.getNotification())) { + if (isNotificationBlockedByPolicy(mSbn.getNotification())) { return false; } - if ((notification.getNotification().flags + if ((mSbn.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0) { return true; } - if (notification.getNotification().isMediaNotification()) { + if (mSbn.getNotification().isMediaNotification()) { return true; } if (mIsSystemNotification != null && mIsSystemNotification) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRowBinderImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRowBinderImpl.java index e5571b64cc9e..5dbb9c544d7b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRowBinderImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRowBinderImpl.java @@ -135,9 +135,9 @@ public class NotificationRowBinderImpl implements NotificationRowBinder { throws InflationException { ViewGroup parent = mListContainer.getViewParentForNotification(entry); PackageManager pmUser = StatusBar.getPackageManagerForUser(mContext, - entry.notification.getUser().getIdentifier()); + entry.getSbn().getUser().getIdentifier()); - final StatusBarNotification sbn = entry.notification; + final StatusBarNotification sbn = entry.getSbn(); if (entry.rowExists()) { entry.updateIcons(mContext, sbn); entry.reset(); @@ -156,7 +156,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder { private void bindRow(NotificationEntry entry, PackageManager pmUser, StatusBarNotification sbn, ExpandableNotificationRow row, Runnable onDismissRunnable) { - row.setExpansionLogger(mExpansionLogger, entry.notification.getKey()); + row.setExpansionLogger(mExpansionLogger, entry.getSbn().getKey()); row.setBypassController(mKeyguardBypassController); row.setStatusBarStateController(mStatusBarStateController); row.setGroupManager(mGroupManager); @@ -213,8 +213,8 @@ public class NotificationRowBinderImpl implements NotificationRowBinder { entry.reset(); PackageManager pmUser = StatusBar.getPackageManagerForUser( mContext, - entry.notification.getUser().getIdentifier()); - updateNotification(entry, pmUser, entry.notification, entry.getRow()); + entry.getSbn().getUser().getIdentifier()); + updateNotification(entry, pmUser, entry.getSbn(), entry.getRow()); } else { // Once the RowInflaterTask is done, it will pick up the updated entry, so // no-op here. @@ -248,7 +248,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder { // TODO: should updates to the entry be happening somewhere else? entry.setIconTag(R.id.icon_is_pre_L, entry.targetSdk < Build.VERSION_CODES.LOLLIPOP); - entry.autoRedacted = entry.notification.getNotification().publicVersion == null; + entry.autoRedacted = entry.getSbn().getNotification().publicVersion == null; entry.setRow(row); row.setOnActivatedListener(mPresenter); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java index 81275fda57e5..b7f408ebe557 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java @@ -126,7 +126,7 @@ public class NotificationLogger implements StateListener { int N = activeNotifications.size(); for (int i = 0; i < N; i++) { NotificationEntry entry = activeNotifications.get(i); - String key = entry.notification.getKey(); + String key = entry.getSbn().getKey(); boolean isVisible = mListContainer.isInVisibleLocation(entry); NotificationVisibility visObj = NotificationVisibility.obtain(key, i, N, isVisible, getNotificationLocation(entry)); @@ -214,14 +214,14 @@ public class NotificationLogger implements StateListener { NotificationVisibility visibility, boolean removedByUser) { if (removedByUser && visibility != null) { - logNotificationClear(entry.key, entry.notification, visibility); + logNotificationClear(entry.getKey(), entry.getSbn(), visibility); } - mExpansionStateLogger.onEntryRemoved(entry.key); + mExpansionStateLogger.onEntryRemoved(entry.getKey()); } @Override public void onEntryReinflated(NotificationEntry entry) { - mExpansionStateLogger.onEntryReinflated(entry.key); + mExpansionStateLogger.onEntryReinflated(entry.getKey()); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 924a3470b832..536db67a8795 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -442,7 +442,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView */ public void setEntry(@NonNull NotificationEntry entry) { mEntry = entry; - mStatusBarNotification = entry.notification; + mStatusBarNotification = entry.getSbn(); cacheIsSystemNotification(); } @@ -1203,7 +1203,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView // Let's update our childrencontainer. This is intentionally not guarded with // mIsSummaryWithChildren since we might have had children but not anymore. if (mChildrenContainer != null) { - mChildrenContainer.reInflateViews(mExpandClickListener, mEntry.notification); + mChildrenContainer.reInflateViews(mExpandClickListener, mEntry.getSbn()); } if (mGuts != null) { NotificationGuts oldGuts = mGuts; @@ -2303,7 +2303,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private void updateRippleAllowed() { boolean allowed = isOnKeyguard() - || mEntry.notification.getNotification().contentIntent == null; + || mEntry.getSbn().getNotification().contentIntent == null; setRippleAllowed(allowed); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java index a612a1721c41..a91a119d4ea7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java @@ -230,7 +230,7 @@ public class NotificationContentInflater { } // Only inflate the ones that are set. reInflateFlags &= mInflationFlags; - StatusBarNotification sbn = mRow.getEntry().notification; + StatusBarNotification sbn = mRow.getEntry().getSbn(); // To check if the notification has inline image and preload inline image if necessary. mRow.getImageResolver().preloadImages(sbn.getNotification()); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index f30a8b12ab39..b12c76c750a8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -1097,7 +1097,7 @@ public class NotificationContentView extends FrameLayout { } public void onNotificationUpdated(NotificationEntry entry) { - mStatusBarNotification = entry.notification; + mStatusBarNotification = entry.getSbn(); mOnContentViewInactiveListeners.clear(); mBeforeN = entry.targetSdk < Build.VERSION_CODES.N; updateAllSingleLineViews(); @@ -1179,7 +1179,7 @@ public class NotificationContentView extends FrameLayout { : mHeadsUpInflatedSmartReplies.getSmartRepliesAndActions(); if (DEBUG) { Log.d(TAG, String.format("Adding suggestions for %s, %d actions, and %d replies.", - entry.notification.getKey(), + entry.getSbn().getKey(), mCurrentSmartRepliesAndActions.smartActions == null ? 0 : mCurrentSmartRepliesAndActions.smartActions.actions.size(), mCurrentSmartRepliesAndActions.smartReplies == null ? 0 : @@ -1253,7 +1253,7 @@ public class NotificationContentView extends FrameLayout { } } if (hasRemoteInput) { - int color = entry.notification.getNotification().color; + int color = entry.getSbn().getNotification().color; if (color == Notification.COLOR_DEFAULT) { color = mContext.getColor(R.color.default_remote_input_background); } @@ -1267,7 +1267,7 @@ public class NotificationContentView extends FrameLayout { if (existingPendingIntent != null || existing.isActive()) { // The current action could be gone, or the pending intent no longer valid. // If we find a matching action in the new notification, focus, otherwise close. - Notification.Action[] actions = entry.notification.getNotification().actions; + Notification.Action[] actions = entry.getSbn().getNotification().actions; if (existingPendingIntent != null) { existing.setPendingIntent(existingPendingIntent); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java index 2b7deec87715..1de2cbb982a9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java @@ -494,15 +494,17 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx @Override public void setShouldManageLifetime(NotificationEntry entry, boolean shouldExtend) { if (shouldExtend) { - mKeyToRemoveOnGutsClosed = entry.key; + mKeyToRemoveOnGutsClosed = entry.getKey(); if (Log.isLoggable(TAG, Log.DEBUG)) { - Log.d(TAG, "Keeping notification because it's showing guts. " + entry.key); + Log.d(TAG, "Keeping notification because it's showing guts. " + entry.getKey()); } } else { - if (mKeyToRemoveOnGutsClosed != null && mKeyToRemoveOnGutsClosed.equals(entry.key)) { + if (mKeyToRemoveOnGutsClosed != null + && mKeyToRemoveOnGutsClosed.equals(entry.getKey())) { mKeyToRemoveOnGutsClosed = null; if (Log.isLoggable(TAG, Log.DEBUG)) { - Log.d(TAG, "Notification that was kept for guts was updated. " + entry.key); + Log.d(TAG, "Notification that was kept for guts was updated. " + + entry.getKey()); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java index 1116106df19d..5d5c09e98f11 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java @@ -175,7 +175,7 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi mActions = mView.findViewById(com.android.internal.R.id.media_actions); mIsViewVisible = mView.isShown(); - final MediaSession.Token token = mRow.getEntry().notification.getNotification().extras + final MediaSession.Token token = mRow.getEntry().getSbn().getNotification().extras .getParcelable(Notification.EXTRA_MEDIA_SESSION); boolean showCompactSeekbar = mMediaManager.getShowCompactMediaSeekbar(); @@ -404,7 +404,7 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi * @return new LogMaker */ private LogMaker newLog(int event) { - String packageName = mRow.getEntry().notification.getPackageName(); + String packageName = mRow.getEntry().getSbn().getPackageName(); return new LogMaker(MetricsEvent.MEDIA_NOTIFICATION_SEEKBAR) .setType(event) @@ -416,7 +416,7 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi * @return new LogMaker */ private LogMaker newLog(int event, int subtype) { - String packageName = mRow.getEntry().notification.getPackageName(); + String packageName = mRow.getEntry().getSbn().getPackageName(); return new LogMaker(MetricsEvent.MEDIA_NOTIFICATION_SEEKBAR) .setType(event) .setSubtype(subtype) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java index 3950003e64ce..c2eff8a6a776 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java @@ -63,7 +63,7 @@ public abstract class NotificationViewWrapper implements TransformableView { return new NotificationMessagingTemplateViewWrapper(ctx, v, row); } Class<? extends Notification.Style> style = - row.getEntry().notification.getNotification().getNotificationStyle(); + row.getEntry().getSbn().getNotification().getNotificationStyle(); if (Notification.DecoratedCustomViewStyle.class.equals(style)) { return new NotificationDecoratedCustomViewWrapper(ctx, v, row); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java index f3d068a9d610..ecab188a7481 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java @@ -22,7 +22,6 @@ import android.content.Context; import android.util.MathUtils; import android.view.View; -import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.statusbar.NotificationShelf; import com.android.systemui.statusbar.StatusBarState; @@ -410,7 +409,7 @@ public class AmbientState { if (!mPulsing || mHeadUpManager == null) { return false; } - return mHeadUpManager.isAlerting(entry.key); + return mHeadUpManager.isAlerting(entry.getKey()); } public boolean isPanelTracking() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java index d0444ae81b89..6ed4a576f441 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java @@ -284,12 +284,12 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section ActivatableNotificationView first = s.getFirstVisibleChild(); String fs = first == null ? "(null)" : (first instanceof ExpandableNotificationRow) - ? ((ExpandableNotificationRow) first).getEntry().key + ? ((ExpandableNotificationRow) first).getEntry().getKey() : Integer.toHexString(System.identityHashCode(first)); ActivatableNotificationView last = s.getLastVisibleChild(); String ls = last == null ? "(null)" : (last instanceof ExpandableNotificationRow) - ? ((ExpandableNotificationRow) last).getEntry().key + ? ((ExpandableNotificationRow) last).getEntry().getKey() : Integer.toHexString(System.identityHashCode(last)); android.util.Log.d(TAG, "updateSections: f=" + fs + " s=" + i); android.util.Log.d(TAG, "updateSections: l=" + ls + " s=" + i); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 98178252124a..5a1a2176672e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -602,7 +602,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd mEntryManager.addNotificationEntryListener(new NotificationEntryListener() { @Override public void onPostEntryUpdated(NotificationEntry entry) { - if (!entry.notification.isClearable()) { + if (!entry.getSbn().isClearable()) { // The user may have performed a dismiss action on the notification, since it's // not clearable we should snap it back. snapViewIfNeeded(entry); @@ -1627,7 +1627,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd if (!mIsExpanded && row.isHeadsUp() && row.isPinned() && mHeadsUpManager.getTopEntry().getRow() != row && mGroupManager.getGroupSummary( - mHeadsUpManager.getTopEntry().notification) + mHeadsUpManager.getTopEntry().getSbn()) != entry) { continue; } @@ -5525,12 +5525,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd // TODO: This is a listener method; we shouldn't be calling it. Can we just // call performRemoveNotification as below? mEntryManager.removeNotification( - rowToRemove.getEntry().key, + rowToRemove.getEntry().getKey(), null /* ranking */, NotificationListenerService.REASON_CANCEL_ALL); } else { mEntryManager.performRemoveNotification( - rowToRemove.getEntry().notification, + rowToRemove.getEntry().getSbn(), NotificationListenerService.REASON_CANCEL_ALL); } } else { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java index c6d051d74239..4e06c84c30be 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java @@ -197,9 +197,9 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, mReleaseOnExpandFinish = false; } else { for (NotificationEntry entry : mEntriesToRemoveAfterExpand) { - if (isAlerting(entry.key)) { + if (isAlerting(entry.getKey())) { // Maybe the heads-up was removed already - removeAlertEntry(entry.key); + removeAlertEntry(entry.getKey()); } } } @@ -291,7 +291,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, */ public void setRemoteInputActive( @NonNull NotificationEntry entry, boolean remoteInputActive) { - HeadsUpEntryPhone headsUpEntry = getHeadsUpEntryPhone(entry.key); + HeadsUpEntryPhone headsUpEntry = getHeadsUpEntryPhone(entry.getKey()); if (headsUpEntry != null && headsUpEntry.remoteInputActive != remoteInputActive) { headsUpEntry.remoteInputActive = remoteInputActive; if (remoteInputActive) { @@ -307,7 +307,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, * area if it's pinned until it's hidden again. */ public void setMenuShown(@NonNull NotificationEntry entry, boolean menuShown) { - HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.key); + HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.getKey()); if (headsUpEntry instanceof HeadsUpEntryPhone && entry.isRowPinned()) { ((HeadsUpEntryPhone) headsUpEntry).setMenuShownPinned(menuShown); } @@ -375,7 +375,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, } else { if (topEntry.isChildInGroup()) { final NotificationEntry groupSummary = - mGroupManager.getGroupSummary(topEntry.notification); + mGroupManager.getGroupSummary(topEntry.getSbn()); if (groupSummary != null) { topEntry = groupSummary; } @@ -429,9 +429,9 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, public void onReorderingAllowed() { mAnimationStateHandler.setHeadsUpGoingAwayAnimationsAllowed(false); for (NotificationEntry entry : mEntriesToRemoveWhenReorderingAllowed) { - if (isAlerting(entry.key)) { + if (isAlerting(entry.getKey())) { // Maybe the heads-up was removed already - removeAlertEntry(entry.key); + removeAlertEntry(entry.getKey()); } } mEntriesToRemoveWhenReorderingAllowed.clear(); @@ -448,7 +448,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, @Override protected void onAlertEntryRemoved(AlertEntry alertEntry) { - mKeysToRemoveWhenLeavingKeyguard.remove(alertEntry.mEntry.key); + mKeysToRemoveWhenLeavingKeyguard.remove(alertEntry.mEntry.getKey()); super.onAlertEntryRemoved(alertEntry); mEntryPool.release((HeadsUpEntryPhone) alertEntry); } @@ -533,9 +533,9 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, } else if (mTrackingHeadsUp) { mEntriesToRemoveAfterExpand.add(entry); } else if (mIsAutoHeadsUp && mStatusBarState == StatusBarState.KEYGUARD) { - mKeysToRemoveWhenLeavingKeyguard.add(entry.key); + mKeysToRemoveWhenLeavingKeyguard.add(entry.getKey()); } else { - removeAlertEntry(entry.key); + removeAlertEntry(entry.getKey()); } }; @@ -553,7 +553,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, if (mEntriesToRemoveWhenReorderingAllowed.contains(mEntry)) { mEntriesToRemoveWhenReorderingAllowed.remove(mEntry); } - mKeysToRemoveWhenLeavingKeyguard.remove(mEntry.key); + mKeysToRemoveWhenLeavingKeyguard.remove(mEntry.getKey()); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java index 4d69f77e744d..2798285c073d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java @@ -105,7 +105,7 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis * @return true if the entry was transferred to and should inflate + alert */ public boolean isAlertTransferPending(@NonNull NotificationEntry entry) { - PendingAlertInfo alertInfo = mPendingAlerts.get(entry.key); + PendingAlertInfo alertInfo = mPendingAlerts.get(entry.getKey()); return alertInfo != null && alertInfo.isStillValid(); } @@ -141,7 +141,7 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis @Override public void onGroupSuppressionChanged(NotificationGroup group, boolean suppressed) { if (suppressed) { - if (mHeadsUpManager.isAlerting(group.summary.key)) { + if (mHeadsUpManager.isAlerting(group.summary.getKey())) { handleSuppressedSummaryAlerted(group.summary, mHeadsUpManager); } } else { @@ -151,11 +151,11 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis return; } GroupAlertEntry groupAlertEntry = mGroupAlertEntries.get(mGroupManager.getGroupKey( - group.summary.notification)); + group.summary.getSbn())); // Group is no longer suppressed. We should check if we need to transfer the alert // back to the summary now that it's no longer suppressed. if (groupAlertEntry.mAlertSummaryOnNextAddition) { - if (!mHeadsUpManager.isAlerting(group.summary.key)) { + if (!mHeadsUpManager.isAlerting(group.summary.getKey())) { alertNotificationWhenPossible(group.summary, mHeadsUpManager); } groupAlertEntry.mAlertSummaryOnNextAddition = false; @@ -173,7 +173,7 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis private void onAlertStateChanged(NotificationEntry entry, boolean isAlerting, AlertingNotificationManager alertManager) { - if (isAlerting && mGroupManager.isSummaryOfSuppressedGroup(entry.notification)) { + if (isAlerting && mGroupManager.isSummaryOfSuppressedGroup(entry.getSbn())) { handleSuppressedSummaryAlerted(entry, alertManager); } } @@ -184,7 +184,7 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis // see as early as we can if we need to abort a transfer. @Override public void onPendingEntryAdded(NotificationEntry entry) { - String groupKey = mGroupManager.getGroupKey(entry.notification); + String groupKey = mGroupManager.getGroupKey(entry.getSbn()); GroupAlertEntry groupAlertEntry = mGroupAlertEntries.get(groupKey); if (groupAlertEntry != null) { checkShouldTransferBack(groupAlertEntry); @@ -195,7 +195,7 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis // then show the alert. @Override public void onEntryReinflated(NotificationEntry entry) { - PendingAlertInfo alertInfo = mPendingAlerts.remove(entry.key); + PendingAlertInfo alertInfo = mPendingAlerts.remove(entry.getKey()); if (alertInfo != null) { if (alertInfo.isStillValid()) { alertNotificationWhenPossible(entry, mHeadsUpManager); @@ -214,7 +214,7 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis // Removes any alerts pending on this entry. Note that this will not stop any inflation // tasks started by a transfer, so this should only be used as clean-up for when // inflation is stopped and the pending alert no longer needs to happen. - mPendingAlerts.remove(entry.key); + mPendingAlerts.remove(entry.getKey()); } }; @@ -267,10 +267,10 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis */ private boolean isPendingNotificationInGroup(@NonNull NotificationEntry entry, @NonNull NotificationGroup group) { - String groupKey = mGroupManager.getGroupKey(group.summary.notification); - return mGroupManager.isGroupChild(entry.notification) - && Objects.equals(mGroupManager.getGroupKey(entry.notification), groupKey) - && !group.children.containsKey(entry.key); + String groupKey = mGroupManager.getGroupKey(group.summary.getSbn()); + return mGroupManager.isGroupChild(entry.getSbn()) + && Objects.equals(mGroupManager.getGroupKey(entry.getSbn()), groupKey) + && !group.children.containsKey(entry.getKey()); } /** @@ -284,10 +284,10 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis */ private void handleSuppressedSummaryAlerted(@NonNull NotificationEntry summary, @NonNull AlertingNotificationManager alertManager) { - StatusBarNotification sbn = summary.notification; + StatusBarNotification sbn = summary.getSbn(); GroupAlertEntry groupAlertEntry = mGroupAlertEntries.get(mGroupManager.getGroupKey(sbn)); - if (!mGroupManager.isSummaryOfSuppressedGroup(summary.notification) + if (!mGroupManager.isSummaryOfSuppressedGroup(summary.getSbn()) || !alertManager.isAlerting(sbn.getKey()) || groupAlertEntry == null) { return; @@ -298,7 +298,8 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis return; } - NotificationEntry child = mGroupManager.getLogicalChildren(summary.notification).iterator().next(); + NotificationEntry child = + mGroupManager.getLogicalChildren(summary.getSbn()).iterator().next(); if (child != null) { if (child.getRow().keepInParent() || child.isRowRemoved() @@ -306,7 +307,7 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis // The notification is actually already removed. No need to alert it. return; } - if (!alertManager.isAlerting(child.key) && onlySummaryAlerts(summary)) { + if (!alertManager.isAlerting(child.getKey()) && onlySummaryAlerts(summary)) { groupAlertEntry.mLastAlertTransferTime = SystemClock.elapsedRealtime(); } transferAlertState(summary, child, alertManager); @@ -324,7 +325,7 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis */ private void transferAlertState(@NonNull NotificationEntry fromEntry, @NonNull NotificationEntry toEntry, @NonNull AlertingNotificationManager alertManager) { - alertManager.removeNotification(fromEntry.key, true /* releaseImmediately */); + alertManager.removeNotification(fromEntry.getKey(), true /* releaseImmediately */); alertNotificationWhenPossible(toEntry, alertManager); } @@ -347,7 +348,8 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis if (!onlySummaryAlerts(summary)) { return; } - ArrayList<NotificationEntry> children = mGroupManager.getLogicalChildren(summary.notification); + ArrayList<NotificationEntry> children = mGroupManager.getLogicalChildren( + summary.getSbn()); int numChildren = children.size(); int numPendingChildren = getPendingChildrenNotAlerting(groupAlertEntry.mGroup); numChildren += numPendingChildren; @@ -357,17 +359,18 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis boolean releasedChild = false; for (int i = 0; i < children.size(); i++) { NotificationEntry entry = children.get(i); - if (onlySummaryAlerts(entry) && mHeadsUpManager.isAlerting(entry.key)) { + if (onlySummaryAlerts(entry) && mHeadsUpManager.isAlerting(entry.getKey())) { releasedChild = true; - mHeadsUpManager.removeNotification(entry.key, true /* releaseImmediately */); + mHeadsUpManager.removeNotification( + entry.getKey(), true /* releaseImmediately */); } - if (mPendingAlerts.containsKey(entry.key)) { + if (mPendingAlerts.containsKey(entry.getKey())) { // This is the child that would've been removed if it was inflated. releasedChild = true; - mPendingAlerts.get(entry.key).mAbortOnInflation = true; + mPendingAlerts.get(entry.getKey()).mAbortOnInflation = true; } } - if (releasedChild && !mHeadsUpManager.isAlerting(summary.key)) { + if (releasedChild && !mHeadsUpManager.isAlerting(summary.getKey())) { boolean notifyImmediately = (numChildren - numPendingChildren) > 1; if (notifyImmediately) { alertNotificationWhenPossible(summary, mHeadsUpManager); @@ -391,20 +394,20 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis @NonNull AlertingNotificationManager alertManager) { @InflationFlag int contentFlag = alertManager.getContentFlag(); if (!entry.getRow().isInflationFlagSet(contentFlag)) { - mPendingAlerts.put(entry.key, new PendingAlertInfo(entry)); + mPendingAlerts.put(entry.getKey(), new PendingAlertInfo(entry)); entry.getRow().updateInflationFlag(contentFlag, true /* shouldInflate */); entry.getRow().inflateViews(); return; } - if (alertManager.isAlerting(entry.key)) { - alertManager.updateNotification(entry.key, true /* alert */); + if (alertManager.isAlerting(entry.getKey())) { + alertManager.updateNotification(entry.getKey(), true /* alert */); } else { alertManager.showNotification(entry); } } private boolean onlySummaryAlerts(NotificationEntry entry) { - return entry.notification.getNotification().getGroupAlertBehavior() + return entry.getSbn().getNotification().getGroupAlertBehavior() == Notification.GROUP_ALERT_SUMMARY; } @@ -431,7 +434,7 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis boolean mAbortOnInflation; PendingAlertInfo(NotificationEntry entry) { - mOriginalNotification = entry.notification; + mOriginalNotification = entry.getSbn(); mEntry = entry; } @@ -445,11 +448,11 @@ public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedLis // Notification is aborted due to the transfer being explicitly cancelled return false; } - if (mEntry.notification.getGroupKey() != mOriginalNotification.getGroupKey()) { + if (mEntry.getSbn().getGroupKey() != mOriginalNotification.getGroupKey()) { // Groups have changed return false; } - if (mEntry.notification.getNotification().isGroupSummary() + if (mEntry.getSbn().getNotification().isGroupSummary() != mOriginalNotification.getNotification().isGroupSummary()) { // Notification has changed from group summary to not or vice versa return false; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java index adaea9379c71..e11fc1b46a5b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java @@ -103,8 +103,8 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State } public void onEntryRemoved(NotificationEntry removed) { - onEntryRemovedInternal(removed, removed.notification); - mIsolatedEntries.remove(removed.key); + onEntryRemovedInternal(removed, removed.getSbn()); + mIsolatedEntries.remove(removed.getKey()); } /** @@ -126,7 +126,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State return; } if (isGroupChild(sbn)) { - group.children.remove(removed.key); + group.children.remove(removed.getKey()); } else { group.summary = null; } @@ -145,7 +145,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State if (added.isRowRemoved()) { added.setDebugThrowable(new Throwable()); } - final StatusBarNotification sbn = added.notification; + final StatusBarNotification sbn = added.getSbn(); boolean isGroupChild = isGroupChild(sbn); String groupKey = getGroupKey(sbn); NotificationGroup group = mGroupMap.get(groupKey); @@ -157,17 +157,17 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State } } if (isGroupChild) { - NotificationEntry existing = group.children.get(added.key); + NotificationEntry existing = group.children.get(added.getKey()); if (existing != null && existing != added) { Throwable existingThrowable = existing.getDebugThrowable(); - Log.wtf(TAG, "Inconsistent entries found with the same key " + added.key + Log.wtf(TAG, "Inconsistent entries found with the same key " + added.getKey() + "existing removed: " + existing.isRowRemoved() + (existingThrowable != null ? Log.getStackTraceString(existingThrowable) + "\n": "") + " added removed" + added.isRowRemoved() , new Throwable()); } - group.children.put(added.key, added); + group.children.put(added.getKey(), added); updateSuppression(group); } else { group.summary = added; @@ -210,7 +210,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State group.suppressed = group.summary != null && !group.expanded && (childCount == 1 || (childCount == 0 - && group.summary.notification.getNotification().isGroupSummary() + && group.summary.getSbn().getNotification().isGroupSummary() && (hasIsolatedChildren(group) || hasBubbles))); if (prevSuppressed != group.suppressed) { for (OnGroupChangeListener listener : mListeners) { @@ -223,7 +223,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State } private boolean hasIsolatedChildren(NotificationGroup group) { - return getNumberOfIsolatedChildren(group.summary.notification.getGroupKey()) != 0; + return getNumberOfIsolatedChildren(group.summary.getSbn().getGroupKey()) != 0; } private int getNumberOfIsolatedChildren(String groupKey) { @@ -248,18 +248,18 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State public void onEntryUpdated(NotificationEntry entry, StatusBarNotification oldNotification) { String oldKey = oldNotification.getGroupKey(); - String newKey = entry.notification.getGroupKey(); + String newKey = entry.getSbn().getGroupKey(); boolean groupKeysChanged = !oldKey.equals(newKey); boolean wasGroupChild = isGroupChild(oldNotification); - boolean isGroupChild = isGroupChild(entry.notification); + boolean isGroupChild = isGroupChild(entry.getSbn()); mIsUpdatingUnchangedGroup = !groupKeysChanged && wasGroupChild == isGroupChild; if (mGroupMap.get(getGroupKey(oldNotification)) != null) { onEntryRemovedInternal(entry, oldNotification); } onEntryAdded(entry); mIsUpdatingUnchangedGroup = false; - if (isIsolated(entry.notification)) { - mIsolatedEntries.put(entry.key, entry.notification); + if (isIsolated(entry.getSbn())) { + mIsolatedEntries.put(entry.getKey(), entry.getSbn()); if (groupKeysChanged) { updateSuppression(mGroupMap.get(oldKey)); updateSuppression(mGroupMap.get(newKey)); @@ -284,7 +284,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State } NotificationEntry logicalGroupSummary = getLogicalGroupSummary(sbn); return logicalGroupSummary != null - && !logicalGroupSummary.notification.equals(sbn); + && !logicalGroupSummary.getSbn().equals(sbn); } private int getTotalNumberOfChildren(StatusBarNotification sbn) { @@ -351,7 +351,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State if (group == null || group.summary == null) { return false; } - return !group.children.isEmpty() && Objects.equals(group.summary.notification, sbn); + return !group.children.isEmpty() && Objects.equals(group.summary.getSbn(), sbn); } /** @@ -404,7 +404,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State * will update the suppression of that group. */ public void updateSuppression(NotificationEntry entry) { - NotificationGroup group = mGroupMap.get(getGroupKey(entry.notification)); + NotificationGroup group = mGroupMap.get(getGroupKey(entry.getSbn())); if (group != null) { updateSuppression(group); } @@ -489,12 +489,12 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State */ private boolean shouldIsolate(NotificationEntry entry) { - StatusBarNotification sbn = entry.notification; + StatusBarNotification sbn = entry.getSbn(); NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey()); if (!sbn.isGroup() || sbn.getNotification().isGroupSummary()) { return false; } - if (mHeadsUpManager != null && !mHeadsUpManager.isAlerting(entry.key)) { + if (mHeadsUpManager != null && !mHeadsUpManager.isAlerting(entry.getKey())) { return false; } return (sbn.getNotification().fullScreenIntent != null @@ -509,10 +509,10 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State * @param entry the notification to isolate */ private void isolateNotification(NotificationEntry entry) { - StatusBarNotification sbn = entry.notification; + StatusBarNotification sbn = entry.getSbn(); // We will be isolated now, so lets update the groups - onEntryRemovedInternal(entry, entry.notification); + onEntryRemovedInternal(entry, entry.getSbn()); mIsolatedEntries.put(sbn.getKey(), sbn); @@ -521,7 +521,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State // even before the groupManager knows about the notification at all. // When the notification gets added afterwards it is already isolated and therefore // it doesn't lead to an update. - updateSuppression(mGroupMap.get(entry.notification.getGroupKey())); + updateSuppression(mGroupMap.get(entry.getSbn().getGroupKey())); for (OnGroupChangeListener listener : mListeners) { listener.onGroupsChanged(); } @@ -533,10 +533,10 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State * @param entry the notification to un-isolate */ private void stopIsolatingNotification(NotificationEntry entry) { - StatusBarNotification sbn = entry.notification; + StatusBarNotification sbn = entry.getSbn(); if (mIsolatedEntries.containsKey(sbn.getKey())) { // not isolated anymore, we need to update the groups - onEntryRemovedInternal(entry, entry.notification); + onEntryRemovedInternal(entry, entry.getSbn()); mIsolatedEntries.remove(sbn.getKey()); onEntryAdded(entry); for (OnGroupChangeListener listener : mListeners) { @@ -584,13 +584,13 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State @Override public String toString() { String result = " summary:\n " - + (summary != null ? summary.notification : "null") + + (summary != null ? summary.getSbn() : "null") + (summary != null && summary.getDebugThrowable() != null ? Log.getStackTraceString(summary.getDebugThrowable()) : ""); result += "\n children size: " + children.size(); for (NotificationEntry child : children.values()) { - result += "\n " + child.notification + result += "\n " + child.getSbn() + (child.getDebugThrowable() != null ? Log.getStackTraceString(child.getDebugThrowable()) : ""); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java index 1a37520d546e..1e10b6f025f2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java @@ -247,10 +247,10 @@ public class NotificationIconAreaController implements DarkReceiver, if (hideCenteredIcon && isCenteredNotificationIcon && !entry.isRowHeadsUp()) { return false; } - if (mEntryManager.getNotificationData().isAmbient(entry.key) && !showAmbient) { + if (mEntryManager.getNotificationData().isAmbient(entry.getKey()) && !showAmbient) { return false; } - if (hideCurrentMedia && entry.key.equals(mMediaManager.getMediaNotificationKey())) { + if (hideCurrentMedia && entry.getKey().equals(mMediaManager.getMediaNotificationKey())) { return false; } if (!entry.isTopLevelChild()) { 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 8e70d082dbb6..550c950e2fce 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -1895,7 +1895,7 @@ public class StatusBar extends SystemUI implements DemoMode, public void maybeEscalateHeadsUp() { mHeadsUpManager.getAllEntries().forEach(entry -> { - final StatusBarNotification sbn = entry.notification; + final StatusBarNotification sbn = entry.getSbn(); final Notification notification = sbn.getNotification(); if (notification.fullScreenIntent != null) { if (DEBUG) { @@ -3696,9 +3696,7 @@ public class StatusBar extends SystemUI implements DemoMode, // Indicate that the group expansion is changing at this time -- this way the group // and children backgrounds / divider animations will look correct. entry.setGroupExpansionChanging(true); - if (entry.notification != null) { - userId = entry.notification.getUserId(); - } + userId = entry.getSbn().getUserId(); } boolean fullShadeNeedsBouncer = !mLockscreenUserManager. userAllowsPrivateNotificationsInPublic(mLockscreenUserManager.getCurrentUserId()) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java index dfec1951f229..64a45e16d749 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java @@ -245,7 +245,7 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit StatusBarNotification parentToCancel = null; if (shouldAutoCancel(sbn) && mGroupManager.isOnlyChildInGroup(sbn)) { StatusBarNotification summarySbn = - mGroupManager.getLogicalGroupSummary(sbn).notification; + mGroupManager.getLogicalGroupSummary(sbn).getSbn(); if (shouldAutoCancel(summarySbn)) { parentToCancel = summarySbn; } @@ -310,7 +310,7 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit if (!TextUtils.isEmpty(entry.remoteInputText)) { remoteInputText = entry.remoteInputText; } - if (!TextUtils.isEmpty(remoteInputText) && !controller.isSpinning(entry.key)) { + if (!TextUtils.isEmpty(remoteInputText) && !controller.isSpinning(entry.getKey())) { fillInIntent = new Intent().putExtra(Notification.EXTRA_REMOTE_INPUT_DRAFT, remoteInputText.toString()); } @@ -409,11 +409,11 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit if (mNotificationInterruptionStateProvider.shouldLaunchFullScreenIntentWhenAdded(entry)) { if (shouldSuppressFullScreenIntent(entry)) { if (DEBUG) { - Log.d(TAG, "No Fullscreen intent: suppressed by DND: " + entry.key); + Log.d(TAG, "No Fullscreen intent: suppressed by DND: " + entry.getKey()); } } else if (entry.getImportance() < NotificationManager.IMPORTANCE_HIGH) { if (DEBUG) { - Log.d(TAG, "No Fullscreen intent: not important enough: " + entry.key); + Log.d(TAG, "No Fullscreen intent: not important enough: " + entry.getKey()); } } else { // Stop screensaver if the notification has a fullscreen intent. @@ -432,8 +432,8 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit } try { EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION, - entry.key); - entry.notification.getNotification().fullScreenIntent.send(); + entry.getKey()); + entry.getSbn().getNotification().fullScreenIntent.send(); entry.notifyFullScreenIntentLaunched(); mMetricsLogger.count("note_fullscreen", 1); } catch (PendingIntent.CanceledException e) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java index f4a26badf719..b01a8d4b82e4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java @@ -201,7 +201,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter, NotificationVisibility visibility, boolean removedByUser) { StatusBarNotificationPresenter.this.onNotificationRemoved( - entry.key, entry.notification); + entry.getKey(), entry.getSbn()); if (removedByUser) { maybeEndAmbientPulse(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java index b84dc476dd6f..6828c322dea2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java @@ -117,7 +117,7 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { } protected boolean hasFullScreenIntent(@NonNull NotificationEntry entry) { - return entry.notification.getNotification().fullScreenIntent != null; + return entry.getSbn().getNotification().fullScreenIntent != null; } protected void setEntryPinned( @@ -206,7 +206,7 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { public void snooze() { for (String key : mAlertEntries.keySet()) { AlertEntry entry = getHeadsUpEntry(key); - String packageName = entry.mEntry.notification.getPackageName(); + String packageName = entry.mEntry.getSbn().getPackageName(); mSnoozedPackages.put(snoozeKey(packageName, mUser), mClock.currentTimeMillis() + mSnoozeLengthMs); } @@ -328,8 +328,8 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { * one should be ranked higher and 0 if they are equal. */ public int compare(@NonNull NotificationEntry a, @NonNull NotificationEntry b) { - AlertEntry aEntry = getHeadsUpEntry(a.key); - AlertEntry bEntry = getHeadsUpEntry(b.key); + AlertEntry aEntry = getHeadsUpEntry(a.getKey()); + AlertEntry bEntry = getHeadsUpEntry(b.getKey()); if (aEntry == null || bEntry == null) { return aEntry == null ? 1 : -1; } @@ -341,7 +341,7 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { * until it's collapsed again. */ public void setExpanded(@NonNull NotificationEntry entry, boolean expanded) { - HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.key); + HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.getKey()); if (headsUpEntry != null && entry.isRowPinned()) { headsUpEntry.setExpanded(expanded); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/InflatedSmartReplies.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/InflatedSmartReplies.java index be27741b4dc8..c6ae669d5d08 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/InflatedSmartReplies.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/InflatedSmartReplies.java @@ -144,13 +144,13 @@ public class InflatedSmartReplies { return false; } // If we are showing the spinner we don't want to add the buttons. - boolean showingSpinner = entry.notification.getNotification() + boolean showingSpinner = entry.getSbn().getNotification() .extras.getBoolean(Notification.EXTRA_SHOW_REMOTE_INPUT_SPINNER, false); if (showingSpinner) { return false; } // If we are keeping the notification around while sending we don't want to add the buttons. - boolean hideSmartReplies = entry.notification.getNotification() + boolean hideSmartReplies = entry.getSbn().getNotification() .extras.getBoolean(Notification.EXTRA_HIDE_SMART_REPLIES, false); if (hideSmartReplies) { return false; @@ -168,7 +168,7 @@ public class InflatedSmartReplies { public static SmartRepliesAndActions chooseSmartRepliesAndActions( SmartReplyConstants smartReplyConstants, final NotificationEntry entry) { - Notification notification = entry.notification.getNotification(); + Notification notification = entry.getSbn().getNotification(); Pair<RemoteInput, Notification.Action> remoteInputActionPair = notification.findRemoteInputActionPair(false /* freeform */); Pair<RemoteInput, Notification.Action> freeformRemoteInputActionPair = @@ -177,7 +177,7 @@ public class InflatedSmartReplies { if (!smartReplyConstants.isEnabled()) { if (DEBUG) { Log.d(TAG, "Smart suggestions not enabled, not adding suggestions for " - + entry.notification.getKey()); + + entry.getSbn().getKey()); } return new SmartRepliesAndActions(null, null); } @@ -271,7 +271,7 @@ public class InflatedSmartReplies { * through the remote input. */ public static boolean hasFreeformRemoteInput(NotificationEntry entry) { - Notification notification = entry.notification.getNotification(); + Notification notification = entry.getSbn().getNotification(); return null != notification.findRemoteInputActionPair(true /* freeform */); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index cca9479d20d6..7b4a7d20293c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -175,7 +175,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene results.put(contentType, data); try { mStatusBarManagerService.grantInlineReplyUriPermission( - mEntry.notification.getKey(), data); + mEntry.getSbn().getKey(), data); } catch (Exception e) { Log.e(TAG, "Failed to grant URI permissions:" + e.getMessage(), e); } @@ -191,7 +191,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mProgressBar.setVisibility(VISIBLE); mEntry.remoteInputText = mEditText.getText(); mEntry.lastRemoteInputSent = SystemClock.elapsedRealtime(); - mController.addSpinning(mEntry.key, mToken); + mController.addSpinning(mEntry.getKey(), mToken); mController.removeRemoteInput(mEntry, mToken); mEditText.mShowImeOnInputConnection = false; mController.remoteInputSent(mEntry); @@ -203,17 +203,17 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene // but that's an edge case, and also because we can't always know which package will receive // an intent, so we just reset for the publisher. getContext().getSystemService(ShortcutManager.class).onApplicationActive( - mEntry.notification.getPackageName(), - mEntry.notification.getUser().getIdentifier()); + mEntry.getSbn().getPackageName(), + mEntry.getSbn().getUser().getIdentifier()); MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_SEND, - mEntry.notification.getPackageName()); + mEntry.getSbn().getPackageName()); try { mPendingIntent.send(mContext, 0, intent); } catch (PendingIntent.CanceledException e) { Log.i(TAG, "Unable to send remote input result", e); MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_FAIL, - mEntry.notification.getPackageName()); + mEntry.getSbn().getPackageName()); } } @@ -228,7 +228,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene LayoutInflater.from(context).inflate(R.layout.remote_input, root, false); v.mController = controller; v.mEntry = entry; - UserHandle user = computeTextOperationUser(entry.notification.getUser()); + UserHandle user = computeTextOperationUser(entry.getSbn().getUser()); v.mEditText.mUser = user; v.mEditText.setTextOperationUser(user); v.setTag(VIEW_TAG); @@ -284,7 +284,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mRemoteInputQuickSettingsDisabler.setRemoteInputActive(false); MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_CLOSE, - mEntry.notification.getPackageName()); + mEntry.getSbn().getPackageName()); } @Override @@ -304,7 +304,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene return; } mController.removeRemoteInput(mEntry, mToken); - mController.removeSpinning(mEntry.key, mToken); + mController.removeSpinning(mEntry.getKey(), mToken); } public void setPendingIntent(PendingIntent pendingIntent) { @@ -349,7 +349,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene public void focus() { MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_OPEN, - mEntry.notification.getPackageName()); + mEntry.getSbn().getPackageName()); setVisibility(VISIBLE); if (mWrapper != null) { @@ -388,7 +388,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mEditText.setEnabled(true); mSendButton.setVisibility(VISIBLE); mProgressBar.setVisibility(INVISIBLE); - mController.removeSpinning(mEntry.key, mToken); + mController.removeSpinning(mEntry.getKey(), mToken); updateSendButton(); onDefocus(false /* animate */); @@ -540,7 +540,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene } public boolean isSending() { - return getVisibility() == VISIBLE && mController.isSpinning(mEntry.key, mToken); + return getVisibility() == VISIBLE && mController.isSpinning(mEntry.getKey(), mToken); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java index b5f660a84043..65bb28ffbe39 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java @@ -350,7 +350,7 @@ public class SmartReplyView extends ViewGroup { () -> { smartReplyController.smartActionClicked( entry, actionIndex, action, smartActions.fromAssistant); - headsUpManager.removeNotification(entry.key, true); + headsUpManager.removeNotification(entry.getKey(), true); }, entry.getRow()); if (useDelayedOnClickListener) { onClickListener = new DelayedOnClickListener(onClickListener, diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java index 34725733251a..00681130074b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java @@ -172,8 +172,8 @@ public class BubbleControllerTest extends SysuiTestCase { // Return non-null notification data from the NEM when(mNotificationEntryManager.getNotificationData()).thenReturn(mNotificationData); - when(mNotificationData.get(mRow.getEntry().key)).thenReturn(mRow.getEntry()); - when(mNotificationData.getChannel(mRow.getEntry().key)).thenReturn( + when(mNotificationData.get(mRow.getEntry().getKey())).thenReturn(mRow.getEntry()); + when(mNotificationData.getChannel(mRow.getEntry().getKey())).thenReturn( mRow.getEntry().getChannel()); mZenModeConfig.suppressedVisualEffects = 0; @@ -228,14 +228,15 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testRemoveBubble() { mBubbleController.updateBubble(mRow.getEntry()); - assertNotNull(mBubbleData.getBubbleWithKey(mRow.getEntry().key)); + assertNotNull(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey())); assertTrue(mBubbleController.hasBubbles()); verify(mNotificationEntryManager).updateNotifications(any()); verify(mBubbleStateChangeListener).onHasBubblesChanged(true); - mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_USER_GESTURE); + mBubbleController.removeBubble( + mRow.getEntry().getKey(), BubbleController.DISMISS_USER_GESTURE); assertFalse(mStatusBarWindowController.getBubblesShowing()); - assertNull(mBubbleData.getBubbleWithKey(mRow.getEntry().key)); + assertNull(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey())); verify(mNotificationEntryManager, times(2)).updateNotifications(anyString()); verify(mBubbleStateChangeListener).onHasBubblesChanged(false); } @@ -246,18 +247,20 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); - assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); // Make it look like dismissed notif - mBubbleData.getBubbleWithKey(mRow.getEntry().key).setShowInShadeWhenBubble(false); + mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).setShowInShadeWhenBubble(false); // Now remove the bubble - mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_USER_GESTURE); + mBubbleController.removeBubble( + mRow.getEntry().getKey(), BubbleController.DISMISS_USER_GESTURE); // Since the notif is dismissed, once the bubble is removed, performRemoveNotification gets // called to really remove the notif verify(mNotificationEntryManager, times(1)).performRemoveNotification( - mRow.getEntry().notification, UNDEFINED_DISMISS_REASON); + mRow.getEntry().getSbn(), UNDEFINED_DISMISS_REASON); assertFalse(mBubbleController.hasBubbles()); } @@ -265,17 +268,17 @@ public class BubbleControllerTest extends SysuiTestCase { public void testDismissStack() { mBubbleController.updateBubble(mRow.getEntry()); verify(mNotificationEntryManager, times(1)).updateNotifications(any()); - assertNotNull(mBubbleData.getBubbleWithKey(mRow.getEntry().key)); + assertNotNull(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey())); mBubbleController.updateBubble(mRow2.getEntry()); verify(mNotificationEntryManager, times(2)).updateNotifications(any()); - assertNotNull(mBubbleData.getBubbleWithKey(mRow2.getEntry().key)); + assertNotNull(mBubbleData.getBubbleWithKey(mRow2.getEntry().getKey())); assertTrue(mBubbleController.hasBubbles()); mBubbleController.dismissStack(BubbleController.DISMISS_USER_GESTURE); assertFalse(mStatusBarWindowController.getBubblesShowing()); verify(mNotificationEntryManager, times(3)).updateNotifications(any()); - assertNull(mBubbleData.getBubbleWithKey(mRow.getEntry().key)); - assertNull(mBubbleData.getBubbleWithKey(mRow2.getEntry().key)); + assertNull(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey())); + assertNull(mBubbleData.getBubbleWithKey(mRow2.getEntry().getKey())); } @Test @@ -288,22 +291,24 @@ public class BubbleControllerTest extends SysuiTestCase { // We should have bubbles & their notifs should not be suppressed assertTrue(mBubbleController.hasBubbles()); - assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); assertFalse(mStatusBarWindowController.getBubbleExpanded()); // Expand the stack BubbleStackView stackView = mBubbleController.getStackView(); mBubbleController.expandStack(); assertTrue(mBubbleController.isStackExpanded()); - verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().getKey()); assertTrue(mStatusBarWindowController.getBubbleExpanded()); // Make sure the notif is suppressed - assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); // Collapse mBubbleController.collapseStack(); - verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().getKey()); assertFalse(mBubbleController.isStackExpanded()); assertFalse(mStatusBarWindowController.getBubbleExpanded()); } @@ -318,30 +323,33 @@ public class BubbleControllerTest extends SysuiTestCase { // We should have bubbles & their notifs should not be suppressed assertTrue(mBubbleController.hasBubbles()); - assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( - mRow2.getEntry().key)); + mRow.getEntry().getKey())); + assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow2.getEntry().getKey())); // Expand BubbleStackView stackView = mBubbleController.getStackView(); mBubbleController.expandStack(); assertTrue(mBubbleController.isStackExpanded()); - verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().getKey()); // Last added is the one that is expanded assertEquals(mRow2.getEntry(), stackView.getExpandedBubbleView().getEntry()); - assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow2.getEntry().key)); + assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow2.getEntry().getKey())); // Switch which bubble is expanded - mBubbleController.selectBubble(mRow.getEntry().key); - stackView.setExpandedBubble(mRow.getEntry().key); + mBubbleController.selectBubble(mRow.getEntry().getKey()); + stackView.setExpandedBubble(mRow.getEntry().getKey()); assertEquals(mRow.getEntry(), stackView.getExpandedBubbleView().getEntry()); - assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); // collapse for previous bubble - verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().getKey()); // expand for selected bubble - verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().getKey()); // Collapse mBubbleController.collapseStack(); @@ -356,18 +364,20 @@ public class BubbleControllerTest extends SysuiTestCase { // We should have bubbles & their notifs should not be suppressed assertTrue(mBubbleController.hasBubbles()); - assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); - assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot()); + assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); + assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showBubbleDot()); // Expand mBubbleController.expandStack(); assertTrue(mBubbleController.isStackExpanded()); - verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().getKey()); // Notif is suppressed after expansion - assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); // Notif shouldn't show dot after expansion - assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot()); + assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showBubbleDot()); } @Test @@ -378,28 +388,31 @@ public class BubbleControllerTest extends SysuiTestCase { // We should have bubbles & their notifs should not be suppressed assertTrue(mBubbleController.hasBubbles()); - assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); - assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot()); + assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); + assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showBubbleDot()); // Expand BubbleStackView stackView = mBubbleController.getStackView(); mBubbleController.expandStack(); assertTrue(mBubbleController.isStackExpanded()); - verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().getKey()); // Notif is suppressed after expansion - assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); // Notif shouldn't show dot after expansion - assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot()); + assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showBubbleDot()); // Send update mEntryListener.onPreEntryUpdated(mRow.getEntry()); // Nothing should have changed // Notif is suppressed after expansion - assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); // Notif shouldn't show dot after expansion - assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot()); + assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showBubbleDot()); } @Test @@ -416,27 +429,28 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.expandStack(); assertTrue(mBubbleController.isStackExpanded()); - verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().getKey()); // Last added is the one that is expanded assertEquals(mRow2.getEntry(), stackView.getExpandedBubbleView().getEntry()); - assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow2.getEntry().key)); + assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow2.getEntry().getKey())); // Dismiss currently expanded mBubbleController.removeBubble(stackView.getExpandedBubbleView().getKey(), BubbleController.DISMISS_USER_GESTURE); - verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().getKey()); // Make sure first bubble is selected assertEquals(mRow.getEntry(), stackView.getExpandedBubbleView().getEntry()); - verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().getKey()); // Dismiss that one mBubbleController.removeBubble(stackView.getExpandedBubbleView().getKey(), BubbleController.DISMISS_USER_GESTURE); // Make sure state changes and collapse happens - verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().key); + verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().getKey()); verify(mBubbleStateChangeListener).onHasBubblesChanged(false); assertFalse(mBubbleController.hasBubbles()); } @@ -453,7 +467,7 @@ public class BubbleControllerTest extends SysuiTestCase { // Expansion shouldn't change verify(mBubbleExpandListener, never()).onBubbleExpandChanged(false /* expanded */, - mRow.getEntry().key); + mRow.getEntry().getKey()); assertFalse(mBubbleController.isStackExpanded()); // # of bubbles should change @@ -471,7 +485,7 @@ public class BubbleControllerTest extends SysuiTestCase { // Expansion should change verify(mBubbleExpandListener).onBubbleExpandChanged(true /* expanded */, - mRow.getEntry().key); + mRow.getEntry().getKey()); assertTrue(mBubbleController.isStackExpanded()); // # of bubbles should change @@ -488,7 +502,8 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.updateBubble(mRow.getEntry()); // Should not be suppressed because we weren't forground - assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); // # of bubbles should change verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */); } @@ -503,7 +518,8 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.updateBubble(mRow.getEntry()); // Notif should be suppressed because we were foreground - assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); // # of bubbles should change verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */); @@ -511,13 +527,14 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testExpandStackAndSelectBubble_removedFirst() { - final String key = mRow.getEntry().key; + final String key = mRow.getEntry().getKey(); mEntryListener.onPendingEntryAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Simulate notification cancellation. - mRemoveInterceptor.onNotificationRemoveRequested(mRow.getEntry().key, REASON_APP_CANCEL); + mRemoveInterceptor.onNotificationRemoveRequested( + mRow.getEntry().getKey(), REASON_APP_CANCEL); mBubbleController.expandStackAndSelectBubble(key); } @@ -525,8 +542,9 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testMarkNewNotificationAsShowInShade() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); - assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); - assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().key).showBubbleDot()); + assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); + assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showBubbleDot()); } @Test @@ -541,14 +559,15 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testDeleteIntent_removeBubble_aged() throws PendingIntent.CanceledException { mBubbleController.updateBubble(mRow.getEntry()); - mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_AGED); + mBubbleController.removeBubble(mRow.getEntry().getKey(), BubbleController.DISMISS_AGED); verify(mDeleteIntent, never()).send(); } @Test public void testDeleteIntent_removeBubble_user() throws PendingIntent.CanceledException { mBubbleController.updateBubble(mRow.getEntry()); - mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_USER_GESTURE); + mBubbleController.removeBubble( + mRow.getEntry().getKey(), BubbleController.DISMISS_USER_GESTURE); verify(mDeleteIntent, times(1)).send(); } @@ -566,7 +585,7 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); - mRow.getEntry().notification.getNotification().flags &= ~FLAG_BUBBLE; + mRow.getEntry().getSbn().getNotification().flags &= ~FLAG_BUBBLE; mEntryListener.onPreEntryUpdated(mRow.getEntry()); assertFalse(mBubbleController.hasBubbles()); @@ -581,7 +600,7 @@ public class BubbleControllerTest extends SysuiTestCase { assertTrue(mBubbleController.hasBubbles()); boolean intercepted = mRemoveInterceptor.onNotificationRemoveRequested( - mRow.getEntry().key, REASON_APP_CANCEL); + mRow.getEntry().getKey(), REASON_APP_CANCEL); // Cancels always remove so no need to intercept assertFalse(intercepted); @@ -594,15 +613,17 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); - assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); boolean intercepted = mRemoveInterceptor.onNotificationRemoveRequested( - mRow.getEntry().key, REASON_CANCEL_ALL); + mRow.getEntry().getKey(), REASON_CANCEL_ALL); // Intercept! assertTrue(intercepted); // Should update show in shade state - assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); verify(mNotificationEntryManager, never()).performRemoveNotification( any(), anyInt()); @@ -615,15 +636,17 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); - assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); boolean intercepted = mRemoveInterceptor.onNotificationRemoveRequested( - mRow.getEntry().key, REASON_CANCEL); + mRow.getEntry().getKey(), REASON_CANCEL); // Intercept! assertTrue(intercepted); // Should update show in shade state - assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); verify(mNotificationEntryManager, never()).performRemoveNotification( any(), anyInt()); @@ -636,15 +659,17 @@ public class BubbleControllerTest extends SysuiTestCase { mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); - assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(mRow.getEntry().key)); + assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( + mRow.getEntry().getKey())); // Dismiss the bubble - mBubbleController.removeBubble(mRow.getEntry().key, BubbleController.DISMISS_USER_GESTURE); + mBubbleController.removeBubble( + mRow.getEntry().getKey(), BubbleController.DISMISS_USER_GESTURE); assertFalse(mBubbleController.hasBubbles()); // Dismiss the notification boolean intercepted = mRemoveInterceptor.onNotificationRemoveRequested( - mRow.getEntry().key, REASON_CANCEL); + mRow.getEntry().getKey(), REASON_CANCEL); // It's no longer a bubble so we shouldn't intercept assertFalse(intercepted); @@ -694,7 +719,7 @@ public class BubbleControllerTest extends SysuiTestCase { */ private void setMetadataFlags(NotificationEntry entry, int flag, boolean enableFlag) { Notification.BubbleMetadata bubbleMetadata = - entry.notification.getNotification().getBubbleMetadata(); + entry.getSbn().getNotification().getBubbleMetadata(); int flags = bubbleMetadata.getFlags(); if (enableFlag) { flags |= flag; diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java index 96ee079f1fee..67f65e611e4e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java @@ -842,14 +842,14 @@ public class BubbleDataTest extends SysuiTestCase { } private void setPostTime(NotificationEntry entry, long postTime) { - when(entry.notification.getPostTime()).thenReturn(postTime); + when(entry.getSbn().getPostTime()).thenReturn(postTime); } private void setOngoing(NotificationEntry entry, boolean ongoing) { if (ongoing) { - entry.notification.getNotification().flags |= Notification.FLAG_FOREGROUND_SERVICE; + entry.getSbn().getNotification().flags |= Notification.FLAG_FOREGROUND_SERVICE; } else { - entry.notification.getNotification().flags &= ~Notification.FLAG_FOREGROUND_SERVICE; + entry.getSbn().getNotification().flags &= ~Notification.FLAG_FOREGROUND_SERVICE; } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java index cf5a12fcc2af..c6dd23262b85 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java @@ -141,9 +141,9 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { public void testShowNotification_addsEntry() { mAlertingNotificationManager.showNotification(mEntry); - assertTrue(mAlertingNotificationManager.isAlerting(mEntry.key)); + assertTrue(mAlertingNotificationManager.isAlerting(mEntry.getKey())); assertTrue(mAlertingNotificationManager.hasNotifications()); - assertEquals(mEntry, mAlertingNotificationManager.getEntry(mEntry.key)); + assertEquals(mEntry, mAlertingNotificationManager.getEntry(mEntry.getKey())); } @Test @@ -155,7 +155,7 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { TestableLooper.get(this).processMessages(1); assertFalse("Test timed out", mTimedOut); - assertFalse(mAlertingNotificationManager.isAlerting(mEntry.key)); + assertFalse(mAlertingNotificationManager.isAlerting(mEntry.getKey())); } @Test @@ -163,9 +163,10 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { mAlertingNotificationManager.showNotification(mEntry); // Try to remove but defer, since the notification has not been shown long enough. - mAlertingNotificationManager.removeNotification(mEntry.key, false /* releaseImmediately */); + mAlertingNotificationManager.removeNotification( + mEntry.getKey(), false /* releaseImmediately */); - assertTrue(mAlertingNotificationManager.isAlerting(mEntry.key)); + assertTrue(mAlertingNotificationManager.isAlerting(mEntry.getKey())); } @Test @@ -173,9 +174,10 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { mAlertingNotificationManager.showNotification(mEntry); // Remove forcibly with releaseImmediately = true. - mAlertingNotificationManager.removeNotification(mEntry.key, true /* releaseImmediately */); + mAlertingNotificationManager.removeNotification( + mEntry.getKey(), true /* releaseImmediately */); - assertFalse(mAlertingNotificationManager.isAlerting(mEntry.key)); + assertFalse(mAlertingNotificationManager.isAlerting(mEntry.getKey())); } @Test @@ -199,7 +201,7 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { mAlertingNotificationManager.showNotification(mEntry); // The entry has just been added so we should not remove immediately. - assertFalse(mAlertingNotificationManager.canRemoveImmediately(mEntry.key)); + assertFalse(mAlertingNotificationManager.canRemoveImmediately(mEntry.getKey())); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationEntryHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationEntryHelper.java index 5ad054b5b453..2420e573421a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationEntryHelper.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationEntryHelper.java @@ -59,7 +59,7 @@ public class NotificationEntryHelper { @Override public StatusBarNotification build() { final StatusBarNotification sbn = super.build(); - mTarget.setNotification(sbn); + mTarget.setSbn(sbn); return sbn; } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java index 6b996ab8450b..2514c9382e44 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java @@ -112,7 +112,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase { @Test public void testShouldExtendLifetime_isSpinning() { NotificationRemoteInputManager.FORCE_REMOTE_INPUT_HISTORY = true; - when(mController.isSpinning(mEntry.key)).thenReturn(true); + when(mController.isSpinning(mEntry.getKey())).thenReturn(true); assertTrue(mRemoteInputHistoryExtender.shouldExtendLifetime(mEntry)); } @@ -128,7 +128,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase { @Test public void testShouldExtendLifetime_smartReplySending() { NotificationRemoteInputManager.FORCE_REMOTE_INPUT_HISTORY = true; - when(mSmartReplyController.isSendingSmartReply(mEntry.key)).thenReturn(true); + when(mSmartReplyController.isSendingSmartReply(mEntry.getKey())).thenReturn(true); assertTrue(mSmartReplyHistoryExtender.shouldExtendLifetime(mEntry)); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java index 6efa57d21cce..18649bfe68d3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java @@ -143,11 +143,11 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { Lists.newArrayList(entry0, entry1, entry2)); // Set up group manager to report that they should be bundled now. - when(mGroupManager.isChildInGroupWithSummary(entry0.notification)).thenReturn(false); - when(mGroupManager.isChildInGroupWithSummary(entry1.notification)).thenReturn(true); - when(mGroupManager.isChildInGroupWithSummary(entry2.notification)).thenReturn(true); - when(mGroupManager.getGroupSummary(entry1.notification)).thenReturn(entry0); - when(mGroupManager.getGroupSummary(entry2.notification)).thenReturn(entry0); + when(mGroupManager.isChildInGroupWithSummary(entry0.getSbn())).thenReturn(false); + when(mGroupManager.isChildInGroupWithSummary(entry1.getSbn())).thenReturn(true); + when(mGroupManager.isChildInGroupWithSummary(entry2.getSbn())).thenReturn(true); + when(mGroupManager.getGroupSummary(entry1.getSbn())).thenReturn(entry0); + when(mGroupManager.getGroupSummary(entry2.getSbn())).thenReturn(entry0); // Run updateNotifications - the view hierarchy should be reorganized. mViewHierarchyManager.updateNotificationViews(); @@ -172,9 +172,9 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { Lists.newArrayList(entry0, entry1, entry2)); // Set up group manager to report that they should not be bundled now. - when(mGroupManager.isChildInGroupWithSummary(entry0.notification)).thenReturn(false); - when(mGroupManager.isChildInGroupWithSummary(entry1.notification)).thenReturn(false); - when(mGroupManager.isChildInGroupWithSummary(entry2.notification)).thenReturn(false); + when(mGroupManager.isChildInGroupWithSummary(entry0.getSbn())).thenReturn(false); + when(mGroupManager.isChildInGroupWithSummary(entry1.getSbn())).thenReturn(false); + when(mGroupManager.isChildInGroupWithSummary(entry2.getSbn())).thenReturn(false); // Run updateNotifications - the view hierarchy should be reorganized. mViewHierarchyManager.updateNotificationViews(); @@ -201,9 +201,9 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { Lists.newArrayList(entry0, entry1)); // Set up group manager to report a suppressed summary now. - when(mGroupManager.isChildInGroupWithSummary(entry0.notification)).thenReturn(false); - when(mGroupManager.isChildInGroupWithSummary(entry1.notification)).thenReturn(false); - when(mGroupManager.isSummaryOfSuppressedGroup(entry0.notification)).thenReturn(true); + when(mGroupManager.isChildInGroupWithSummary(entry0.getSbn())).thenReturn(false); + when(mGroupManager.isChildInGroupWithSummary(entry1.getSbn())).thenReturn(false); + when(mGroupManager.isSummaryOfSuppressedGroup(entry0.getSbn())).thenReturn(true); // Run updateNotifications - the view hierarchy should be reorganized. mViewHierarchyManager.updateNotificationViews(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java index 0b91dfb72c36..ebdf851899b5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java @@ -270,7 +270,8 @@ public class NotificationEntryManagerTest extends SysuiTestCase { notificationRowBinder.setNotificationClicker(mock(NotificationClicker.class)); mEntryManager.setRowBinder(notificationRowBinder); - setUserSentiment(mEntry.key, NotificationListenerService.Ranking.USER_SENTIMENT_NEUTRAL); + setUserSentiment( + mEntry.getKey(), NotificationListenerService.Ranking.USER_SENTIMENT_NEUTRAL); } @Test @@ -317,7 +318,8 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mEntryManager.getNotificationData().add(mEntry); - setUserSentiment(mEntry.key, NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE); + setUserSentiment( + mEntry.getKey(), NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE); mEntryManager.updateNotification(mSbn, mRankingMap); TestableLooper.get(this).processMessages(1); @@ -341,7 +343,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { TestableLooper.get(this).processAllMessages(); NotificationData notifData = mock(NotificationData.class); - when(notifData.get(mEntry.key)).thenReturn(mEntry); + when(notifData.get(mEntry.getKey())).thenReturn(mEntry); mEntryManager.setNotificationData(notifData); @@ -413,7 +415,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mEntry.setRow(mRow); mEntry.setInflationTask(mAsyncInflationTask); mEntryManager.getNotificationData().add(mEntry); - setSmartActions(mEntry.key, new ArrayList<>(Arrays.asList(createAction()))); + setSmartActions(mEntry.getKey(), new ArrayList<>(Arrays.asList(createAction()))); mEntryManager.updateNotificationRanking(mRankingMap); verify(mRow).setEntry(eq(mEntry)); @@ -429,7 +431,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mEntry.setRow(mRow); mEntryManager.getNotificationData().add(mEntry); - setSmartActions(mEntry.key, null); + setSmartActions(mEntry.getKey(), null); mEntryManager.updateNotificationRanking(mRankingMap); verify(mRow, never()).setEntry(eq(mEntry)); @@ -443,7 +445,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mEntry.setRow(null); mEntryManager.getNotificationData().add(mEntry); - setSmartActions(mEntry.key, new ArrayList<>(Arrays.asList(createAction()))); + setSmartActions(mEntry.getKey(), new ArrayList<>(Arrays.asList(createAction()))); mEntryManager.updateNotificationRanking(mRankingMap); verify(mRow, never()).setEntry(eq(mEntry)); @@ -457,8 +459,8 @@ public class NotificationEntryManagerTest extends SysuiTestCase { when(mEnvironment.isNotificationForCurrentProfiles(any())).thenReturn(true); mEntry.setRow(null); - mEntryManager.mPendingNotifications.put(mEntry.key, mEntry); - setSmartActions(mEntry.key, new ArrayList<>(Arrays.asList(createAction()))); + mEntryManager.mPendingNotifications.put(mEntry.getKey(), mEntry); + setSmartActions(mEntry.getKey(), new ArrayList<>(Arrays.asList(createAction()))); mEntryManager.updateNotificationRanking(mRankingMap); verify(mRow, never()).setEntry(eq(mEntry)); @@ -478,7 +480,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mEntryManager.addNotificationLifetimeExtender(extender); // WHEN the notification is removed - mEntryManager.removeNotification(mEntry.key, mRankingMap, UNDEFINED_DISMISS_REASON); + mEntryManager.removeNotification(mEntry.getKey(), mRankingMap, UNDEFINED_DISMISS_REASON); // THEN the extender is asked to manage the lifetime verify(extender).setShouldManageLifetime(mEntry, true); @@ -494,12 +496,12 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mEntryManager.getNotificationData().add(mEntry); final FakeNotificationLifetimeExtender extender = new FakeNotificationLifetimeExtender(); mEntryManager.addNotificationLifetimeExtender(extender); - mEntryManager.removeNotification(mEntry.key, mRankingMap, UNDEFINED_DISMISS_REASON); - assertTrue(extender.isManaging(mEntry.key)); + mEntryManager.removeNotification(mEntry.getKey(), mRankingMap, UNDEFINED_DISMISS_REASON); + assertTrue(extender.isManaging(mEntry.getKey())); // WHEN the extender finishes its extension extender.setExtendLifetimes(false); - extender.getCallback().onSafeToRemove(mEntry.key); + extender.getCallback().onSafeToRemove(mEntry.getKey()); // THEN the notification is removed assertNull(mEntryManager.getNotificationData().get(mSbn.getKey())); @@ -514,10 +516,10 @@ public class NotificationEntryManagerTest extends SysuiTestCase { NotificationLifetimeExtender extender = mock(NotificationLifetimeExtender.class); when(extender.shouldExtendLifetime(mEntry)).thenReturn(true); mEntryManager.addNotificationLifetimeExtender(extender); - mEntryManager.removeNotification(mEntry.key, mRankingMap, UNDEFINED_DISMISS_REASON); + mEntryManager.removeNotification(mEntry.getKey(), mRankingMap, UNDEFINED_DISMISS_REASON); // WHEN the notification is updated - mEntryManager.updateNotification(mEntry.notification, mRankingMap); + mEntryManager.updateNotification(mEntry.getSbn(), mRankingMap); // THEN the lifetime extension is canceled verify(extender).setShouldManageLifetime(mEntry, false); @@ -539,13 +541,13 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mEntryManager.addNotificationLifetimeExtender(extender2); // GIVEN a notification was lifetime-extended and extender2 is managing it - mEntryManager.removeNotification(mEntry.key, mRankingMap, UNDEFINED_DISMISS_REASON); + mEntryManager.removeNotification(mEntry.getKey(), mRankingMap, UNDEFINED_DISMISS_REASON); verify(extender1, never()).setShouldManageLifetime(mEntry, true); verify(extender2).setShouldManageLifetime(mEntry, true); // WHEN the extender1 changes its mind and wants to extend the lifetime of the notif when(extender1.shouldExtendLifetime(mEntry)).thenReturn(true); - mEntryManager.removeNotification(mEntry.key, mRankingMap, UNDEFINED_DISMISS_REASON); + mEntryManager.removeNotification(mEntry.getKey(), mRankingMap, UNDEFINED_DISMISS_REASON); // THEN extender2 stops managing the notif and extender1 starts managing it verify(extender1).setShouldManageLifetime(mEntry, true); @@ -569,14 +571,14 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mEntryManager.getNotificationData().add(mEntry); // GIVEN interceptor that intercepts that entry - when(mRemoveInterceptor.onNotificationRemoveRequested(eq(mEntry.key), anyInt())) + when(mRemoveInterceptor.onNotificationRemoveRequested(eq(mEntry.getKey()), anyInt())) .thenReturn(true); // WHEN the notification is removed - mEntryManager.removeNotification(mEntry.key, mRankingMap, UNDEFINED_DISMISS_REASON); + mEntryManager.removeNotification(mEntry.getKey(), mRankingMap, UNDEFINED_DISMISS_REASON); // THEN the interceptor intercepts & the entry is not removed & no listeners are called - assertNotNull(mEntryManager.getNotificationData().get(mEntry.key)); + assertNotNull(mEntryManager.getNotificationData().get(mEntry.getKey())); verify(mEntryListener, never()).onEntryRemoved(eq(mEntry), any(NotificationVisibility.class), anyBoolean()); } @@ -588,14 +590,14 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mEntryManager.getNotificationData().add(mEntry); // GIVEN interceptor that doesn't intercept - when(mRemoveInterceptor.onNotificationRemoveRequested(eq(mEntry.key), anyInt())) + when(mRemoveInterceptor.onNotificationRemoveRequested(eq(mEntry.getKey()), anyInt())) .thenReturn(false); // WHEN the notification is removed - mEntryManager.removeNotification(mEntry.key, mRankingMap, UNDEFINED_DISMISS_REASON); + mEntryManager.removeNotification(mEntry.getKey(), mRankingMap, UNDEFINED_DISMISS_REASON); // THEN the interceptor intercepts & the entry is not removed & no listeners are called - assertNull(mEntryManager.getNotificationData().get(mEntry.key)); + assertNull(mEntryManager.getNotificationData().get(mEntry.getKey())); verify(mEntryListener, atLeastOnce()).onEntryRemoved(eq(mEntry), any(NotificationVisibility.class), anyBoolean()); } @@ -626,17 +628,17 @@ public class NotificationEntryManagerTest extends SysuiTestCase { public void setShouldManageLifetime( @NonNull NotificationEntry entry, boolean shouldManage) { - final boolean hasEntry = mManagedNotifs.contains(entry.key); + final boolean hasEntry = mManagedNotifs.contains(entry.getKey()); if (shouldManage) { if (hasEntry) { - throw new RuntimeException("Already managing this entry: " + entry.key); + throw new RuntimeException("Already managing this entry: " + entry.getKey()); } - mManagedNotifs.add(entry.key); + mManagedNotifs.add(entry.getKey()); } else { if (!hasEntry) { - throw new RuntimeException("Not managing this entry: " + entry.key); + throw new RuntimeException("Not managing this entry: " + entry.getKey()); } - mManagedNotifs.remove(entry.key); + mManagedNotifs.remove(entry.getKey()); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationFilterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationFilterTest.java index 45e1721782a1..d85f2752a247 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationFilterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationFilterTest.java @@ -142,7 +142,7 @@ public class NotificationFilterTest extends SysuiTestCase { public void testSuppressSystemAlertNotification() { when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(true); - StatusBarNotification sbn = mRow.getEntry().notification; + StatusBarNotification sbn = mRow.getEntry().getSbn(); Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{"something"}); sbn.getNotification().extras = bundle; @@ -152,7 +152,7 @@ public class NotificationFilterTest extends SysuiTestCase { @Test public void testDoNotSuppressSystemAlertNotification() { - StatusBarNotification sbn = mRow.getEntry().notification; + StatusBarNotification sbn = mRow.getEntry().getSbn(); Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{"something"}); sbn.getNotification().extras = bundle; @@ -180,7 +180,7 @@ public class NotificationFilterTest extends SysuiTestCase { // missing extra assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); - StatusBarNotification sbn = mRow.getEntry().notification; + StatusBarNotification sbn = mRow.getEntry().getSbn(); Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{}); sbn.getNotification().extras = bundle; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationListControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationListControllerTest.java index 170c661eb325..9202c51d3c97 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationListControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationListControllerTest.java @@ -109,7 +109,7 @@ public class NotificationListControllerTest extends SysuiTestCase { final NotificationEntry entry = buildEntry(); mEntryListener.onEntryRemoved( entry, - NotificationVisibility.obtain(entry.key, 0, 0, true), + NotificationVisibility.obtain(entry.getKey(), 0, 0, true), false); verify(mListContainer).cleanUpViewStateForEntry(entry); } @@ -126,13 +126,13 @@ public class NotificationListControllerTest extends SysuiTestCase { final NotificationEntry entry = buildEntry(); mNotificationData.add(entry); when(mForegroundServiceController.getStandardLayoutKey(anyInt(), anyString())) - .thenReturn(entry.key); + .thenReturn(entry.getKey()); // WHEN we are notified of a new app op mController.updateNotificationsForAppOp( AppOpsManager.OP_CAMERA, - entry.notification.getUid(), - entry.notification.getPackageName(), + entry.getSbn().getUid(), + entry.getSbn().getPackageName(), true); // THEN the app op is added to the entry @@ -165,10 +165,10 @@ public class NotificationListControllerTest extends SysuiTestCase { expected.add(235); expected.add(1); when(mForegroundServiceController.getStandardLayoutKey( - entry.notification.getUserId(), - entry.notification.getPackageName())).thenReturn(entry.key); - when(mForegroundServiceController.getAppOps(entry.notification.getUserId(), - entry.notification.getPackageName())).thenReturn(expected); + entry.getSbn().getUserId(), + entry.getSbn().getPackageName())).thenReturn(entry.getKey()); + when(mForegroundServiceController.getAppOps(entry.getSbn().getUserId(), + entry.getSbn().getPackageName())).thenReturn(expected); // WHEN the notification is added mEntryListener.onBeforeNotificationAdded(entry); @@ -187,10 +187,10 @@ public class NotificationListControllerTest extends SysuiTestCase { mNotificationData.add(entry); when(mForegroundServiceController.getStandardLayoutKey( - entry.notification.getUserId(), - entry.notification.getPackageName())).thenReturn(entry.key); - when(mForegroundServiceController.getAppOps(entry.notification.getUserId(), - entry.notification.getPackageName())).thenReturn(null); + entry.getSbn().getUserId(), + entry.getSbn().getPackageName())).thenReturn(entry.getKey()); + when(mForegroundServiceController.getAppOps(entry.getSbn().getUserId(), + entry.getSbn().getPackageName())).thenReturn(null); // WHEN the notification is added mEntryListener.onBeforeNotificationAdded(entry); @@ -208,11 +208,11 @@ public class NotificationListControllerTest extends SysuiTestCase { ops.add(3); ops.add(235); ops.add(1); - when(mForegroundServiceController.getAppOps(entry.notification.getUserId(), - entry.notification.getPackageName())).thenReturn(ops); + when(mForegroundServiceController.getAppOps(entry.getSbn().getUserId(), + entry.getSbn().getPackageName())).thenReturn(ops); when(mForegroundServiceController.getStandardLayoutKey( - entry.notification.getUserId(), - entry.notification.getPackageName())).thenReturn("something else"); + entry.getSbn().getUserId(), + entry.getSbn().getPackageName())).thenReturn("something else"); // WHEN the notification is added mEntryListener.onBeforeNotificationAdded(entry); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationDataTest.java index 20871cfe2e2b..640984b1129f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationDataTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationDataTest.java @@ -153,7 +153,7 @@ public class NotificationDataTest extends SysuiTestCase { public void testChannelSetWhenAdded() { Bundle override = new Bundle(); override.putParcelable(OVERRIDE_CHANNEL, NOTIFICATION_CHANNEL); - mNotificationData.rankingOverrides.put(mRow.getEntry().key, override); + mNotificationData.rankingOverrides.put(mRow.getEntry().getKey(), override); mNotificationData.add(mRow.getEntry()); assertEquals(NOTIFICATION_CHANNEL, mRow.getEntry().getChannel()); } @@ -175,17 +175,17 @@ public class NotificationDataTest extends SysuiTestCase { for (int op : expectedOps) { mNotificationData.updateAppOp(op, NotificationTestHelper.UID, - NotificationTestHelper.PKG, mRow.getEntry().key, true); + NotificationTestHelper.PKG, mRow.getEntry().getKey(), true); mNotificationData.updateAppOp(op, NotificationTestHelper.UID, - NotificationTestHelper.PKG, row2.getEntry().key, true); + NotificationTestHelper.PKG, row2.getEntry().getKey(), true); } for (int op : expectedOps) { - assertTrue(mRow.getEntry().key + " doesn't have op " + op, - mNotificationData.get(mRow.getEntry().key).mActiveAppOps.contains(op)); - assertTrue(row2.getEntry().key + " doesn't have op " + op, - mNotificationData.get(row2.getEntry().key).mActiveAppOps.contains(op)); - assertFalse(diffPkg.getEntry().key + " has op " + op, - mNotificationData.get(diffPkg.getEntry().key).mActiveAppOps.contains(op)); + assertTrue(mRow.getEntry().getKey() + " doesn't have op " + op, + mNotificationData.get(mRow.getEntry().getKey()).mActiveAppOps.contains(op)); + assertTrue(row2.getEntry().getKey() + " doesn't have op " + op, + mNotificationData.get(row2.getEntry().getKey()).mActiveAppOps.contains(op)); + assertFalse(diffPkg.getEntry().getKey() + " has op " + op, + mNotificationData.get(diffPkg.getEntry().getKey()).mActiveAppOps.contains(op)); } } @@ -202,22 +202,22 @@ public class NotificationDataTest extends SysuiTestCase { for (int op : expectedOps) { mNotificationData.updateAppOp(op, NotificationTestHelper.UID, - NotificationTestHelper.PKG, row2.getEntry().key, true); + NotificationTestHelper.PKG, row2.getEntry().getKey(), true); } expectedOps.remove(OP_ACCEPT_HANDOVER); mNotificationData.updateAppOp(OP_ACCEPT_HANDOVER, NotificationTestHelper.UID, - NotificationTestHelper.PKG, row2.getEntry().key, false); - - assertTrue(mRow.getEntry().key + " doesn't have op " + OP_CAMERA, - mNotificationData.get(mRow.getEntry().key).mActiveAppOps.contains(OP_CAMERA)); - assertTrue(row2.getEntry().key + " doesn't have op " + OP_CAMERA, - mNotificationData.get(row2.getEntry().key).mActiveAppOps.contains(OP_CAMERA)); - assertFalse(mRow.getEntry().key + " has op " + OP_ACCEPT_HANDOVER, - mNotificationData.get(mRow.getEntry().key) + NotificationTestHelper.PKG, row2.getEntry().getKey(), false); + + assertTrue(mRow.getEntry().getKey() + " doesn't have op " + OP_CAMERA, + mNotificationData.get(mRow.getEntry().getKey()).mActiveAppOps.contains(OP_CAMERA)); + assertTrue(row2.getEntry().getKey() + " doesn't have op " + OP_CAMERA, + mNotificationData.get(row2.getEntry().getKey()).mActiveAppOps.contains(OP_CAMERA)); + assertFalse(mRow.getEntry().getKey() + " has op " + OP_ACCEPT_HANDOVER, + mNotificationData.get(mRow.getEntry().getKey()) .mActiveAppOps.contains(OP_ACCEPT_HANDOVER)); - assertFalse(row2.getEntry().key + " has op " + OP_ACCEPT_HANDOVER, - mNotificationData.get(row2.getEntry().key) + assertFalse(row2.getEntry().getKey() + " has op " + OP_ACCEPT_HANDOVER, + mNotificationData.get(row2.getEntry().getKey()) .mActiveAppOps.contains(OP_ACCEPT_HANDOVER)); } @@ -230,9 +230,9 @@ public class NotificationDataTest extends SysuiTestCase { mNotificationData.add(row2.getEntry()); when(mEnvironment.isNotificationForCurrentProfiles( - mRow.getEntry().notification)).thenReturn(false); + mRow.getEntry().getSbn())).thenReturn(false); when(mEnvironment.isNotificationForCurrentProfiles( - row2.getEntry().notification)).thenReturn(true); + row2.getEntry().getSbn())).thenReturn(true); ArrayList<NotificationEntry> result = mNotificationData.getNotificationsForCurrentUser(); @@ -249,7 +249,7 @@ public class NotificationDataTest extends SysuiTestCase { mNotificationData.add(mEntry); Bundle override = new Bundle(); override.putInt(OVERRIDE_VIS_EFFECTS, 255); - mNotificationData.rankingOverrides.put(mEntry.key, override); + mNotificationData.rankingOverrides.put(mEntry.getKey(), override); assertTrue(mEntry.isExemptFromDndVisualSuppression()); assertFalse(mEntry.shouldSuppressAmbient()); @@ -269,7 +269,7 @@ public class NotificationDataTest extends SysuiTestCase { mNotificationData.add(mEntry); Bundle override = new Bundle(); override.putInt(OVERRIDE_VIS_EFFECTS, 255); - mNotificationData.rankingOverrides.put(mEntry.key, override); + mNotificationData.rankingOverrides.put(mEntry.getKey(), override); assertTrue(mEntry.isExemptFromDndVisualSuppression()); assertFalse(mEntry.shouldSuppressAmbient()); @@ -283,7 +283,7 @@ public class NotificationDataTest extends SysuiTestCase { mNotificationData.add(mEntry); Bundle override = new Bundle(); override.putInt(OVERRIDE_VIS_EFFECTS, 255); - mNotificationData.rankingOverrides.put(mEntry.key, override); + mNotificationData.rankingOverrides.put(mEntry.getKey(), override); assertTrue(mEntry.isExemptFromDndVisualSuppression()); assertFalse(mEntry.shouldSuppressAmbient()); @@ -299,7 +299,7 @@ public class NotificationDataTest extends SysuiTestCase { entry.mIsSystemNotification = true; Bundle override = new Bundle(); override.putInt(OVERRIDE_VIS_EFFECTS, NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT); - mNotificationData.rankingOverrides.put(entry.key, override); + mNotificationData.rankingOverrides.put(entry.getKey(), override); mNotificationData.add(entry); modifySbn(entry) @@ -511,7 +511,7 @@ public class NotificationDataTest extends SysuiTestCase { Bundle override = new Bundle(); override.putInt(OVERRIDE_IMPORTANCE, IMPORTANCE_LOW); override.putInt(OVERRIDE_RANK, 1); - mNotificationData.rankingOverrides.put(a.key, override); + mNotificationData.rankingOverrides.put(a.getKey(), override); Notification bN = new Notification.Builder(mContext, "test") .setStyle(new Notification.MessagingStyle("")) @@ -530,7 +530,7 @@ public class NotificationDataTest extends SysuiTestCase { Bundle bOverride = new Bundle(); bOverride.putInt(OVERRIDE_IMPORTANCE, IMPORTANCE_LOW); bOverride.putInt(OVERRIDE_RANK, 2); - mNotificationData.rankingOverrides.put(b.key, bOverride); + mNotificationData.rankingOverrides.put(b.getKey(), bOverride); assertEquals(1, mNotificationData.mRankingComparator.compare(a, b)); } @@ -555,7 +555,7 @@ public class NotificationDataTest extends SysuiTestCase { Bundle override = new Bundle(); override.putInt(OVERRIDE_IMPORTANCE, IMPORTANCE_LOW); override.putInt(OVERRIDE_RANK, 1); - mNotificationData.rankingOverrides.put(a.key, override); + mNotificationData.rankingOverrides.put(a.getKey(), override); Notification bN = new Notification.Builder(mContext, "test") .setStyle(new Notification.MessagingStyle("")) @@ -574,7 +574,7 @@ public class NotificationDataTest extends SysuiTestCase { Bundle bOverride = new Bundle(); bOverride.putInt(OVERRIDE_IMPORTANCE, IMPORTANCE_LOW); bOverride.putInt(OVERRIDE_RANK, 2); - mNotificationData.rankingOverrides.put(b.key, bOverride); + mNotificationData.rankingOverrides.put(b.getKey(), bOverride); assertEquals(-1, mNotificationData.mRankingComparator.compare(a, b)); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java index 24cd056b789c..47c17ad88fcb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java @@ -113,7 +113,7 @@ public class NotificationLoggerTest extends SysuiTestCase { @Test public void testOnChildLocationsChangedReportsVisibilityChanged() throws Exception { NotificationVisibility[] newlyVisibleKeys = { - NotificationVisibility.obtain(mEntry.key, 0, 1, true) + NotificationVisibility.obtain(mEntry.getKey(), 0, 1, true) }; NotificationVisibility[] noLongerVisibleKeys = {}; doAnswer(invocation -> { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java index 41fe1735b5b2..c7877bb8f4f9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java @@ -487,13 +487,13 @@ public class NotificationGutsManagerTest extends SysuiTestCase { NotificationEntry entry = createTestNotificationRow().getEntry(); mGutsManager.setShouldManageLifetime(entry, true /* shouldManage */); - assertTrue(entry.key.equals(mGutsManager.mKeyToRemoveOnGutsClosed)); + assertTrue(entry.getKey().equals(mGutsManager.mKeyToRemoveOnGutsClosed)); } @Test public void testSetShouldManageLifetime_setShouldNotManage() { NotificationEntry entry = createTestNotificationRow().getEntry(); - mGutsManager.mKeyToRemoveOnGutsClosed = entry.key; + mGutsManager.mKeyToRemoveOnGutsClosed = entry.getKey(); mGutsManager.setShouldManageLifetime(entry, false /* shouldManage */); assertNull(mGutsManager.mKeyToRemoveOnGutsClosed); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java index 6fcf550c56bc..2068f7ccc3ca 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java @@ -102,27 +102,27 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest { mHeadsUpManager.snooze(); - assertTrue(mHeadsUpManager.isSnoozed(mEntry.notification.getPackageName())); + assertTrue(mHeadsUpManager.isSnoozed(mEntry.getSbn().getPackageName())); } @Test public void testSwipedOutNotification() { mHeadsUpManager.showNotification(mEntry); - mHeadsUpManager.addSwipedOutNotification(mEntry.key); + mHeadsUpManager.addSwipedOutNotification(mEntry.getKey()); // Remove should succeed because the notification is swiped out - mHeadsUpManager.removeNotification(mEntry.key, false /* releaseImmediately */); + mHeadsUpManager.removeNotification(mEntry.getKey(), false /* releaseImmediately */); - assertFalse(mHeadsUpManager.isAlerting(mEntry.key)); + assertFalse(mHeadsUpManager.isAlerting(mEntry.getKey())); } @Test public void testCanRemoveImmediately_swipedOut() { mHeadsUpManager.showNotification(mEntry); - mHeadsUpManager.addSwipedOutNotification(mEntry.key); + mHeadsUpManager.addSwipedOutNotification(mEntry.getKey()); // Notification is swiped so it can be immediately removed. - assertTrue(mHeadsUpManager.canRemoveImmediately(mEntry.key)); + assertTrue(mHeadsUpManager.canRemoveImmediately(mEntry.getKey())); } @Test @@ -135,7 +135,7 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest { mHeadsUpManager.showNotification(laterEntry); // Notification is "behind" a higher priority notification so we can remove it immediately. - assertTrue(mHeadsUpManager.canRemoveImmediately(mEntry.key)); + assertTrue(mHeadsUpManager.canRemoveImmediately(mEntry.getKey())); } @@ -143,7 +143,7 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest { public void testExtendHeadsUp() { mHeadsUpManager.showNotification(mEntry); Runnable pastNormalTimeRunnable = - () -> mLivesPastNormalTime = mHeadsUpManager.isAlerting(mEntry.key); + () -> mLivesPastNormalTime = mHeadsUpManager.isAlerting(mEntry.getKey()); mTestHandler.postDelayed(pastNormalTimeRunnable, TEST_AUTO_DISMISS_TIME + mHeadsUpManager.mExtensionTime / 2); mTestHandler.postDelayed(TEST_TIMEOUT_RUNNABLE, TEST_TIMEOUT_TIME); @@ -155,6 +155,6 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest { assertFalse("Test timed out", mTimedOut); assertTrue("Pulse was not extended", mLivesPastNormalTime); - assertFalse(mHeadsUpManager.isAlerting(mEntry.key)); + assertFalse(mHeadsUpManager.isAlerting(mEntry.getKey())); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java index 225423415421..5b54fba5b3b5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java @@ -102,8 +102,8 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupManager.onEntryAdded(childEntry); // A suppressed summary should transfer its alert state to the child. - assertFalse(mHeadsUpManager.isAlerting(summaryEntry.key)); - assertTrue(mHeadsUpManager.isAlerting(childEntry.key)); + assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey())); + assertTrue(mHeadsUpManager.isAlerting(childEntry.getKey())); } @Test @@ -120,14 +120,14 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupManager.onEntryAdded(childEntry); // Add second child notification so that summary is no longer suppressed. - mPendingEntries.put(childEntry2.key, childEntry2); + mPendingEntries.put(childEntry2.getKey(), childEntry2); mNotificationEntryListener.onPendingEntryAdded(childEntry2); mGroupManager.onEntryAdded(childEntry2); // The alert state should transfer back to the summary as there is now more than one // child and the summary should no longer be suppressed. - assertTrue(mHeadsUpManager.isAlerting(summaryEntry.key)); - assertFalse(mHeadsUpManager.isAlerting(childEntry.key)); + assertTrue(mHeadsUpManager.isAlerting(summaryEntry.getKey())); + assertFalse(mHeadsUpManager.isAlerting(childEntry.getKey())); } @Test @@ -147,12 +147,12 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupAlertTransferHelper.onDozingChanged(true); // Add second child notification so that summary is no longer suppressed. - mPendingEntries.put(childEntry2.key, childEntry2); + mPendingEntries.put(childEntry2.getKey(), childEntry2); mNotificationEntryListener.onPendingEntryAdded(childEntry2); mGroupManager.onEntryAdded(childEntry2); // Dozing changed so no reason to re-alert summary. - assertFalse(mHeadsUpManager.isAlerting(summaryEntry.key)); + assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey())); } @Test @@ -168,8 +168,8 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { // Alert is immediately removed from summary, but we do not show child yet either as its // content is not inflated. - assertFalse(mHeadsUpManager.isAlerting(summaryEntry.key)); - assertFalse(mHeadsUpManager.isAlerting(childEntry.key)); + assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey())); + assertFalse(mHeadsUpManager.isAlerting(childEntry.getKey())); assertTrue(mGroupAlertTransferHelper.isAlertTransferPending(childEntry)); } @@ -189,8 +189,8 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mNotificationEntryListener.onEntryReinflated(childEntry); // Alert is immediately removed from summary, and we show child as its content is inflated. - assertFalse(mHeadsUpManager.isAlerting(summaryEntry.key)); - assertTrue(mHeadsUpManager.isAlerting(childEntry.key)); + assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey())); + assertTrue(mHeadsUpManager.isAlerting(childEntry.getKey())); } @Test @@ -209,7 +209,7 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupManager.onEntryAdded(childEntry); // Add second child notification so that summary is no longer suppressed. - mPendingEntries.put(childEntry2.key, childEntry2); + mPendingEntries.put(childEntry2.getKey(), childEntry2); mNotificationEntryListener.onPendingEntryAdded(childEntry2); mGroupManager.onEntryAdded(childEntry2); @@ -220,7 +220,7 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { verify(childEntry.getRow(), times(1)).freeContentViewWhenSafe(mHeadsUpManager .getContentFlag()); - assertFalse(mHeadsUpManager.isAlerting(childEntry.key)); + assertFalse(mHeadsUpManager.isAlerting(childEntry.getKey())); } @Test @@ -255,10 +255,10 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupManager.onEntryAdded(childEntry); // Notify that entry changed groups. - StatusBarNotification oldNotification = childEntry.notification; - StatusBarNotification newSbn = spy(childEntry.notification.clone()); + StatusBarNotification oldNotification = childEntry.getSbn(); + StatusBarNotification newSbn = spy(childEntry.getSbn().clone()); doReturn("other_group").when(newSbn).getGroupKey(); - childEntry.setNotification(newSbn); + childEntry.setSbn(newSbn); mGroupManager.onEntryUpdated(childEntry, oldNotification); assertFalse(mGroupAlertTransferHelper.isAlertTransferPending(childEntry)); @@ -278,10 +278,10 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupManager.onEntryAdded(childEntry); // Update that child to a summary. - StatusBarNotification oldNotification = childEntry.notification; - childEntry.setNotification( + StatusBarNotification oldNotification = childEntry.getSbn(); + childEntry.setSbn( mGroupTestHelper.createSummaryNotification( - Notification.GROUP_ALERT_SUMMARY, 47).notification); + Notification.GROUP_ALERT_SUMMARY, 47).getSbn()); mGroupManager.onEntryUpdated(childEntry, oldNotification); assertFalse(mGroupAlertTransferHelper.isAlertTransferPending(childEntry)); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java index 493b74dd66cf..19ce1ea218c9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java @@ -75,7 +75,7 @@ public class NotificationGroupManagerTest extends SysuiTestCase { mGroupManager.onEntryAdded(summaryEntry); mGroupManager.onEntryAdded(childEntry); - assertTrue(mGroupManager.isOnlyChildInGroup(childEntry.notification)); + assertTrue(mGroupManager.isOnlyChildInGroup(childEntry.getSbn())); } @Test @@ -87,7 +87,7 @@ public class NotificationGroupManagerTest extends SysuiTestCase { mGroupManager.onEntryAdded(childEntry); mGroupManager.onEntryAdded(mGroupTestHelper.createChildNotification()); - assertTrue(mGroupManager.isChildInGroupWithSummary(childEntry.notification)); + assertTrue(mGroupManager.isChildInGroupWithSummary(childEntry.getSbn())); } @Test @@ -99,8 +99,8 @@ public class NotificationGroupManagerTest extends SysuiTestCase { mGroupManager.onEntryAdded(childEntry); mGroupManager.onEntryAdded(mGroupTestHelper.createChildNotification()); - assertTrue(mGroupManager.isSummaryOfGroup(summaryEntry.notification)); - assertEquals(summaryEntry, mGroupManager.getGroupSummary(childEntry.notification)); + assertTrue(mGroupManager.isSummaryOfGroup(summaryEntry.getSbn())); + assertEquals(summaryEntry, mGroupManager.getGroupSummary(childEntry.getSbn())); } @Test @@ -113,7 +113,7 @@ public class NotificationGroupManagerTest extends SysuiTestCase { mGroupManager.onEntryRemoved(childEntry); - assertFalse(mGroupManager.isChildInGroupWithSummary(childEntry.notification)); + assertFalse(mGroupManager.isChildInGroupWithSummary(childEntry.getSbn())); } @Test @@ -126,8 +126,8 @@ public class NotificationGroupManagerTest extends SysuiTestCase { mGroupManager.onEntryRemoved(summaryEntry); - assertNull(mGroupManager.getGroupSummary(childEntry.notification)); - assertFalse(mGroupManager.isSummaryOfGroup(summaryEntry.notification)); + assertNull(mGroupManager.getGroupSummary(childEntry.getSbn())); + assertFalse(mGroupManager.isSummaryOfGroup(summaryEntry.getSbn())); } @Test @@ -137,13 +137,13 @@ public class NotificationGroupManagerTest extends SysuiTestCase { mGroupManager.onEntryAdded(summaryEntry); mGroupManager.onEntryAdded(childEntry); mGroupManager.onEntryAdded(mGroupTestHelper.createChildNotification()); - when(mHeadsUpManager.isAlerting(childEntry.key)).thenReturn(true); + when(mHeadsUpManager.isAlerting(childEntry.getKey())).thenReturn(true); mGroupManager.onHeadsUpStateChanged(childEntry, true); // Child entries that are heads upped should be considered separate groups visually even if // they are the same group logically - assertEquals(childEntry, mGroupManager.getGroupSummary(childEntry.notification)); - assertEquals(summaryEntry, mGroupManager.getLogicalGroupSummary(childEntry.notification)); + assertEquals(childEntry, mGroupManager.getGroupSummary(childEntry.getSbn())); + assertEquals(summaryEntry, mGroupManager.getLogicalGroupSummary(childEntry.getSbn())); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java index 6b83fed64ddf..fc7d0ce30687 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java @@ -73,7 +73,7 @@ public class HeadsUpManagerTest extends AlertingNotificationManagerTest { .getRecommendedTimeoutMillis(anyInt(), anyInt()); mHeadsUpManager.showNotification(mEntry); Runnable pastNormalTimeRunnable = - () -> mLivesPastNormalTime = mHeadsUpManager.isAlerting(mEntry.key); + () -> mLivesPastNormalTime = mHeadsUpManager.isAlerting(mEntry.getKey()); mTestHandler.postDelayed(pastNormalTimeRunnable, (TEST_A11Y_AUTO_DISMISS_TIME + TEST_AUTO_DISMISS_TIME) / 2); mTestHandler.postDelayed(TEST_TIMEOUT_RUNNABLE, TEST_A11Y_TIMEOUT_TIME); @@ -82,7 +82,7 @@ public class HeadsUpManagerTest extends AlertingNotificationManagerTest { assertFalse("Test timed out", mTimedOut); assertTrue("Heads up should live long enough", mLivesPastNormalTime); - assertFalse(mHeadsUpManager.isAlerting(mEntry.key)); + assertFalse(mHeadsUpManager.isAlerting(mEntry.getKey())); } } |