Add permission prompt to bubble expanded header view

Test: manual / coming soon
Bug: 111236845
Change-Id: Ie616d2215c495e8b30ba7fa8ebb1abdc8e5ebd7e
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index 9a9a52f..f36dca7 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -70,7 +70,7 @@
  * The controller manages addition, removal, and visible state of bubbles on screen.
  */
 @Singleton
-public class BubbleController {
+public class BubbleController implements BubbleExpandedViewContainer.OnBubbleBlockedListener {
     private static final int MAX_BUBBLES = 5; // TODO: actually enforce this
 
     private static final String TAG = "BubbleController";
@@ -266,6 +266,7 @@
                 if (mExpandListener != null) {
                     mStackView.setExpandListener(mExpandListener);
                 }
+                mStackView.setOnBlockedListener(this);
             }
             // It's new
             BubbleView bubble = (BubbleView) mInflater.inflate(
@@ -302,6 +303,19 @@
         updateVisibility();
     }
 
+    @Override
+    public void onBubbleBlocked(NotificationEntry entry) {
+        Object[] bubbles = mBubbles.values().toArray();
+        for (int i = 0; i < bubbles.length; i++) {
+            NotificationEntry e = ((BubbleView) bubbles[i]).getEntry();
+            boolean samePackage = entry.notification.getPackageName().equals(
+                    e.notification.getPackageName());
+            if (samePackage) {
+                removeBubble(entry.key);
+            }
+        }
+    }
+
     @SuppressWarnings("FieldCanBeLocal")
     private final NotificationEntryListener mEntryListener = new NotificationEntryListener() {
         @Override