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

Unverified Commit 17ba3bd3 authored by Kevin F. Haggerty's avatar Kevin F. Haggerty
Browse files

Revert "Revert "Do not show the notification footer until the user is set up.""

The original change officially shows up in the 2022-03 ASB, and the
android10-security-release branch contains a fix
(If6e99b5fbe3d2a9d9274223c35d23c30f5524229) to the issue that
caused us to revert earlier.

This reverts commit 338240ee.

Change-Id: I35c7854ad9632bae71366a2fe722bc568f0bfef6
parent 98e4f199
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -137,6 +137,8 @@ import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
import com.android.systemui.statusbar.policy.HeadsUpUtil;
import com.android.systemui.statusbar.policy.ScrollAdapter;
import com.android.systemui.tuner.TunerService;
@@ -284,6 +286,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
    private boolean mExpandedInThisMotion;
    private boolean mShouldShowShelfOnly;
    protected boolean mScrollingEnabled;
    private boolean mIsCurrentUserSetup;
    protected FooterView mFooterView;
    protected EmptyShadeView mEmptyShadeView;
    private boolean mDismissAllInProgress;
@@ -484,6 +487,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
    private final Rect mTmpRect = new Rect();
    private final NotificationEntryManager mEntryManager =
            Dependency.get(NotificationEntryManager.class);
    private final DeviceProvisionedController mDeviceProvisionedController =
            Dependency.get(DeviceProvisionedController.class);
    private final IStatusBarService mBarService = IStatusBarService.Stub.asInterface(
            ServiceManager.getService(Context.STATUS_BAR_SERVICE));
    @VisibleForTesting
@@ -605,6 +610,28 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        }, HIGH_PRIORITY, Settings.Secure.NOTIFICATION_DISMISS_RTL,
                LOCKSCREEN_TRANSLUCENT_NOTIFICATIONS_BG_ENABLED);

        mDeviceProvisionedController.addCallback(
                new DeviceProvisionedListener() {
                    @Override
                    public void onDeviceProvisionedChanged() {
                        updateCurrentUserIsSetup();
                    }

                    @Override
                    public void onUserSwitched() {
                        updateCurrentUserIsSetup();
                    }

                    @Override
                    public void onUserSetupChanged() {
                        updateCurrentUserIsSetup();
                    }

                    private void updateCurrentUserIsSetup() {
                        setCurrentUserSetup(mDeviceProvisionedController.isCurrentUserSetup());
                    }
                });

        mEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
            @Override
            public void onPostEntryUpdated(NotificationEntry entry) {
@@ -700,6 +727,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        boolean showDismissView = mClearAllEnabled && hasActiveClearableNotifications(ROWS_ALL);
        boolean showFooterView = (showDismissView ||
                mEntryManager.getNotificationData().getActiveNotifications().size() != 0)
                && mIsCurrentUserSetup  // see: b/193149550
                && mStatusBarState != StatusBarState.KEYGUARD
                && !mRemoteInputManager.getController().isRemoteInputActive();

@@ -5749,6 +5777,16 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        return MathUtils.smoothStep(0, totalDistance, dragDownAmount);
    }

    /**
     * Sets whether the current user is set up, which is required to show the footer (b/193149550)
     */
    public void setCurrentUserSetup(boolean isCurrentUserSetup) {
        if (mIsCurrentUserSetup != isCurrentUserSetup) {
            mIsCurrentUserSetup = isCurrentUserSetup;
            updateFooter();
        }
    }

    /**
     * A listener that is notified when the empty space below the notifications is clicked on
     */
+27 −0
Original line number Diff line number Diff line
@@ -299,6 +299,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Test
    public void testUpdateFooter_noNotifications() {
        setBarStateForTest(StatusBarState.SHADE);
        mStackScroller.setCurrentUserSetup(true);
        assertEquals(0, mNotificationData.getActiveNotifications().size());

        mStackScroller.updateFooter();
@@ -308,6 +309,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Test
    public void testUpdateFooter_remoteInput() {
        setBarStateForTest(StatusBarState.SHADE);
        mStackScroller.setCurrentUserSetup(true);

        ArrayList<NotificationEntry> entries = new ArrayList<>();
        entries.add(mock(NotificationEntry.class));
        when(mNotificationData.getActiveNotifications()).thenReturn(entries);
@@ -325,6 +328,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Test
    public void testUpdateFooter_oneClearableNotification() {
        setBarStateForTest(StatusBarState.SHADE);
        mStackScroller.setCurrentUserSetup(true);

        ArrayList<NotificationEntry> entries = new ArrayList<>();
        entries.add(mock(NotificationEntry.class));
        when(mNotificationData.getActiveNotifications()).thenReturn(entries);
@@ -338,9 +343,29 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        verify(mStackScroller).updateFooterView(true, true);
    }

    @Test
    public void testUpdateFooter_oneClearableNotification_beforeUserSetup() {
        setBarStateForTest(StatusBarState.SHADE);
        mStackScroller.setCurrentUserSetup(false);

        ArrayList<NotificationEntry> entries = new ArrayList<>();
        entries.add(mock(NotificationEntry.class));
        when(mNotificationData.getActiveNotifications()).thenReturn(entries);

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

        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(false, true);
    }

    @Test
    public void testUpdateFooter_oneNonClearableNotification() {
        setBarStateForTest(StatusBarState.SHADE);
        mStackScroller.setCurrentUserSetup(true);

        ArrayList<NotificationEntry> entries = new ArrayList<>();
        entries.add(mock(NotificationEntry.class));
        when(mEntryManager.getNotificationData().getActiveNotifications()).thenReturn(entries);
@@ -352,6 +377,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {

    @Test
    public void testUpdateFooter_atEnd() {
        mStackScroller.setCurrentUserSetup(true);

        // add footer
        mStackScroller.inflateFooterView();