Match players based on notification key

One player per package caused problems with RCN because all RCN
notifications come from the same package. We can't remove this step
completely because then every time the user restarts media it would
create a new set of controls.

Instead, match based on the notification key. This will allow one player
per notification tag + ID, so RCN can use different IDs per device to have
multiple players visible at the same time.
This is consistent with how NotificationManager identifies notifications
to update.

Fixes: 153236983
Test: manual - used cast test apk and cast to multiple devices on a
different phone, observed multiple players

Change-Id: Iaa98b4180725209982beb079d96bfedaa9742b58
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
index 62efd8c..8492fef 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
@@ -82,6 +82,7 @@
     protected ComponentName mRecvComponent;
     private MediaDevice mDevice;
     private boolean mIsRegistered = false;
+    private String mKey;
 
     private final int[] mActionIds;
 
@@ -203,14 +204,15 @@
      * @param bgColor
      * @param contentIntent
      * @param appNameString
-     * @param device
+     * @param key
      */
     public void setMediaSession(MediaSession.Token token, Icon icon, int iconColor,
-            int bgColor, PendingIntent contentIntent, String appNameString) {
+            int bgColor, PendingIntent contentIntent, String appNameString, String key) {
         mToken = token;
         mForegroundColor = iconColor;
         mBackgroundColor = bgColor;
         mController = new MediaController(mContext, mToken);
+        mKey = key;
 
         MediaMetadata mediaMetadata = mController.getMetadata();
 
@@ -326,6 +328,14 @@
     }
 
     /**
+     * Return the original notification's key
+     * @return The notification key
+     */
+    public String getKey()  {
+        return mKey;
+    }
+
+    /**
      * Check whether this player has an attached media session.
      * @return whether there is a controller with a current media session.
      */