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

Commit b6accbf1 authored by Olivier St-Onge's avatar Olivier St-Onge
Browse files

Only show the stacked mobile icon when all individual mobile icons are visible

Test: manually with demo mode
Test: MobileIconsViewModelTest
Fixes: 402628097
Flag: com.android.settingslib.flags.new_status_bar_icons
Flag: com.android.systemui.status_bar_root_modernization

Change-Id: I6df2e609dc531909813c1e3b2b2246ebfeb94c45
parent 1760acbd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ class MobileIconInteractorKairosAdapterTest : MobileIconInteractorTestBase() {
                    }
                    .asIncremental()
                    .applyLatestSpecForKey(),
            isStackable = interactor.isStackable.toState(),
            isStackable = interactor.isStackable.toState(false),
            activeDataConnectionHasDataEnabled =
                interactor.activeDataConnectionHasDataEnabled.toState(),
            activeDataIconInteractor =
+40 −3
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ class MobileIconsViewModelTest : SysuiTestCase() {
    private val interactor = FakeMobileIconsInteractor(FakeMobileMappingsProxy(), mock())

    private lateinit var airplaneModeInteractor: AirplaneModeInteractor
    @Mock private lateinit var constants: ConnectivityConstants
    @Mock private lateinit var logger: MobileViewLogger
    @Mock private lateinit var verboseLogger: VerboseMobileViewLogger

@@ -84,7 +83,10 @@ class MobileIconsViewModelTest : SysuiTestCase() {
                verboseLogger,
                interactor,
                airplaneModeInteractor,
                constants,
                object : ConnectivityConstants {
                    override val hasDataCapabilities = true
                    override val shouldShowActivityConfig = false
                },
                testScope.backgroundScope,
            )

@@ -349,7 +351,42 @@ class MobileIconsViewModelTest : SysuiTestCase() {
            // WHEN sub2 becomes last and sub2 has a network type icon
            interactor.filteredSubscriptions.value = listOf(SUB_1, SUB_2)

            // THEN the flow updates
            assertThat(latest).isTrue()
            job.cancel()
        }

    @Test
    fun isStackable_apmEnabled_false() =
        testScope.runTest {
            var latest: Boolean? = null
            val job = underTest.isStackable.onEach { latest = it }.launchIn(this)

            // Set the interactor to true to test APM
            interactor.isStackable.value = true

            // Enable APM
            airplaneModeInteractor.setIsAirplaneMode(true)

            interactor.filteredSubscriptions.value = listOf(SUB_1, SUB_2)

            assertThat(latest).isFalse()
            job.cancel()
        }

    @Test
    fun isStackable_apmDisabled_true() =
        testScope.runTest {
            var latest: Boolean? = null
            val job = underTest.isStackable.onEach { latest = it }.launchIn(this)

            // Set the interactor to true to test APM
            interactor.isStackable.value = true

            // Disable APM
            airplaneModeInteractor.setIsAirplaneMode(false)

            interactor.filteredSubscriptions.value = listOf(SUB_1, SUB_2)

            assertThat(latest).isTrue()

            job.cancel()
+1 −2
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ interface MobileIconsInteractor {
    val icons: StateFlow<List<MobileIconInteractor>>

    /** Whether the mobile icons can be stacked vertically. */
    val isStackable: StateFlow<Boolean>
    val isStackable: Flow<Boolean>

    /**
     * Observable for the subscriptionId of the current mobile data connection. Null if we don't
@@ -323,7 +323,6 @@ constructor(
            } else {
                flowOf(false)
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)

    /**
     * Copied from the old pipeline. We maintain a 2s period of time where we will keep the
+13 −1
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
@@ -99,7 +101,17 @@ constructor(
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)

    val isStackable: StateFlow<Boolean> = interactor.isStackable
    /** Whether all of [mobileSubViewModels] are visible or not. */
    private val iconsAreAllVisible =
        mobileSubViewModels.flatMapLatest { viewModels ->
            combine(viewModels.map { it.isVisible }) { isVisibleArray -> isVisibleArray.all { it } }
        }

    val isStackable: StateFlow<Boolean> =
        combine(iconsAreAllVisible, interactor.isStackable) { isVisible, isStackable ->
                isVisible && isStackable
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)

    init {
        scope.launch { subscriptionIdsFlow.collect { invalidateCaches(it) } }
+1 −2
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel
import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow

class FakeMobileIconsInteractor(
    mobileMappings: MobileMappingsProxy,
@@ -76,7 +75,7 @@ class FakeMobileIconsInteractor(

    override val icons: MutableStateFlow<List<MobileIconInteractor>> = MutableStateFlow(emptyList())

    override val isStackable: StateFlow<Boolean> = MutableStateFlow(false)
    override val isStackable: MutableStateFlow<Boolean> = MutableStateFlow(false)

    private val _defaultMobileIconMapping = MutableStateFlow(TEST_MAPPING)
    override val defaultMobileIconMapping = _defaultMobileIconMapping