Remove NotifBlockingHelperManager from rom NSSL

Remove NotificationBlockingHelperManager from
NotificationStackScrollLayout and move it to the
NotificationStackScrollLayoutController.

Bug: 147245740
Test: atest SystemUITests
Change-Id: I4957fa9183690a68a730fdbf00f61e4e0068e34d
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 64a6114..3092b76 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -106,7 +106,6 @@
 import com.android.systemui.statusbar.notification.row.ExpandableView;
 import com.android.systemui.statusbar.notification.row.FooterView;
 import com.android.systemui.statusbar.notification.row.ForegroundServiceDungeonView;
-import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
 import com.android.systemui.statusbar.notification.row.StackScrollerDecorView;
 import com.android.systemui.statusbar.phone.HeadsUpAppearanceController;
 import com.android.systemui.statusbar.phone.HeadsUpTouchHelper;
@@ -551,13 +550,6 @@
                 res.getBoolean(R.bool.config_drawNotificationBackground);
         setOutlineProvider(mOutlineProvider);
 
-        // Blocking helper manager wants to know the expanded state, update as well.
-        NotificationBlockingHelperManager blockingHelperManager =
-                Dependency.get(NotificationBlockingHelperManager.class);
-        addOnExpandedHeightChangedListener((height, unused) -> {
-            blockingHelperManager.setNotificationShadeExpanded(height);
-        });
-
         boolean willDraw = mShouldDrawNotificationBackground || DEBUG;
         setWillNotDraw(!willDraw);
         mBackgroundPaint.setAntiAlias(true);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
index 4da4497..bfbae4e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
@@ -96,6 +96,7 @@
 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
 import com.android.systemui.statusbar.notification.row.ExpandableView;
 import com.android.systemui.statusbar.notification.row.ForegroundServiceDungeonView;
+import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
 import com.android.systemui.statusbar.notification.row.NotificationGuts;
 import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
 import com.android.systemui.statusbar.notification.row.NotificationSnooze;
@@ -154,6 +155,7 @@
     private final LayoutInflater mLayoutInflater;
     private final NotificationRemoteInputManager mRemoteInputManager;
     private final VisualStabilityManager mVisualStabilityManager;
+    private final NotificationBlockingHelperManager mNotificationBlockingHelperManager;
     private final KeyguardMediaController mKeyguardMediaController;
     private final SysuiStatusBarStateController mStatusBarStateController;
     private final KeyguardBypassController mKeyguardBypassController;
@@ -577,7 +579,8 @@
             ForegroundServiceSectionController fgServicesSectionController,
             LayoutInflater layoutInflater,
             NotificationRemoteInputManager remoteInputManager,
-            VisualStabilityManager visualStabilityManager) {
+            VisualStabilityManager visualStabilityManager,
+            NotificationBlockingHelperManager notificationBlockingHelperManager) {
         mAllowLongPress = allowLongPress;
         mNotificationGutsManager = notificationGutsManager;
         mHeadsUpManager = headsUpManager;
@@ -622,6 +625,7 @@
         mLayoutInflater = layoutInflater;
         mRemoteInputManager = remoteInputManager;
         mVisualStabilityManager = visualStabilityManager;
+        mNotificationBlockingHelperManager = notificationBlockingHelperManager;
     }
 
     public void attach(NotificationStackScrollLayout view) {
@@ -682,6 +686,10 @@
         mView.addOnExpandedHeightChangedListener(mNotificationRoundnessManager::setExpanded);
 
         mVisualStabilityManager.setVisibilityLocationProvider(this::isInVisibleLocation);
+        // Blocking helper manager wants to know the expanded state, update as well.
+        mView.addOnExpandedHeightChangedListener((height, unused) ->
+                mNotificationBlockingHelperManager.setNotificationShadeExpanded(height)
+        );
 
         mTunerService.addTunable(
                 (key, newValue) -> {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
index 1ed9a5c..a2a6514 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
@@ -65,6 +65,7 @@
 import com.android.systemui.statusbar.phone.StatusBar;
 
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -74,6 +75,8 @@
 import org.mockito.junit.MockitoJUnit;
 import org.mockito.junit.MockitoRule;
 
+import java.util.function.BiConsumer;
+
 /**
  * Tests for {@link NotificationStackScrollLayout}.
  */
@@ -216,12 +219,20 @@
     @Test
     @UiThreadTest
     public void testSetExpandedHeight_blockingHelperManagerReceivedCallbacks() {
-        mStackScroller.setExpandedHeight(0f);
-        verify(mBlockingHelperManager).setNotificationShadeExpanded(0f);
-        reset(mBlockingHelperManager);
+        final float expectedHeight[] = {0f};
+        final float expectedAppear[] = {0f};
 
-        mStackScroller.setExpandedHeight(100f);
-        verify(mBlockingHelperManager).setNotificationShadeExpanded(100f);
+        mStackScroller.addOnExpandedHeightChangedListener((height, appear) -> {
+            Assert.assertEquals(expectedHeight[0], height, 0);
+            Assert.assertEquals(expectedAppear[0], appear, .1);
+        });
+        expectedHeight[0] = 1f;
+        expectedAppear[0] = 1f;
+        mStackScroller.setExpandedHeight(expectedHeight[0]);
+
+        expectedHeight[0] = 100f;
+        expectedAppear[0] = 0f;
+        mStackScroller.setExpandedHeight(expectedHeight[0]);
     }
 
     @Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java
index 9e9fa88..969805f6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java
@@ -27,6 +27,7 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -64,6 +65,7 @@
 import com.android.systemui.statusbar.notification.collection.render.SectionHeaderController;
 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
 import com.android.systemui.statusbar.notification.row.ForegroundServiceDungeonView;
+import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
 import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
 import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController.NotificationPanelEvent;
 import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
@@ -84,6 +86,8 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
+import java.util.function.BiConsumer;
+
 /**
  * Tests for {@link NotificationStackScrollLayoutController}.
  */
@@ -127,6 +131,7 @@
     @Mock private NotificationRemoteInputManager mRemoteInputManager;
     @Mock private RemoteInputController mRemoteInputController;
     @Mock private VisualStabilityManager mVisualStabilityManager;
+    @Mock private NotificationBlockingHelperManager mNotificationBlockingHelperManager;
 
     @Captor
     private ArgumentCaptor<StatusBarStateController.StateListener> mStateListenerArgumentCaptor;
@@ -176,7 +181,8 @@
                 mFgServicesSectionController,
                 mLayoutInflater,
                 mRemoteInputManager,
-                mVisualStabilityManager
+                mVisualStabilityManager,
+                mNotificationBlockingHelperManager
         );
 
         when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true);
@@ -369,6 +375,25 @@
                 any(ForegroundServiceDungeonView.class));
     }
 
+    @Test
+    public void testSetExpandedHeight_blockingHelperManagerReceivedCallbacks() {
+
+        ArgumentCaptor<BiConsumer<Float, Float>>
+                onExpandedHeightChangeListenerCaptor = ArgumentCaptor.forClass(
+                BiConsumer.class);
+
+        mController.attach(mNotificationStackScrollLayout);
+
+        verify(mNotificationStackScrollLayout, times(2)).addOnExpandedHeightChangedListener(
+                onExpandedHeightChangeListenerCaptor.capture());
+
+        for (BiConsumer<Float, Float> listener :
+                onExpandedHeightChangeListenerCaptor.getAllValues()) {
+            listener.accept(1f, 2f);
+        }
+        verify(mNotificationBlockingHelperManager).setNotificationShadeExpanded(1f);
+    }
+
     private LogMaker logMatcher(int category, int type) {
         return argThat(new LogMatcher(category, type));
     }