summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java23
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java1
3 files changed, 25 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java
index 0988e347945c..d668665f062c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java
@@ -163,7 +163,7 @@ public class NotificationMediaManager implements Dumpable {
if (!isPlaybackActive(state.getState())) {
clearCurrentMediaNotification();
}
- dispatchUpdateMediaMetaData(true /* changed */, true /* allowAnimation */);
+ findAndUpdateMediaNotifications();
}
}
@@ -200,6 +200,16 @@ public class NotificationMediaManager implements Dumpable {
mEntryManager = notificationEntryManager;
notificationEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
@Override
+ public void onPendingEntryAdded(NotificationEntry entry) {
+ findAndUpdateMediaNotifications();
+ }
+
+ @Override
+ public void onPreEntryUpdated(NotificationEntry entry) {
+ findAndUpdateMediaNotifications();
+ }
+
+ @Override
public void onEntryRemoved(
NotificationEntry entry,
NotificationVisibility visibility,
@@ -272,16 +282,12 @@ public class NotificationMediaManager implements Dumpable {
boolean metaDataChanged = false;
synchronized (mEntryManager.getNotificationData()) {
- ArrayList<NotificationEntry> activeNotifications =
- mEntryManager.getNotificationData().getActiveNotifications();
- final int N = activeNotifications.size();
+ Set<NotificationEntry> allNotifications = mEntryManager.getAllNotifs();
// Promote the media notification with a controller in 'playing' state, if any.
NotificationEntry mediaNotification = null;
MediaController controller = null;
- for (int i = 0; i < N; i++) {
- final NotificationEntry entry = activeNotifications.get(i);
-
+ for (NotificationEntry entry : allNotifications) {
if (entry.isMediaNotification()) {
final MediaSession.Token token =
entry.getSbn().getNotification().extras.getParcelable(
@@ -319,8 +325,7 @@ public class NotificationMediaManager implements Dumpable {
// now to see if we have one like this
final String pkg = aController.getPackageName();
- for (int i = 0; i < N; i++) {
- final NotificationEntry entry = activeNotifications.get(i);
+ for (NotificationEntry entry : allNotifications) {
if (entry.getSbn().getPackageName().equals(pkg)) {
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: found controller matching "
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 bde097a89f6b..404087d9b973 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -53,8 +53,10 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -561,6 +563,15 @@ public class NotificationEntryManager implements
}
/**
+ * @return all notification we're currently aware of (both pending and visible notifications)
+ */
+ public Set<NotificationEntry> getAllNotifs() {
+ Set<NotificationEntry> allNotifs = new HashSet<>(mPendingNotifications.values());
+ allNotifs.addAll(mNotificationData.getActiveNotifications());
+ return allNotifs;
+ }
+
+ /**
* Gets the pending or visible notification entry with the given key. Returns null if
* notification doesn't exist.
*/
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 971843ec0187..afc147a75c56 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -1528,7 +1528,6 @@ public class StatusBar extends SystemUI implements DemoMode,
.start();
}
}
- mMediaManager.findAndUpdateMediaNotifications();
}
private void updateReportRejectedTouchVisibility() {