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

Commit 60f5ff4f authored by Steve Elliott's avatar Steve Elliott Committed by Android (Google) Code Review
Browse files

Merge "Remove ZenModeController from NSSL Constructor"

parents f89e45bc 787367b0
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -156,7 +156,6 @@ import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.HeadsUpUtil;
import com.android.systemui.statusbar.policy.ScrollAdapter;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.Assert;

@@ -366,7 +365,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private boolean mForceNoOverlappingRendering;
    private final ArrayList<Pair<ExpandableNotificationRow, Boolean>> mTmpList = new ArrayList<>();
    private FalsingManager mFalsingManager;
    private final ZenModeController mZenController;
    private boolean mAnimationRunning;
    private ViewTreeObserver.OnPreDrawListener mRunningAnimationUpdater
            = new ViewTreeObserver.OnPreDrawListener() {
@@ -587,14 +585,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            AttributeSet attrs,
            NotificationRoundnessManager notificationRoundnessManager,
            DynamicPrivacyController dynamicPrivacyController,
            SysuiStatusBarStateController statusBarStateController,
            SysuiStatusBarStateController statusbarStateController,
            HeadsUpManagerPhone headsUpManager,
            KeyguardBypassController keyguardBypassController,
            KeyguardMediaController keyguardMediaController,
            FalsingManager falsingManager,
            NotificationLockscreenUserManager notificationLockscreenUserManager,
            NotificationGutsManager notificationGutsManager,
            ZenModeController zenController,
            NotificationSectionsManager notificationSectionsManager,
            ForegroundServiceSectionController fgsSectionController,
            ForegroundServiceDismissalFeatureController fgsFeatureController,
@@ -615,7 +612,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mHeadsUpManager.setAnimationStateHandler(this::setHeadsUpGoingAwayAnimationsAllowed);
        mKeyguardBypassController = keyguardBypassController;
        mFalsingManager = falsingManager;
        mZenController = zenController;
        mFgsSectionController = fgsSectionController;

        mSectionsManager = notificationSectionsManager;
@@ -693,7 +689,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        }

        mDynamicPrivacyController = dynamicPrivacyController;
        mStatusbarStateController = statusBarStateController;
        mStatusbarStateController = statusbarStateController;
        initializeForegroundServiceSection(fgsFeatureController);
        mUiEventLogger = uiEventLogger;
        mColorExtractor.addOnColorsChangedListener(mOnColorsChangedListener);
@@ -4996,11 +4992,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    void updateEmptyShadeView(boolean visible) {
    void updateEmptyShadeView(boolean visible, boolean notifVisibleInShade) {
        mEmptyShadeView.setVisible(visible, mIsExpanded && mAnimationsEnabled);

        int oldTextRes = mEmptyShadeView.getTextResource();
        int newTextRes = mZenController.areNotificationsHiddenInShade()
        int newTextRes = notifVisibleInShade
                ? R.string.dnd_suppressing_shade_text : R.string.empty_shade_text;
        if (oldTextRes != newTextRes) {
            mEmptyShadeView.setText(newTextRes);
+6 −2
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.tuner.TunerService;

import java.util.function.BiConsumer;
@@ -68,6 +69,7 @@ public class NotificationStackScrollLayoutController {
    private final TunerService mTunerService;
    private final DynamicPrivacyController mDynamicPrivacyController;
    private final ConfigurationController mConfigurationController;
    private final ZenModeController mZenModeController;
    private final NotificationListContainerImpl mNotificationListContainer =
            new NotificationListContainerImpl();
    private NotificationStackScrollLayout mView;
@@ -130,7 +132,8 @@ public class NotificationStackScrollLayoutController {
            NotificationRoundnessManager notificationRoundnessManager,
            TunerService tunerService,
            DynamicPrivacyController dynamicPrivacyController,
            ConfigurationController configurationController) {
            ConfigurationController configurationController,
            ZenModeController zenModeController) {
        mAllowLongPress = allowLongPress;
        mNotificationGutsManager = notificationGutsManager;
        mHeadsUpManager = headsUpManager;
@@ -138,6 +141,7 @@ public class NotificationStackScrollLayoutController {
        mTunerService = tunerService;
        mDynamicPrivacyController = dynamicPrivacyController;
        mConfigurationController = configurationController;
        mZenModeController = zenModeController;
    }

    public void attach(NotificationStackScrollLayout view) {
@@ -484,7 +488,7 @@ public class NotificationStackScrollLayoutController {
    }

    public void updateEmptyShadeView(boolean visible) {
        mView.updateEmptyShadeView(visible);
        mView.updateEmptyShadeView(visible, mZenModeController.areNotificationsHiddenInShade());
    }

    public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
+11 −13
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.util.leak.LeakDetector;

@@ -136,12 +137,12 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Mock private MetricsLogger mMetricsLogger;
    @Mock private NotificationRoundnessManager mNotificationRoundnessManager;
    @Mock private KeyguardBypassController mKeyguardBypassController;
    @Mock private KeyguardMediaController mKeyguardMediaController;
    @Mock private ZenModeController mZenModeController;
    @Mock private NotificationSectionsManager mNotificationSectionsManager;
    @Mock private NotificationSection mNotificationSection;
    @Mock private NotificationLockscreenUserManager mLockscreenUserManager;
    @Mock private FeatureFlags mFeatureFlags;
    @Mock private KeyguardMediaController mKeyguardMediaController;
    @Mock private SysuiStatusBarStateController mStatusBarStateController;
    private UserChangedListener mUserChangedListener;
    private NotificationEntryManager mEntryManager;
    private int mOriginalInterruptionModelSetting;
@@ -211,17 +212,18 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        // which refer to members of NotificationStackScrollLayout. The spy
        // holds a copy of the CUT's instances of these KeyguardBypassController, so they still
        // refer to the CUT's member variables, not the spy's member variables.
        mStackScrollerInternal = new NotificationStackScrollLayout(getContext(), null,
        mStackScrollerInternal = new NotificationStackScrollLayout(
                getContext(),
                null,
                mNotificationRoundnessManager,
                mock(DynamicPrivacyController.class),
                mock(SysuiStatusBarStateController.class),
                mStatusBarStateController,
                mHeadsUpManager,
                mKeyguardBypassController,
                mKeyguardMediaController,
                new FalsingManagerFake(),
                mLockscreenUserManager,
                mock(NotificationGutsManager.class),
                mZenModeController,
                mNotificationSectionsManager,
                mock(ForegroundServiceSectionController.class),
                mock(ForegroundServiceDismissalFeatureController.class),
@@ -269,9 +271,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Test
    public void updateEmptyView_dndSuppressing() {
        when(mEmptyShadeView.willBeGone()).thenReturn(true);
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(true);

        mStackScroller.updateEmptyShadeView(true);
        mStackScroller.updateEmptyShadeView(true, true);

        verify(mEmptyShadeView).setText(R.string.dnd_suppressing_shade_text);
    }
@@ -280,9 +281,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    public void updateEmptyView_dndNotSuppressing() {
        mStackScroller.setEmptyShadeView(mEmptyShadeView);
        when(mEmptyShadeView.willBeGone()).thenReturn(true);
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);

        mStackScroller.updateEmptyShadeView(true);
        mStackScroller.updateEmptyShadeView(true, false);

        verify(mEmptyShadeView).setText(R.string.empty_shade_text);
    }
@@ -291,12 +291,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    public void updateEmptyView_noNotificationsToDndSuppressing() {
        mStackScroller.setEmptyShadeView(mEmptyShadeView);
        when(mEmptyShadeView.willBeGone()).thenReturn(true);
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
        mStackScroller.updateEmptyShadeView(true);
        mStackScroller.updateEmptyShadeView(true, false);
        verify(mEmptyShadeView).setText(R.string.empty_shade_text);

        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(true);
        mStackScroller.updateEmptyShadeView(true);
        mStackScroller.updateEmptyShadeView(true, true);
        verify(mEmptyShadeView).setText(R.string.dnd_suppressing_shade_text);
    }

+39 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.statusbar.notification.stack;

import static com.android.systemui.statusbar.notification.ViewGroupFadeHelper.reset;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -26,11 +28,11 @@ import android.testing.AndroidTestingRunner;
import androidx.test.filters.SmallTest;

import com.android.systemui.SysuiTestCase;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.tuner.TunerService;

import org.junit.Before;
@@ -55,13 +57,13 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
    @Mock
    private TunerService mTunerService;
    @Mock
    private AmbientState mAmbientState;
    @Mock
    private DynamicPrivacyController mDynamicPrivacyController;
    @Mock
    private ConfigurationController mConfigurationController;
    @Mock
    private NotificationStackScrollLayout mNotificationStackScrollLayout;
    @Mock
    private ZenModeController mZenModeController;

    NotificationStackScrollLayoutController mController;

@@ -76,7 +78,8 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
                mNotificationRoundnessManager,
                mTunerService,
                mDynamicPrivacyController,
                mConfigurationController
                mConfigurationController,
                mZenModeController
        );

        when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true);
@@ -112,4 +115,36 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
        mController.mConfigurationListener.onDensityOrFontScaleChanged();
        verify(mNotificationStackScrollLayout).reinflateViews();
    }

    @Test
    public void testUpdateEmptyShadeView_notificationsVisible() {
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(true);
        mController.attach(mNotificationStackScrollLayout);

        mController.updateEmptyShadeView(true /* visible */);
        verify(mNotificationStackScrollLayout).updateEmptyShadeView(
                true /* visible */,
                true /* notifVisibleInShade */);
        reset(mNotificationStackScrollLayout);
        mController.updateEmptyShadeView(false /* visible */);
        verify(mNotificationStackScrollLayout).updateEmptyShadeView(
                false /* visible */,
                true /* notifVisibleInShade */);
    }

    @Test
    public void testUpdateEmptyShadeView_notificationsHidden() {
        when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
        mController.attach(mNotificationStackScrollLayout);

        mController.updateEmptyShadeView(true /* visible */);
        verify(mNotificationStackScrollLayout).updateEmptyShadeView(
                true /* visible */,
                false /* notifVisibleInShade */);
        reset(mNotificationStackScrollLayout);
        mController.updateEmptyShadeView(false /* visible */);
        verify(mNotificationStackScrollLayout).updateEmptyShadeView(
                false /* visible */,
                false /* notifVisibleInShade */);
    }
}