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

Commit cd2db86e authored by András Kurucz's avatar András Kurucz
Browse files

[flexiglass] Update NSSL stack height on child height changes

NSSL has two concepts of stack heights: one for the available space,
and one for the required (intrinsic) stack height.
When a Notification changes its height (e.g. it swaps public to private layout bc the device gets unlocked), we are updating the intrinsic stack height, which is the correct thing to do.
However there are scenarios, when we need to update the available space as well, because the NSSL lays out its  content like "wrap height" instead of "match parent". This update was missing.

Fixes: 382626688
Test: atest NotificationStackScrollLayoutTest
Test: unlock the device with face auth (without bypass) -> notifications update their content correctly
Flag: com.android.systemui.scene_container
Change-Id: I0094a9b34c0ab025df63203a3a38444dba27605c
parent fdddba25
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2630,6 +2630,7 @@ public class NotificationStackScrollLayout
    private void updateContentHeight() {
        if (SceneContainerFlag.isEnabled()) {
            updateIntrinsicStackHeight();
            updateStackEndHeightAndStackHeight(mAmbientState.getExpansionFraction());
            return;
        }

+31 −0
Original line number Diff line number Diff line
@@ -1274,6 +1274,37 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackViewPortHeight);
    }

    @Test
    @EnableSceneContainer
    public void testChildHeightUpdated_whenMaxDisplayedNotificationsSet_updatesStackHeight() {
        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        int maxNotifs = 1; // any non-zero limit
        float stackTop = 100;
        float stackCutoff = 1100;
        mStackScroller.setStackTop(stackTop);
        mStackScroller.setStackCutoff(stackCutoff);

        // Given we have a limit on max displayed notifications
        int stackHeightBeforeUpdate = 100;
        when(mStackSizeCalculator.computeHeight(eq(mStackScroller), eq(maxNotifs), anyFloat()))
                .thenReturn((float) stackHeightBeforeUpdate);
        mStackScroller.setMaxDisplayedNotifications(maxNotifs);

        // And the stack heights are set
        assertThat(mStackScroller.getIntrinsicStackHeight()).isEqualTo(stackHeightBeforeUpdate);
        assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackHeightBeforeUpdate);

        // When a child changes its height
        int stackHeightAfterUpdate = 300;
        when(mStackSizeCalculator.computeHeight(eq(mStackScroller), eq(maxNotifs), anyFloat()))
                .thenReturn((float) stackHeightAfterUpdate);
        mStackScroller.onChildHeightChanged(row, /* needsAnimation = */ false);

        // Then the stack heights are updated
        assertThat(mStackScroller.getIntrinsicStackHeight()).isEqualTo(stackHeightAfterUpdate);
        assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackHeightAfterUpdate);
    }

    @Test
    @DisableSceneContainer
    public void testSetMaxDisplayedNotifications_notifiesListeners() {