Merge "Fix Conversation widget on new notif pipeline" into tm-dev am: 1e6d8d693f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17543543 Change-Id: I96c964cd18d26eb5a69ec0b3377c043371db40ff Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -441,12 +441,16 @@ public class PeopleSpaceWidgetManager {
|
|||||||
Log.d(TAG, "Notification removed, key: " + sbn.getKey());
|
Log.d(TAG, "Notification removed, key: " + sbn.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (DEBUG) Log.d(TAG, "Fetching notifications");
|
||||||
|
Collection<NotificationEntry> notifications = mNotifCollection.getAllNotifs();
|
||||||
mBgExecutor.execute(
|
mBgExecutor.execute(
|
||||||
() -> updateWidgetsWithNotificationChangedInBackground(sbn, notificationAction));
|
() -> updateWidgetsWithNotificationChangedInBackground(
|
||||||
|
sbn, notificationAction, notifications));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWidgetsWithNotificationChangedInBackground(StatusBarNotification sbn,
|
private void updateWidgetsWithNotificationChangedInBackground(StatusBarNotification sbn,
|
||||||
PeopleSpaceUtils.NotificationAction action) {
|
PeopleSpaceUtils.NotificationAction action,
|
||||||
|
Collection<NotificationEntry> notifications) {
|
||||||
try {
|
try {
|
||||||
PeopleTileKey key = new PeopleTileKey(
|
PeopleTileKey key = new PeopleTileKey(
|
||||||
sbn.getShortcutId(), sbn.getUser().getIdentifier(), sbn.getPackageName());
|
sbn.getShortcutId(), sbn.getUser().getIdentifier(), sbn.getPackageName());
|
||||||
@@ -469,7 +473,7 @@ public class PeopleSpaceWidgetManager {
|
|||||||
Log.d(TAG, "Widgets by URI to be updated:" + tilesUpdatedByUri.toString());
|
Log.d(TAG, "Widgets by URI to be updated:" + tilesUpdatedByUri.toString());
|
||||||
}
|
}
|
||||||
tilesUpdated.addAll(tilesUpdatedByUri);
|
tilesUpdated.addAll(tilesUpdatedByUri);
|
||||||
updateWidgetIdsBasedOnNotifications(tilesUpdated);
|
updateWidgetIdsBasedOnNotifications(tilesUpdated, notifications);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Throwing exception: " + e);
|
Log.e(TAG, "Throwing exception: " + e);
|
||||||
@@ -477,15 +481,15 @@ public class PeopleSpaceWidgetManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Updates {@code widgetIdsToUpdate} with {@code action}. */
|
/** Updates {@code widgetIdsToUpdate} with {@code action}. */
|
||||||
private void updateWidgetIdsBasedOnNotifications(Set<String> widgetIdsToUpdate) {
|
private void updateWidgetIdsBasedOnNotifications(Set<String> widgetIdsToUpdate,
|
||||||
|
Collection<NotificationEntry> ungroupedNotifications) {
|
||||||
if (widgetIdsToUpdate.isEmpty()) {
|
if (widgetIdsToUpdate.isEmpty()) {
|
||||||
if (DEBUG) Log.d(TAG, "No widgets to update, returning.");
|
if (DEBUG) Log.d(TAG, "No widgets to update, returning.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (DEBUG) Log.d(TAG, "Fetching grouped notifications");
|
|
||||||
Map<PeopleTileKey, Set<NotificationEntry>> groupedNotifications =
|
Map<PeopleTileKey, Set<NotificationEntry>> groupedNotifications =
|
||||||
getGroupedConversationNotifications();
|
groupConversationNotifications(ungroupedNotifications);
|
||||||
|
|
||||||
widgetIdsToUpdate
|
widgetIdsToUpdate
|
||||||
.stream()
|
.stream()
|
||||||
@@ -510,7 +514,7 @@ public class PeopleSpaceWidgetManager {
|
|||||||
"Augmenting tile from NotificationEntryManager widget: " + key.toString());
|
"Augmenting tile from NotificationEntryManager widget: " + key.toString());
|
||||||
}
|
}
|
||||||
Map<PeopleTileKey, Set<NotificationEntry>> notifications =
|
Map<PeopleTileKey, Set<NotificationEntry>> notifications =
|
||||||
getGroupedConversationNotifications();
|
groupConversationNotifications(mNotifCollection.getAllNotifs());
|
||||||
String contactUri = null;
|
String contactUri = null;
|
||||||
if (tile.getContactUri() != null) {
|
if (tile.getContactUri() != null) {
|
||||||
contactUri = tile.getContactUri().toString();
|
contactUri = tile.getContactUri().toString();
|
||||||
@@ -518,9 +522,10 @@ public class PeopleSpaceWidgetManager {
|
|||||||
return augmentTileFromNotifications(tile, key, contactUri, notifications, appWidgetId);
|
return augmentTileFromNotifications(tile, key, contactUri, notifications, appWidgetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns active and pending notifications grouped by {@link PeopleTileKey}. */
|
/** Groups active and pending notifications grouped by {@link PeopleTileKey}. */
|
||||||
public Map<PeopleTileKey, Set<NotificationEntry>> getGroupedConversationNotifications() {
|
public Map<PeopleTileKey, Set<NotificationEntry>> groupConversationNotifications(
|
||||||
Collection<NotificationEntry> notifications = mNotifCollection.getAllNotifs();
|
Collection<NotificationEntry> notifications
|
||||||
|
) {
|
||||||
if (DEBUG) Log.d(TAG, "Number of total notifications: " + notifications.size());
|
if (DEBUG) Log.d(TAG, "Number of total notifications: " + notifications.size());
|
||||||
Map<PeopleTileKey, Set<NotificationEntry>> groupedNotifications =
|
Map<PeopleTileKey, Set<NotificationEntry>> groupedNotifications =
|
||||||
notifications
|
notifications
|
||||||
|
|||||||
Reference in New Issue
Block a user