Encapsulate NotifEntry.key and .notification
NotificationEntry.key -> getKey()
NotificationEntry.notification -> getSbn()
.key -> mKey
.notification -> mSbn
Test: atest
Change-Id: Idcc56af5d941d600b2958afb9ed898fd7ab361cc
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
index c3cee35..7600b2f 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 @@
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 @@
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 @@
}
public String getPackageName() {
- return mEntry.notification.getPackageName();
+ return mEntry.getSbn().getPackageName();
}
public String getAppName() {
@@ -190,7 +190,7 @@
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 @@
* 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 @@
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 @@
@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 @@
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 @@
* 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 9568a18..0231b56 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 @@
// 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 @@
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 @@
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 @@
@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 @@
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 @@
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 @@
// 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 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 @@
&& !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 @@
// 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 @@
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 d43e030..2f7f47b6 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 @@
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 @@
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 @@
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 @@
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 6f953d5..1d9f6b2 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 @@
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 @@
* @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 340dced..e5af389 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 @@
}
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 @@
*/
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 @@
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 4512aa8..780c314 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 @@
}
// 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;