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

Commit bc77cc1c authored by Justin Weir's avatar Justin Weir
Browse files

Add NPVC.mIsPanelExpanded replacement

This will allow us to remove the incorrectly named method
ShadeExpansionStateManager.addFullExpansionListener, which notifies
listeners of partial expansion of the shade or QS or if the shade is not
expanded at all but is awaiting input transfer.

Bug: 300243163
Test: added test
Test: manual
Change-Id: Iae775deab6ab57df7cc48bd4df97b40d83cedaa8
parent b87dbb2a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2604,6 +2604,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        if (mPanelExpanded != isExpanded) {
            mPanelExpanded = isExpanded;
            updateSystemUiStateFlags();
            mShadeRepository.setLegacyExpandedOrAwaitingInputTransfer(mPanelExpanded);
            mShadeExpansionStateManager.onShadeExpansionFullyChanged(isExpanded);
            if (!isExpanded) {
                mQsController.closeQsCustomizer();
+27 −0
Original line number Diff line number Diff line
@@ -74,6 +74,21 @@ interface ShadeRepository {
     */
    @Deprecated("Use ShadeInteractor instead") val legacyQsTracking: StateFlow<Boolean>

    /**
     * NotificationPanelViewController.mPanelExpanded as a flow. This value is true whenever the
     * expansion fraction is greater than zero or NPVC is about to accept an input transfer from the
     * status bar, home screen, or trackpad.
     */
    @Deprecated("Use ShadeInteractor instead")
    val legacyExpandedOrAwaitingInputTransfer: StateFlow<Boolean>

    /**
     * Sets whether the expansion fraction is greater than zero or NPVC is about to accept an input
     * transfer from the status bar, home screen, or trackpad.
     */
    @Deprecated("Use ShadeInteractor instead")
    fun setLegacyExpandedOrAwaitingInputTransfer(legacyExpandedOrAwaitingInputTransfer: Boolean)

    /** Sets whether the user is moving Quick Settings with a pointer */
    fun setLegacyQsTracking(legacyQsTracking: Boolean)

@@ -155,6 +170,18 @@ constructor(shadeExpansionStateManager: ShadeExpansionStateManager) : ShadeRepos
    @Deprecated("Use ShadeInteractor instead")
    override val legacyQsTracking: StateFlow<Boolean> = _legacyQsTracking.asStateFlow()

    private val _legacyExpandedOrAwaitingInputTransfer = MutableStateFlow(false)
    @Deprecated("Use ShadeInteractor instead")
    override val legacyExpandedOrAwaitingInputTransfer: StateFlow<Boolean> =
        _legacyExpandedOrAwaitingInputTransfer.asStateFlow()

    @Deprecated("Use ShadeInteractor instead")
    override fun setLegacyExpandedOrAwaitingInputTransfer(
        legacyExpandedOrAwaitingInputTransfer: Boolean
    ) {
        _legacyExpandedOrAwaitingInputTransfer.value = legacyExpandedOrAwaitingInputTransfer
    }

    @Deprecated("Should only be called by NPVC and tests")
    override fun setLegacyQsTracking(legacyQsTracking: Boolean) {
        _legacyQsTracking.value = legacyQsTracking
+20 −4
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.isActive
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.isActive
@@ -78,7 +77,7 @@ constructor(
     * Whether split shade, the combined notifications and quick settings shade used for large
     * screens, is enabled.
     */
    val splitShadeEnabled: Flow<Boolean> =
    val isSplitShadeEnabled: Flow<Boolean> =
        sharedNotificationContainerInteractor.configurationBasedDimensions
            .map { dimens -> dimens.useSplitShade }
            .distinctUntilChanged()
@@ -93,7 +92,7 @@ constructor(
                    keyguardRepository.statusBarState,
                    repository.legacyShadeExpansion,
                    repository.qsExpansion,
                    splitShadeEnabled
                    isSplitShadeEnabled
                ) {
                    lockscreenShadeExpansion,
                    statusBarState,
@@ -131,12 +130,28 @@ constructor(
            .stateIn(scope, SharingStarted.Eagerly, 0f)

    /** Whether either the shade or QS is expanding from a fully collapsed state. */
    val isAnyExpanding =
    val isAnyExpanding: Flow<Boolean> =
        anyExpansion
            .pairwise(1f)
            .map { (prev, curr) -> curr > 0f && curr < 1f && prev < 1f }
            .distinctUntilChanged()

    /**
     * Whether either the shade or QS is partially or fully expanded, i.e. not fully collapsed. At
     * this time, this is not simply a matter of checking if either value in shadeExpansion and
     * qsExpansion is greater than zero, because it includes the legacy concept of whether input
     * transfer is about to occur. If the scene container flag is enabled, it just checks whether
     * either expansion value is positive.
     *
     * TODO(b/300258424) remove all but the first sentence of this comment
     */
    val isAnyExpanded: Flow<Boolean> =
        if (sceneContainerFlags.isEnabled()) {
            anyExpansion.map { it > 0f }.distinctUntilChanged()
        } else {
            repository.legacyExpandedOrAwaitingInputTransfer
        }

    /**
     * Whether the user is expanding or collapsing the shade with user input. This will be true even
     * if the user's input gesture has ended but a transition they initiated is animating.
@@ -147,6 +162,7 @@ constructor(
        } else {
            userInteractingFlow(repository.legacyShadeTracking, repository.legacyShadeExpansion)
        }

    /**
     * Whether the user is expanding or collapsing quick settings with user input. This will be true
     * even if the user's input gesture has ended but a transition they initiated is still
+9 −0
Original line number Diff line number Diff line
@@ -168,6 +168,15 @@ class ShadeRepositoryImplTest : SysuiTestCase() {
            assertThat(underTest.legacyQsTracking.value).isEqualTo(true)
        }

    @Test
    fun updateLegacyExpandedOrAwaitingInputTransfer() =
        testScope.runTest {
            assertThat(underTest.legacyExpandedOrAwaitingInputTransfer.value).isEqualTo(false)

            underTest.setLegacyExpandedOrAwaitingInputTransfer(true)
            assertThat(underTest.legacyExpandedOrAwaitingInputTransfer.value).isEqualTo(true)
        }

    @Test
    fun updateUdfpsTransitionToFullShadeProgress() =
        testScope.runTest {
+11 −0
Original line number Diff line number Diff line
@@ -47,6 +47,17 @@ class FakeShadeRepository : ShadeRepository {
    private val _legacyQsTracking = MutableStateFlow(false)
    @Deprecated("Use ShadeInteractor instead") override val legacyQsTracking = _legacyQsTracking

    private val _legacyExpandedOrAwaitingInputTransfer = MutableStateFlow(false)
    @Deprecated("Use ShadeInteractor instead")
    override val legacyExpandedOrAwaitingInputTransfer = _legacyExpandedOrAwaitingInputTransfer

    @Deprecated("Use ShadeInteractor instead")
    override fun setLegacyExpandedOrAwaitingInputTransfer(
        legacyExpandedOrAwaitingInputTransfer: Boolean
    ) {
        _legacyExpandedOrAwaitingInputTransfer.value = legacyExpandedOrAwaitingInputTransfer
    }

    @Deprecated("Should only be called by NPVC and tests")
    override fun setLegacyQsTracking(legacyQsTracking: Boolean) {
        _legacyQsTracking.value = legacyQsTracking