Merge "Fixed a bug where autobundling could lead to bugs" into nyc-dev

This commit is contained in:
TreeHugger Robot
2016-05-19 00:58:24 +00:00
committed by Android (Google) Code Review
2 changed files with 15 additions and 5 deletions

View File

@@ -22,7 +22,6 @@ import static android.service.notification.NotificationRankerService.REASON_DELE
import static android.service.notification.NotificationRankerService.REASON_DELEGATE_CANCEL_ALL; import static android.service.notification.NotificationRankerService.REASON_DELEGATE_CANCEL_ALL;
import static android.service.notification.NotificationRankerService.REASON_DELEGATE_CLICK; import static android.service.notification.NotificationRankerService.REASON_DELEGATE_CLICK;
import static android.service.notification.NotificationRankerService.REASON_DELEGATE_ERROR; import static android.service.notification.NotificationRankerService.REASON_DELEGATE_ERROR;
import static android.service.notification.NotificationRankerService.REASON_GROUP_OPTIMIZATION;
import static android.service.notification.NotificationRankerService.REASON_GROUP_SUMMARY_CANCELED; import static android.service.notification.NotificationRankerService.REASON_GROUP_SUMMARY_CANCELED;
import static android.service.notification.NotificationRankerService.REASON_LISTENER_CANCEL; import static android.service.notification.NotificationRankerService.REASON_LISTENER_CANCEL;
import static android.service.notification.NotificationRankerService.REASON_LISTENER_CANCEL_ALL; import static android.service.notification.NotificationRankerService.REASON_LISTENER_CANCEL_ALL;
@@ -164,7 +163,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -2221,8 +2219,14 @@ public class NotificationManagerService extends SystemService {
int userId = -1; int userId = -1;
NotificationRecord summaryRecord = null; NotificationRecord summaryRecord = null;
synchronized (mNotificationList) { synchronized (mNotificationList) {
final StatusBarNotification adjustedSbn NotificationRecord notificationRecord =
= mNotificationsByKey.get(adjustment.getKey()).sbn; mNotificationsByKey.get(adjustment.getKey());
if (notificationRecord == null) {
// The notification could have been cancelled again already. A successive
// adjustment will post a summary if needed.
return;
}
final StatusBarNotification adjustedSbn = notificationRecord.sbn;
userId = adjustedSbn.getUser().getIdentifier(); userId = adjustedSbn.getUser().getIdentifier();
ArrayMap<String, String> summaries = mAutobundledSummaries.get(userId); ArrayMap<String, String> summaries = mAutobundledSummaries.get(userId);
if (summaries == null) { if (summaries == null) {
@@ -2666,6 +2670,12 @@ public class NotificationManagerService extends SystemService {
int callingUid, int callingPid) { int callingUid, int callingPid) {
StatusBarNotification sbn = r.sbn; StatusBarNotification sbn = r.sbn;
Notification n = sbn.getNotification(); Notification n = sbn.getNotification();
if (n.isGroupSummary() && !sbn.isAppGroup()) {
// notifications without a group shouldn't be a summary, otherwise autobundling can
// lead to bugs
n.flags &= ~Notification.FLAG_GROUP_SUMMARY;
}
String group = sbn.getGroupKey(); String group = sbn.getGroupKey();
boolean isSummary = n.isGroupSummary(); boolean isSummary = n.isGroupSummary();

View File

@@ -176,7 +176,7 @@ public final class NotificationRecord {
mRankingTimeMs = calculateRankingTimeMs(previous.getRankingTimeMs()); mRankingTimeMs = calculateRankingTimeMs(previous.getRankingTimeMs());
mCreationTimeMs = previous.mCreationTimeMs; mCreationTimeMs = previous.mCreationTimeMs;
mVisibleSinceMs = previous.mVisibleSinceMs; mVisibleSinceMs = previous.mVisibleSinceMs;
if(previous.sbn.getOverrideGroupKey() != null) { if (previous.sbn.getOverrideGroupKey() != null && !sbn.isAppGroup()) {
sbn.setOverrideGroupKey(previous.sbn.getOverrideGroupKey()); sbn.setOverrideGroupKey(previous.sbn.getOverrideGroupKey());
} }
// Don't copy importance information or mGlobalSortKey, recompute them. // Don't copy importance information or mGlobalSortKey, recompute them.