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

Commit 4213999c authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Fix qsFullScreen when QS only partially expanded

The qsFullScreen flow & value were true as soon as the QS panel started
to expand, although the JavaDoc said it should only be true when
qsExpansion is 1 (which is true in the flexiglass implementation).

This fixes that by only setting it to true when QS are fully expanded.
This means it's being updated more often, so I also added a check in
NSSL to ignore duplicate updates.

Bug: 330143161
Flag: ACONFIG com.android.systemui.notifications_footer_view_refactor STAGING
Test: QuickSettingsControllerImplTest
Test: NotificationListViewModelTest
Change-Id: I1a2b4244df5199243d954dd1cd4e950e01d7d7a6
parent 58ec8376
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -976,14 +976,21 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
        }
    }

    void updateQsState() {
        boolean qsFullScreen = getExpanded() && !mSplitShadeEnabled;
    private void setQsFullScreen(boolean qsFullScreen) {
        mShadeRepository.setLegacyQsFullscreen(qsFullScreen);
        mNotificationStackScrollLayoutController.setQsFullScreen(qsFullScreen);
        if (!SceneContainerFlag.isEnabled()) {
            mNotificationStackScrollLayoutController.setScrollingEnabled(
                    mBarState != KEYGUARD && (!qsFullScreen || mExpansionFromOverscroll));
        }
    }

    void updateQsState() {
        if (!FooterViewRefactor.isEnabled()) {
            // Update full screen state; note that this will be true if the QS panel is only
            // partially expanded, and that is fixed with the footer view refactor.
            setQsFullScreen(/* qsFullScreen = */ getExpanded() && !mSplitShadeEnabled);
        }

        if (mQsStateUpdateListener != null) {
            mQsStateUpdateListener.onQsStateUpdated(getExpanded(), mStackScrollerOverscrolling);
@@ -1046,6 +1053,11 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum

        // Update the light bar
        mLightBarController.setQsExpanded(mFullyExpanded);

        if (FooterViewRefactor.isEnabled()) {
            // Update full screen state
            setQsFullScreen(/* qsFullScreen = */ mFullyExpanded && !mSplitShadeEnabled);
        }
    }

    float getLockscreenShadeDragProgress() {
+5 −0
Original line number Diff line number Diff line
@@ -4736,6 +4736,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    public void setQsFullScreen(boolean qsFullScreen) {
        if (FooterViewRefactor.isEnabled()) {
            if (qsFullScreen == mQsFullScreen) {
                return;  // no change
            }
        }
        mQsFullScreen = qsFullScreen;
        updateAlgorithmLayoutMinHeight();
        updateScrollability();
+33 −4
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.platform.test.annotations.EnableFlags;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.MotionEvent;
@@ -43,6 +44,7 @@ import androidx.test.filters.SmallTest;

import com.android.systemui.plugins.qs.QS;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.notification.footer.shared.FooterViewRefactor;

import org.junit.Test;
import org.junit.runner.RunWith;
@@ -285,16 +287,43 @@ public class QuickSettingsControllerImplTest extends QuickSettingsControllerImpl
    }

    @Test
    public void updateQsState_fullscreenTrue() {
    @EnableFlags(FooterViewRefactor.FLAG_NAME)
    public void updateExpansion_partiallyExpanded_fullscreenFalse() {
        // WHEN QS are only partially expanded
        mQsController.setExpanded(true);
        mQsController.updateQsState();
        when(mQs.getDesiredHeight()).thenReturn(123);
        mQsController.setQs(mQs);
        mQsController.onHeightChanged();
        mQsController.setExpansionHeight(100);

        // THEN they are not full screen
        mQsController.updateExpansion();
        assertThat(mShadeRepository.getLegacyQsFullscreen().getValue()).isFalse();
    }

    @Test
    public void updateExpansion_fullyExpanded_fullscreenTrue() {
        // WHEN QS are fully expanded
        mQsController.setExpanded(true);
        when(mQs.getDesiredHeight()).thenReturn(123);
        mQsController.setQs(mQs);
        mQsController.onHeightChanged();
        mQsController.setExpansionHeight(123);

        // THEN they are full screen
        assertThat(mShadeRepository.getLegacyQsFullscreen().getValue()).isTrue();
    }

    @Test
    public void updateQsState_fullscreenFalse() {
    public void updateExpansion_notExpanded_fullscreenFalse() {
        // WHEN QS are not expanded
        mQsController.setExpanded(false);
        mQsController.updateQsState();
        when(mQs.getDesiredHeight()).thenReturn(123);
        mQsController.setQs(mQs);
        mQsController.onHeightChanged();
        mQsController.setExpansionHeight(0);

        // THEN they are not full screen
        assertThat(mShadeRepository.getLegacyQsFullscreen().getValue()).isFalse();
    }