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

Commit eca08dfc authored by Yining Liu's avatar Yining Liu Committed by Automerger Merge Worker
Browse files

Merge "Fix Unlabeled NotificationStackScrollLayout on lock screen" into...

Merge "Fix Unlabeled NotificationStackScrollLayout on lock screen" into udc-dev am: 931a039b am: de044aa7 am: 44771a0e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23455968



Change-Id: I0fc7b57a0aabf35270afbc27ecc3e76484056200
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 84afb143 44771a0e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4681,6 +4681,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        if (v instanceof ExpandableNotificationRow && !mController.isShowingEmptyShadeView()) {
            mController.updateShowEmptyShadeView();
            updateFooter();
            mController.updateImportantForAccessibility();
        }

        updateSpeedBumpIndex();
@@ -4692,6 +4693,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        if (v instanceof ExpandableNotificationRow && mController.isShowingEmptyShadeView()) {
            mController.updateShowEmptyShadeView();
            updateFooter();
            mController.updateImportantForAccessibility();
        }

        updateSpeedBumpIndex();
@@ -4704,6 +4706,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        if (v instanceof ExpandableNotificationRow && mController.isShowingEmptyShadeView()) {
            mController.updateShowEmptyShadeView();
            updateFooter();
            mController.updateImportantForAccessibility();
        }

        updateSpeedBumpIndex();
+18 −0
Original line number Diff line number Diff line
@@ -332,6 +332,7 @@ public class NotificationStackScrollLayoutController {
                    mView.updateSensitiveness(mStatusBarStateController.goingToFullShade(),
                            mLockscreenUserManager.isAnyProfilePublicMode());
                    mView.onStatePostChange(mStatusBarStateController.fromShadeLocked());
                    updateImportantForAccessibility();
                }
            };

@@ -1215,6 +1216,7 @@ public class NotificationStackScrollLayoutController {
        if (mView.getVisibility() == View.VISIBLE) {
            // Synchronize EmptyShadeView visibility with the parent container.
            updateShowEmptyShadeView();
            updateImportantForAccessibility();
        }
    }

@@ -1241,6 +1243,22 @@ public class NotificationStackScrollLayoutController {
        Trace.endSection();
    }

    /**
     * Update the importantForAccessibility of NotificationStackScrollLayout.
     * <p>
     * We want the NSSL to be unimportant for accessibility when there's no
     * notifications in it while the device is on lock screen, to avoid unlablel NSSL view.
     * Otherwise, we want it to be important for accessibility to enable accessibility
     * auto-scrolling in NSSL.
     */
    public void updateImportantForAccessibility() {
        if (getVisibleNotificationCount() == 0 && mView.onKeyguard()) {
            mView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        } else {
            mView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
        }
    }

    /**
     * @return true if {@link StatusBarStateController} is in transition to the KEYGUARD
     * and false otherwise.
+79 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.when;
import android.content.res.Resources;
import android.metrics.LogMaker;
import android.testing.AndroidTestingRunner;
import android.view.View;

import androidx.test.filters.SmallTest;

@@ -434,6 +435,84 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
        verify(mNotificationStackScrollLayout).setStatusBarState(KEYGUARD);
    }

    @Test
    public void updateImportantForAccessibility_noChild_onKeyGuard_notImportantForA11y() {
        // GIVEN: Controller is attached, active notifications is empty,
        // and mNotificationStackScrollLayout.onKeyguard() is true
        initController(/* viewIsAttached= */ true);
        when(mNotificationStackScrollLayout.onKeyguard()).thenReturn(true);
        mController.getNotifStackController().setNotifStats(NotifStats.getEmpty());

        // WHEN: call updateImportantForAccessibility
        mController.updateImportantForAccessibility();

        // THEN: mNotificationStackScrollLayout should not be important for A11y
        verify(mNotificationStackScrollLayout)
                .setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
    }

    @Test
    public void updateImportantForAccessibility_hasChild_onKeyGuard_importantForA11y() {
        // GIVEN: Controller is attached, active notifications is not empty,
        // and mNotificationStackScrollLayout.onKeyguard() is true
        initController(/* viewIsAttached= */ true);
        when(mNotificationStackScrollLayout.onKeyguard()).thenReturn(true);
        mController.getNotifStackController().setNotifStats(
                new NotifStats(
                        /* numActiveNotifs = */ 1,
                        /* hasNonClearableAlertingNotifs = */ false,
                        /* hasClearableAlertingNotifs = */ false,
                        /* hasNonClearableSilentNotifs = */ false,
                        /* hasClearableSilentNotifs = */ false)
        );

        // WHEN: call updateImportantForAccessibility
        mController.updateImportantForAccessibility();

        // THEN: mNotificationStackScrollLayout should be important for A11y
        verify(mNotificationStackScrollLayout)
                .setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    @Test
    public void updateImportantForAccessibility_hasChild_notOnKeyGuard_importantForA11y() {
        // GIVEN: Controller is attached, active notifications is not empty,
        // and mNotificationStackScrollLayout.onKeyguard() is false
        initController(/* viewIsAttached= */ true);
        when(mNotificationStackScrollLayout.onKeyguard()).thenReturn(false);
        mController.getNotifStackController().setNotifStats(
                new NotifStats(
                        /* numActiveNotifs = */ 1,
                        /* hasNonClearableAlertingNotifs = */ false,
                        /* hasClearableAlertingNotifs = */ false,
                        /* hasNonClearableSilentNotifs = */ false,
                        /* hasClearableSilentNotifs = */ false)
        );

        // WHEN: call updateImportantForAccessibility
        mController.updateImportantForAccessibility();

        // THEN: mNotificationStackScrollLayout should be important for A11y
        verify(mNotificationStackScrollLayout)
                .setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    @Test
    public void updateImportantForAccessibility_noChild_notOnKeyGuard_importantForA11y() {
        // GIVEN: Controller is attached, active notifications is empty,
        // and mNotificationStackScrollLayout.onKeyguard() is false
        initController(/* viewIsAttached= */ true);
        when(mNotificationStackScrollLayout.onKeyguard()).thenReturn(false);
        mController.getNotifStackController().setNotifStats(NotifStats.getEmpty());

        // WHEN: call updateImportantForAccessibility
        mController.updateImportantForAccessibility();

        // THEN: mNotificationStackScrollLayout should be important for A11y
        verify(mNotificationStackScrollLayout)
                .setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    private LogMaker logMatcher(int category, int type) {
        return argThat(new LogMatcher(category, type));
    }