summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/notification/NotificationListener.java
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2017-03-24 11:31:12 -0700
committerTony Wickham <twickham@google.com>2017-03-24 14:18:53 -0700
commit2f5bb169154d25bc8c164f057117fb056ad2de96 (patch)
tree04bd51eef88d60dadf5913306ac0c5aa120267a0 /src/com/android/launcher3/notification/NotificationListener.java
parented68728b1f22bc849e0567f2be3aeaf6798440ca (diff)
downloadandroid_packages_apps_Trebuchet-2f5bb169154d25bc8c164f057117fb056ad2de96.tar.gz
android_packages_apps_Trebuchet-2f5bb169154d25bc8c164f057117fb056ad2de96.tar.bz2
android_packages_apps_Trebuchet-2f5bb169154d25bc8c164f057117fb056ad2de96.zip
De-dupe shortcuts with the same id as the main notification.
- Pass NotificationKeyData, which includes the shortcut id, instead of just the notification key from NotificationListener - Remove the shortcut with the same shortcut id as the first notification, if it has one, in PopupPopulator#sortAndFilterShorcuts() - Add some unit tests Bug: 36571718 Change-Id: I308941b34c525b34686583476e3f82ccb8b7e2d8
Diffstat (limited to 'src/com/android/launcher3/notification/NotificationListener.java')
-rw-r--r--src/com/android/launcher3/notification/NotificationListener.java25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/com/android/launcher3/notification/NotificationListener.java b/src/com/android/launcher3/notification/NotificationListener.java
index 16cb5fbb0..75a1b8ab5 100644
--- a/src/com/android/launcher3/notification/NotificationListener.java
+++ b/src/com/android/launcher3/notification/NotificationListener.java
@@ -94,8 +94,8 @@ public class NotificationListener extends NotificationListenerService {
break;
case MSG_NOTIFICATION_REMOVED:
if (sNotificationsChangedListener != null) {
- Pair<PackageUserKey, String> pair
- = (Pair<PackageUserKey, String>) message.obj;
+ Pair<PackageUserKey, NotificationKeyData> pair
+ = (Pair<PackageUserKey, NotificationKeyData>) message.obj;
sNotificationsChangedListener.onNotificationRemoved(pair.first, pair.second);
}
break;
@@ -165,12 +165,12 @@ public class NotificationListener extends NotificationListenerService {
*/
private class NotificationPostedMsg {
PackageUserKey packageUserKey;
- String notificationKey;
+ NotificationKeyData notificationKey;
boolean shouldBeFilteredOut;
NotificationPostedMsg(StatusBarNotification sbn) {
packageUserKey = PackageUserKey.fromNotification(sbn);
- notificationKey = sbn.getKey();
+ notificationKey = NotificationKeyData.fromNotification(sbn);
shouldBeFilteredOut = shouldBeFilteredOut(sbn);
}
}
@@ -178,16 +178,18 @@ public class NotificationListener extends NotificationListenerService {
@Override
public void onNotificationRemoved(final StatusBarNotification sbn) {
super.onNotificationRemoved(sbn);
- Pair<PackageUserKey, String> packageUserKeyAndNotificationKey
- = new Pair<>(PackageUserKey.fromNotification(sbn), sbn.getKey());
+ Pair<PackageUserKey, NotificationKeyData> packageUserKeyAndNotificationKey
+ = new Pair<>(PackageUserKey.fromNotification(sbn),
+ NotificationKeyData.fromNotification(sbn));
mWorkerHandler.obtainMessage(MSG_NOTIFICATION_REMOVED, packageUserKeyAndNotificationKey)
.sendToTarget();
}
/** This makes a potentially expensive binder call and should be run on a background thread. */
- public List<StatusBarNotification> getNotificationsForKeys(String[] keys) {
+ public List<StatusBarNotification> getNotificationsForKeys(List<NotificationKeyData> keys) {
StatusBarNotification[] notifications = NotificationListener.this
- .getActiveNotifications(keys);
+ .getActiveNotifications(NotificationKeyData.extractKeysOnly(keys)
+ .toArray(new String[keys.size()]));
return notifications == null ? Collections.EMPTY_LIST : Arrays.asList(notifications);
}
@@ -238,9 +240,10 @@ public class NotificationListener extends NotificationListenerService {
}
public interface NotificationsChangedListener {
- void onNotificationPosted(PackageUserKey postedPackageUserKey, String notificationKey,
- boolean shouldBeFilteredOut);
- void onNotificationRemoved(PackageUserKey removedPackageUserKey, String notificationKey);
+ void onNotificationPosted(PackageUserKey postedPackageUserKey,
+ NotificationKeyData notificationKey, boolean shouldBeFilteredOut);
+ void onNotificationRemoved(PackageUserKey removedPackageUserKey,
+ NotificationKeyData notificationKey);
void onNotificationFullRefresh(List<StatusBarNotification> activeNotifications);
}
}