Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c6a354f authored by Dave Mankoff's avatar Dave Mankoff Committed by Steve Elliott
Browse files

Remove NotifBlockingHelperManager from rom NSSL

Remove NotificationBlockingHelperManager from
NotificationStackScrollLayout and move it to the
NotificationStackScrollLayoutController.

Bug: 147245740
Test: atest SystemUITests
Change-Id: I4957fa9183690a68a730fdbf00f61e4e0068e34d
parent d0443e34
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -106,7 +106,6 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
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 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                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);
+9 −1
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ import com.android.systemui.statusbar.notification.row.ActivatableNotificationVi
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 @@ public class NotificationStackScrollLayoutController {
    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 @@ public class NotificationStackScrollLayoutController {
            ForegroundServiceSectionController fgServicesSectionController,
            LayoutInflater layoutInflater,
            NotificationRemoteInputManager remoteInputManager,
            VisualStabilityManager visualStabilityManager) {
            VisualStabilityManager visualStabilityManager,
            NotificationBlockingHelperManager notificationBlockingHelperManager) {
        mAllowLongPress = allowLongPress;
        mNotificationGutsManager = notificationGutsManager;
        mHeadsUpManager = headsUpManager;
@@ -622,6 +625,7 @@ public class NotificationStackScrollLayoutController {
        mLayoutInflater = layoutInflater;
        mRemoteInputManager = remoteInputManager;
        mVisualStabilityManager = visualStabilityManager;
        mNotificationBlockingHelperManager = notificationBlockingHelperManager;
    }

    public void attach(NotificationStackScrollLayout view) {
@@ -682,6 +686,10 @@ public class NotificationStackScrollLayoutController {
        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) -> {
+16 −5
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import com.android.systemui.statusbar.phone.ShadeController;
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.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;

import java.util.function.BiConsumer;

/**
 * Tests for {@link NotificationStackScrollLayout}.
 */
@@ -216,12 +219,20 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Test
    @UiThreadTest
    public void testSetExpandedHeight_blockingHelperManagerReceivedCallbacks() {
        mStackScroller.setExpandedHeight(0f);
        verify(mBlockingHelperManager).setNotificationShadeExpanded(0f);
        reset(mBlockingHelperManager);
        final float expectedHeight[] = {0f};
        final float expectedAppear[] = {0f};

        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]);

        mStackScroller.setExpandedHeight(100f);
        verify(mBlockingHelperManager).setNotificationShadeExpanded(100f);
        expectedHeight[0] = 100f;
        expectedAppear[0] = 0f;
        mStackScroller.setExpandedHeight(expectedHeight[0]);
    }

    @Test
+26 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
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.legacy.VisualStabi
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.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.function.BiConsumer;

/**
 * Tests for {@link NotificationStackScrollLayoutController}.
 */
@@ -127,6 +131,7 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
    @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 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
                mFgServicesSectionController,
                mLayoutInflater,
                mRemoteInputManager,
                mVisualStabilityManager
                mVisualStabilityManager,
                mNotificationBlockingHelperManager
        );

        when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true);
@@ -369,6 +375,25 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
                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));
    }