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

Commit 72737bc4 authored by Olivier St-Onge's avatar Olivier St-Onge Committed by Android (Google) Code Review
Browse files

Merge "Don't show the satellite icon when apm is enabled" into main

parents 1bac6b42 6723f347
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.pipeline.satellite.ui.viewmodel

import com.android.systemui.common.shared.model.Icon
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.statusbar.pipeline.airplane.data.repository.AirplaneModeRepository
import com.android.systemui.statusbar.pipeline.satellite.domain.interactor.DeviceBasedSatelliteInteractor
import com.android.systemui.statusbar.pipeline.satellite.ui.model.SatelliteIconModel
import javax.inject.Inject
@@ -40,6 +41,7 @@ class DeviceBasedSatelliteViewModel
constructor(
    interactor: DeviceBasedSatelliteInteractor,
    @Application scope: CoroutineScope,
    airplaneModeRepository: AirplaneModeRepository,
) {
    private val shouldShowIcon: StateFlow<Boolean> =
        interactor.areAllConnectionsOutOfService
@@ -47,7 +49,11 @@ constructor(
                if (!allOos) {
                    flowOf(false)
                } else {
                    interactor.isSatelliteAllowed
                    combine(interactor.isSatelliteAllowed, airplaneModeRepository.isAirplaneMode) {
                        isSatelliteAllowed,
                        isAirplaneMode ->
                        isSatelliteAllowed && !isAirplaneMode
                    }
                }
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)
+29 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.statusbar.pipeline.airplane.data.repository.FakeAirplaneModeRepository
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.FakeMobileIconsInteractor
import com.android.systemui.statusbar.pipeline.mobile.util.FakeMobileMappingsProxy
import com.android.systemui.statusbar.pipeline.satellite.data.prod.FakeDeviceBasedSatelliteRepository
@@ -36,6 +37,7 @@ import org.mockito.MockitoAnnotations
class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
    private lateinit var underTest: DeviceBasedSatelliteViewModel
    private lateinit var interactor: DeviceBasedSatelliteInteractor
    private lateinit var airplaneModeRepository: FakeAirplaneModeRepository

    private val repo = FakeDeviceBasedSatelliteRepository()
    private val mobileIconsInteractor = FakeMobileIconsInteractor(FakeMobileMappingsProxy(), mock())
@@ -45,6 +47,7 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
    @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)
        airplaneModeRepository = FakeAirplaneModeRepository()

        interactor =
            DeviceBasedSatelliteInteractor(
@@ -57,6 +60,7 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
            DeviceBasedSatelliteViewModel(
                interactor,
                testScope.backgroundScope,
                airplaneModeRepository,
            )
    }

@@ -72,6 +76,9 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
            val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
            i1.isInService.value = false

            // GIVEN apm is disabled
            airplaneModeRepository.setIsAirplaneMode(false)

            // THEN icon is null because we should not be showing it
            assertThat(latest).isNull()
        }
@@ -88,10 +95,32 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
            val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
            i1.isInService.value = true

            // GIVEN apm is disabled
            airplaneModeRepository.setIsAirplaneMode(false)

            // THEN icon is null because we have service
            assertThat(latest).isNull()
        }

    @Test
    fun icon_nullWhenShouldNotShow_apmIsEnabled() =
        testScope.runTest {
            val latest by collectLastValue(underTest.icon)

            // GIVEN satellite is allowed
            repo.isSatelliteAllowedForCurrentLocation.value = true

            // GIVEN all icons are OOS
            val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
            i1.isInService.value = false

            // GIVEN apm is enabled
            airplaneModeRepository.setIsAirplaneMode(true)

            // THEN icon is null because we should not be showing it
            assertThat(latest).isNull()
        }

    @Test
    fun icon_satelliteIsOff() =
        testScope.runTest {