Merge "SysUI: Uprank current media notification" into lmp-dev
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 8b50a36..df005a8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -518,6 +518,11 @@
         }
     }
 
+    @Override
+    public String getCurrentMediaNotificationKey() {
+        return null;
+    }
+
     /**
      * Takes the necessary steps to prepare the status bar for starting an activity, then starts it.
      * @param action A dismiss action that is called if it's safe to start the activity.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
index 7fefa64..7e37336 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
@@ -98,6 +98,16 @@
 
         @Override
         public int compare(Entry a, Entry b) {
+            String mediaNotification = mEnvironment.getCurrentMediaNotificationKey();
+
+            // Upsort current media notification.
+            boolean aMedia = a.key.equals(mediaNotification);
+            boolean bMedia = b.key.equals(mediaNotification);
+            if (aMedia != bMedia) {
+                return aMedia ? -1 : 1;
+            }
+
+            // RankingMap as received from NoMan.
             if (mRankingMap != null) {
                 mRankingMap.getRanking(a.key, mRankingA);
                 mRankingMap.getRanking(b.key, mRankingB);
@@ -291,5 +301,6 @@
         public boolean shouldHideSensitiveContents(int userId);
         public boolean isDeviceProvisioned();
         public boolean isNotificationForCurrentProfiles(StatusBarNotification sbn);
+        public String getCurrentMediaNotificationKey();
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 95232d4..620d3ec 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -2053,6 +2053,11 @@
         return mNotificationPanel.isQsExpanded();
     }
 
+    @Override  // NotificationData.Environment
+    public String getCurrentMediaNotificationKey() {
+        return mMediaNotificationKey;
+    }
+
     /**
      * All changes to the status bar and notifications funnel through here and are batched.
      */