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

Commit 9ba64847 authored by Dave Mankoff's avatar Dave Mankoff Committed by Steve Elliott
Browse files

Remove ForegroundServicesSectionController from NSSL

Remove ForegroundServicesSectionController from
NotificationStackScrollLayout constructor and put it in the
NotificationStackScrollLayoutController.

Bug: 147245740
Test: atest SystemUITests && manual
Change-Id: I2fe4a264376502d95754486feeeb133816d67e90
parent d06ec138
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -465,7 +465,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private NotificationPanelViewController mNotificationPanelController;

    private final NotificationSectionsManager mSectionsManager;
    private final ForegroundServiceSectionController mFgsSectionController;
    private ForegroundServiceDungeonView mFgsSectionView;
    private boolean mAnimateBottomOnLayout;
    private float mLastSentAppear;
@@ -527,19 +526,16 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            @Named(VIEW_CONTEXT) Context context,
            AttributeSet attrs,
            NotificationRoundnessManager notificationRoundnessManager,
            SysuiStatusBarStateController statusbarStateController,
            NotificationSectionsManager notificationSectionsManager,
            ForegroundServiceSectionController fgsSectionController,
            GroupMembershipManager groupMembershipManager,
            GroupExpansionManager groupExpansionManager
            GroupExpansionManager groupExpansionManager,
            SysuiStatusBarStateController statusbarStateController
    ) {
        super(context, attrs, 0, 0);
        Resources res = getResources();

        mRoundnessManager = notificationRoundnessManager;
        mFgsSectionController = fgsSectionController;

        mSectionsManager = notificationSectionsManager;

        mSectionsManager.initialize(this, LayoutInflater.from(context));
        mSectionsManager.setOnClearSilentNotifsClickListener(v -> {
            // Leave the shade open if there will be other notifs left over to clear
@@ -586,14 +582,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mStatusbarStateController = statusbarStateController;
    }

    void initializeForegroundServiceSection() {
    void initializeForegroundServiceSection(ForegroundServiceDungeonView fgsSectionView) {
        if (mFgsSectionView != null) {
            return;
        }

        LayoutInflater li = LayoutInflater.from(mContext);
        mFgsSectionView =
                (ForegroundServiceDungeonView) mFgsSectionController.createView(li);
        mFgsSectionView = fgsSectionView;

        addView(mFgsSectionView, -1);
    }

+12 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.service.notification.StatusBarNotification;
import android.util.Log;
import android.util.Pair;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -92,6 +93,7 @@ import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
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.NotificationGuts;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.row.NotificationSnooze;
@@ -147,6 +149,8 @@ public class NotificationStackScrollLayoutController {
    private final IStatusBarService mIStatusBarService;
    private final UiEventLogger mUiEventLogger;
    private final ForegroundServiceDismissalFeatureController mFgFeatureController;
    private final ForegroundServiceSectionController mFgServicesSectionController;
    private final LayoutInflater mLayoutInflater;
    private final KeyguardMediaController mKeyguardMediaController;
    private final SysuiStatusBarStateController mStatusBarStateController;
    private final KeyguardBypassController mKeyguardBypassController;
@@ -565,7 +569,9 @@ public class NotificationStackScrollLayoutController {
            NotificationEntryManager notificationEntryManager,
            IStatusBarService iStatusBarService,
            UiEventLogger uiEventLogger,
            ForegroundServiceDismissalFeatureController fgFeatureController) {
            ForegroundServiceDismissalFeatureController fgFeatureController,
            ForegroundServiceSectionController fgServicesSectionController,
            LayoutInflater layoutInflater) {
        mAllowLongPress = allowLongPress;
        mNotificationGutsManager = notificationGutsManager;
        mHeadsUpManager = headsUpManager;
@@ -608,6 +614,8 @@ public class NotificationStackScrollLayoutController {
        mIStatusBarService = iStatusBarService;
        mUiEventLogger = uiEventLogger;
        mFgFeatureController = fgFeatureController;
        mFgServicesSectionController = fgServicesSectionController;
        mLayoutInflater = layoutInflater;
    }

    public void attach(NotificationStackScrollLayout view) {
@@ -620,7 +628,9 @@ public class NotificationStackScrollLayoutController {
                NotificationPanelEvent.fromSelection(selection)));

        if (mFgFeatureController.isForegroundServiceDismissalEnabled()) {
            mView.initializeForegroundServiceSection();
            mView.initializeForegroundServiceSection(
                    (ForegroundServiceDungeonView) mFgServicesSectionController.createView(
                            mLayoutInflater));
        }

        mSwipeHelper = mNotificationSwipeHelperBuilder
+3 −4
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ import com.android.systemui.statusbar.NotificationShelfController;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.ForegroundServiceDismissalFeatureController;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager;
@@ -63,6 +62,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.FooterView;
import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.KeyguardBypassEnabledProvider;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;

@@ -147,11 +147,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
                getContext(),
                null,
                mNotificationRoundnessManager,
                mStatusBarStateController,
                mNotificationSectionsManager,
                mock(ForegroundServiceSectionController.class),
                mGroupMembershipManger,
                mGroupExpansionManager
                mGroupExpansionManager,
                mStatusBarStateController
        );
        mStackScrollerInternal.initView(getContext(), mKeyguardBypassEnabledProvider,
                mNotificationSwipeHelper);
+15 −11
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import static org.mockito.Mockito.when;
import android.content.res.Resources;
import android.metrics.LogMaker;
import android.testing.AndroidTestingRunner;
import android.view.LayoutInflater;

import androidx.test.filters.SmallTest;

@@ -59,6 +60,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
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.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController.NotificationPanelEvent;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
@@ -116,13 +118,10 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
    @Mock private NotificationEntryManager mEntryManager;
    @Mock private IStatusBarService mIStatusBarService;
    @Mock private UiEventLogger mUiEventLogger;
    @Mock private FeatureFlags mFeatureFlags;
    @Mock private NotifPipeline mNotifPipeline;
    @Mock private NotifCollection mNotifCollection;
    @Mock private NotificationEntryManager mEntryManager;
    @Mock private IStatusBarService mIStatusBarService;
    @Mock private UiEventLogger mUiEventLogger;
    @Mock private ForegroundServiceDismissalFeatureController mFgFeatureController;
    @Mock private ForegroundServiceSectionController mFgServicesSectionController;
    @Mock private ForegroundServiceDungeonView mForegroundServiceDungeonView;
    @Mock private LayoutInflater mLayoutInflater;

    @Captor
    private ArgumentCaptor<StatusBarStateController.StateListener> mStateListenerArgumentCaptor;
@@ -135,7 +134,8 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {

        when(mNotificationSwipeHelperBuilder.build()).thenReturn(mNotificationSwipeHelper);
        when(mFeatureFlags.isNewNotifPipelineRenderingEnabled()).thenReturn(false);

        when(mFgServicesSectionController.createView(mLayoutInflater))
                .thenReturn(mForegroundServiceDungeonView);
        mController = new NotificationStackScrollLayoutController(
                true,
                mNotificationGutsManager,
@@ -166,7 +166,9 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
                mEntryManager,
                mIStatusBarService,
                mUiEventLogger,
                mFgFeatureController
                mFgFeatureController,
                mFgServicesSectionController,
                mLayoutInflater
        );

        when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true);
@@ -344,17 +346,19 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase {
    }

    @Test
    public void testForegroundDismissaEnabled() {
    public void testForegroundDismissEnabled() {
        when(mFgFeatureController.isForegroundServiceDismissalEnabled()).thenReturn(true);
        mController.attach(mNotificationStackScrollLayout);
        verify(mNotificationStackScrollLayout).initializeForegroundServiceSection();
        verify(mNotificationStackScrollLayout).initializeForegroundServiceSection(
                mForegroundServiceDungeonView);
    }

    @Test
    public void testForegroundDismissaDisabled() {
        when(mFgFeatureController.isForegroundServiceDismissalEnabled()).thenReturn(false);
        mController.attach(mNotificationStackScrollLayout);
        verify(mNotificationStackScrollLayout, never()).initializeForegroundServiceSection();
        verify(mNotificationStackScrollLayout, never()).initializeForegroundServiceSection(
                any(ForegroundServiceDungeonView.class));
    }

    private LogMaker logMatcher(int category, int type) {