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

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

Move DynamicPrivacyController from NSSL

Move DynamicPrivacyController from NotificationStackScrollLayout
into NotificationStackScrollLayoutController.

Bug: 147245740
Test: atest SystemUITests
Change-Id: Ifcf66d9eb11003b4d471b831dfbe05767abf72e1
parent ab0e8cdc
Loading
Loading
Loading
Loading
+9 −25
Original line number Diff line number Diff line
@@ -94,7 +94,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.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.FakeShadowView;
import com.android.systemui.statusbar.notification.ForegroundServiceDismissalFeatureController;
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
@@ -158,7 +157,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
     */
    private static final int DISTANCE_BETWEEN_ADJACENT_SECTIONS_PX = 1;
    private KeyguardBypassEnabledProvider mKeyguardBypassEnabledProvider;
    private final DynamicPrivacyController mDynamicPrivacyController;
    private final SysuiStatusBarStateController mStatusbarStateController;

    private ExpandHelper mExpandHelper;
@@ -532,7 +530,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            @Named(VIEW_CONTEXT) Context context,
            AttributeSet attrs,
            NotificationRoundnessManager notificationRoundnessManager,
            DynamicPrivacyController dynamicPrivacyController,
            SysuiStatusBarStateController statusbarStateController,
            NotificationSectionsManager notificationSectionsManager,
            ForegroundServiceSectionController fgsSectionController,
@@ -551,7 +548,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mSectionsManager.initialize(this, LayoutInflater.from(context));
        mSectionsManager.setOnClearSilentNotifsClickListener(v -> {
            // Leave the shade open if there will be other notifs left over to clear
            final boolean closeShade = !hasActiveClearableNotifications(ROWS_HIGH_PRIORITY);
            final boolean closeShade =
                    !mController.hasActiveClearableNotifications(ROWS_HIGH_PRIORITY);
            clearNotifications(ROWS_GENTLE, closeShade);
        });
        mSections = mSectionsManager.createSectionsForBuckets();
@@ -590,7 +588,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mClearAllEnabled = res.getBoolean(R.bool.config_enableNotificationsClearAll);
        mGroupMembershipManager = groupMembershipManager;
        mGroupExpansionManager = groupExpansionManager;
        mDynamicPrivacyController = dynamicPrivacyController;
        mStatusbarStateController = statusbarStateController;
        initializeForegroundServiceSection(fgsFeatureController);
        mUiEventLogger = uiEventLogger;
@@ -655,7 +652,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            return;
        }
        // TODO: move this logic to controller, which will invoke updateFooterView directly
        boolean showDismissView = mClearAllEnabled && hasActiveClearableNotifications(ROWS_ALL);
        boolean showDismissView = mClearAllEnabled &&
                mController.hasActiveClearableNotifications(ROWS_ALL);
        RemoteInputController remoteInputController = mRemoteInputManager.getController();
        boolean showFooterView = (showDismissView || mController.hasActiveNotifications())
                && mStatusBarState != StatusBarState.KEYGUARD
@@ -670,22 +668,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
     * Return whether there are any clearable notifications
     */
    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    public boolean hasActiveClearableNotifications(@SelectedRows int selection) {
        if (mDynamicPrivacyController.isInLockedDownShade()) {
            return false;
        }
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            if (!(child instanceof ExpandableNotificationRow)) {
                continue;
            }
            final ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            if (row.canViewBeDismissed() && matchesSelection(row, selection)) {
                return true;
            }
        }
        return false;
    boolean hasActiveClearableNotifications(@SelectedRows int selection) {
        return mController.hasActiveClearableNotifications(selection);
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
@@ -5803,7 +5787,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mSwipeHelper.resetExposedMenuView(animate, force);
    }

    private static boolean matchesSelection(
    static boolean matchesSelection(
            ExpandableNotificationRow row,
            @SelectedRows int selection) {
        switch (selection) {
@@ -6132,7 +6116,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                }

                return true;
            } else if (mDynamicPrivacyController.isInLockedDownShade()) {
            } else if (mController.isInLockedDownShade()) {
                mStatusbarStateController.setLeaveOpenOnKeyguardHide(true);
                mStatusBar.dismissKeyguardThenExecute(() -> false /* dismissAction */,
                        null /* cancelRunnable */, false /* afterKeyguardGone */);
@@ -6176,7 +6160,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            if (isDragDownAnywhereEnabled()) {
                return true;
            }
            if (mDynamicPrivacyController.isInLockedDownShade()) {
            if (mController.isInLockedDownShade()) {
                if (view == null) {
                    // Dragging down is allowed in general
                    return true;
+25 −3
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.ShadeViewRefactor;
import com.android.systemui.statusbar.notification.collection.NotifCollection;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -1066,9 +1067,26 @@ public class NotificationStackScrollLayoutController {
        mView.setPulsing(pulsing, animatePulse);
    }

    public boolean hasActiveClearableNotifications(
            @SelectedRows int selection) {
        return mView.hasActiveClearableNotifications(selection);
    /**
     * Return whether there are any clearable notifications
     */
    public boolean hasActiveClearableNotifications(@SelectedRows int selection) {
        if (mDynamicPrivacyController.isInLockedDownShade()) {
            return false;
        }
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            if (!(child instanceof ExpandableNotificationRow)) {
                continue;
            }
            final ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            if (row.canViewBeDismissed() &&
                    NotificationStackScrollLayout.matchesSelection(row, selection)) {
                return true;
            }
        }
        return false;
    }

    /**
@@ -1271,6 +1289,10 @@ public class NotificationStackScrollLayoutController {
        }
    }

    public boolean isInLockedDownShade() {
        return mDynamicPrivacyController.isInLockedDownShade();
    }

    private class NotificationListContainerImpl implements NotificationListContainer {

        @Override
+9 −7
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification.stack;
import static android.provider.Settings.Secure.NOTIFICATION_HISTORY_ENABLED;
import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;

import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

@@ -53,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.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.ForegroundServiceDismissalFeatureController;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
@@ -148,7 +149,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
                getContext(),
                null,
                mNotificationRoundnessManager,
                mock(DynamicPrivacyController.class),
                mStatusBarStateController,
                mNotificationSectionsManager,
                mock(ForegroundServiceSectionController.class),
@@ -286,6 +286,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        when(mStackScroller.getChildCount()).thenReturn(1);
        when(mStackScroller.getChildAt(anyInt())).thenReturn(row);
        when(mRemoteInputController.isRemoteInputActive()).thenReturn(true);
        when(mStackScrollLayoutController.hasActiveClearableNotifications(ROWS_ALL))
                .thenReturn(true);
        when(mStackScrollLayoutController.hasActiveNotifications()).thenReturn(true);

        FooterView view = mock(FooterView.class);
@@ -298,10 +300,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    public void testUpdateFooter_oneClearableNotification() {
        setBarStateForTest(StatusBarState.SHADE);

        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        when(row.canViewBeDismissed()).thenReturn(true);
        when(mStackScroller.getChildCount()).thenReturn(1);
        when(mStackScroller.getChildAt(anyInt())).thenReturn(row);
        when(mStackScrollLayoutController.hasActiveClearableNotifications(ROWS_ALL))
                .thenReturn(true);
        when(mStackScrollLayoutController.hasActiveNotifications()).thenReturn(true);

        FooterView view = mock(FooterView.class);
@@ -319,6 +319,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        when(mStackScroller.getChildCount()).thenReturn(1);
        when(mStackScroller.getChildAt(anyInt())).thenReturn(row);
        when(mStackScrollLayoutController.hasActiveNotifications()).thenReturn(true);
        when(mStackScrollLayoutController.hasActiveClearableNotifications(ROWS_ALL))
                .thenReturn(false);

        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
@@ -378,7 +380,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {

    @Test
    public void testClearNotifications_All() {
        mStackScroller.clearNotifications(NotificationStackScrollLayout.ROWS_ALL, true);
        mStackScroller.clearNotifications(ROWS_ALL, true);
        assertEquals(1, mUiEventLoggerFake.numLogs());
        assertEquals(NotificationStackScrollLayout.NotificationPanelEvent
                .DISMISS_ALL_NOTIFICATIONS_PANEL.getId(), mUiEventLoggerFake.eventId(0));