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

Commit 74670ea1 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Update a11y importance together with notifStats.

The a11y importance was being updated in NSSL#addContainerView and
removeContainerView, but it uses the value from notifStats, which in
turn is updated in onAfterRenderList (which gets called AFTER
addContainerView & co.). As such, the updateImportantForAccessibility
call was using a stale value for numActiveNotifications.

Similarly, there's no point in calling
updateFooter/updateShowEmptyShadeView in addContainerView &
removeContainerView since we're also (correctly) calling them in
setNotifStats.

Fix: 318021249
Test: enable talkback and verify that there's no unlabelled view when
there are no notifs on the lockscreen
Flag: NONE

Change-Id: I1d4c4f64ee3b32c8b80c347ec30b1d588e818116
parent 39255ff4
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
@@ -4917,30 +4917,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    public void removeContainerView(View v) {
        Assert.isMainThread();
        removeView(v);
        if (!FooterViewRefactor.isEnabled()) {
            // A notification was removed, and we're not currently showing the empty shade view.
            if (v instanceof ExpandableNotificationRow && !mController.isShowingEmptyShadeView()) {
                mController.updateShowEmptyShadeView();
                updateFooter();
                mController.updateImportantForAccessibility();
            }
        }

        updateSpeedBumpIndex();
    }

    public void addContainerView(View v) {
        Assert.isMainThread();
        addView(v);
        if (!FooterViewRefactor.isEnabled()) {
            // A notification was added, and we're currently showing the empty shade view.
            if (v instanceof ExpandableNotificationRow && mController.isShowingEmptyShadeView()) {
                mController.updateShowEmptyShadeView();
                updateFooter();
                mController.updateImportantForAccessibility();
            }
        }

        updateSpeedBumpIndex();
    }

@@ -4948,14 +4930,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        Assert.isMainThread();
        ensureRemovedFromTransientContainer(v);
        addView(v, index);
        // A notification was added, and we're currently showing the empty shade view.
        if (!FooterViewRefactor.isEnabled() && v instanceof ExpandableNotificationRow
                && mController.isShowingEmptyShadeView()) {
            mController.updateShowEmptyShadeView();
            updateFooter();
            mController.updateImportantForAccessibility();
        }

        updateSpeedBumpIndex();
    }

+1 −0
Original line number Diff line number Diff line
@@ -2137,6 +2137,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {

            if (!FooterViewRefactor.isEnabled()) {
                updateShowEmptyShadeView();
                updateImportantForAccessibility();
            }
        }
    }
+0 −12
Original line number Diff line number Diff line
@@ -860,9 +860,6 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
        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);
@@ -884,9 +881,6 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
                        /* hasClearableSilentNotifs = */ false)
        );

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

        // THEN: mNotificationStackScrollLayout should be important for A11y
        verify(mNotificationStackScrollLayout)
                .setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
@@ -908,9 +902,6 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
                        /* hasClearableSilentNotifs = */ false)
        );

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

        // THEN: mNotificationStackScrollLayout should be important for A11y
        verify(mNotificationStackScrollLayout)
                .setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
@@ -925,9 +916,6 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
        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);