Update scrim controller to bubble state when bubbles are expanded

There's one issue with this where if you expand status bar
on top of the expanded bubble there is no scrim in between.

Test: manual / existing tests pass (atest SystemUITests)
Bug: 111236845
Change-Id: I2510758366999131ac7ffbb7505026727f4e40e1
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index ddb8166..e868f96 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -60,6 +60,7 @@
     private Context mContext;
     private BubbleDismissListener mDismissListener;
     private BubbleStateChangeListener mStateChangeListener;
+    private BubbleExpandListener mExpandListener;
 
     private Map<String, BubbleView> mBubbles = new HashMap<>();
     private BubbleStackView mStackView;
@@ -96,6 +97,19 @@
         void onHasBubblesChanged(boolean hasBubbles);
     }
 
+    /**
+     * Listener to find out about stack expansion / collapse events.
+     */
+    public interface BubbleExpandListener {
+        /**
+         * Called when the expansion state of the bubble stack changes.
+         *
+         * @param isExpanding whether it's expanding or collapsing
+         * @param amount fraction of how expanded or collapsed it is, 1 being fully, 0 at the start
+         */
+        void onBubbleExpandChanged(boolean isExpanding, float amount);
+    }
+
     public BubbleController(Context context) {
         mContext = context;
         WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
@@ -119,6 +133,16 @@
     }
 
     /**
+     * Set a listener to be notified of bubble expand events.
+     */
+    public void setExpandListener(BubbleExpandListener listener) {
+        mExpandListener = listener;
+        if (mStackView != null) {
+            mStackView.setExpandListener(mExpandListener);
+        }
+    }
+
+    /**
      * Whether or not there are bubbles present, regardless of them being visible on the
      * screen (e.g. if on AOD).
      */
@@ -185,6 +209,9 @@
                 int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
                 sbv.addView(mStackView, bubblePosition,
                         new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
+                if (mExpandListener != null) {
+                    mStackView.setExpandListener(mExpandListener);
+                }
             }
             mStackView.addBubble(bubble);
             if (setPosition) {