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

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

Merge "Do not show satellite icon when mobile connection is emergency only" into main

parents 695a31e4 c07a99c7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@ interface MobileIconInteractor {
    /** True if we consider this connection to be in service, i.e. can make calls */
    val isInService: StateFlow<Boolean>

    /** True if this connection is emergency only */
    val isEmergencyOnly: StateFlow<Boolean>

    /** Observable for the data enabled state of this connection */
    val isDataEnabled: StateFlow<Boolean>

@@ -306,6 +309,8 @@ class MobileIconInteractorImpl(

    override val isInService = connectionRepository.isInService

    override val isEmergencyOnly: StateFlow<Boolean> = connectionRepository.isEmergencyOnly

    override val isAllowedDuringAirplaneMode = connectionRepository.isAllowedDuringAirplaneMode

    /** Whether or not to show the error state of [SignalDrawable] */
+10 −3
Original line number Diff line number Diff line
@@ -72,9 +72,16 @@ constructor(
    /** When all connections are considered OOS, satellite connectivity is potentially valid */
    val areAllConnectionsOutOfService =
        if (Flags.oemEnabledSatelliteFlag()) {
                iconsInteractor.icons.aggregateOver(selector = { intr -> intr.isInService }) {
                    isInServiceList ->
                    isInServiceList.all { !it }
                iconsInteractor.icons.aggregateOver(
                    selector = { intr ->
                        combine(intr.isInService, intr.isEmergencyOnly) {
                            isInService,
                            isEmergencyOnly ->
                            !isInService && !isEmergencyOnly
                        }
                    }
                ) { isOosAndIsNotEmergencyOnly ->
                    isOosAndIsNotEmergencyOnly.all { it }
                }
            } else {
                flowOf(false)
+3 −0
Original line number Diff line number Diff line
@@ -239,7 +239,9 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {

            // WHEN all of the connections are OOS
            i1.isInService.value = false
            i1.isEmergencyOnly.value = false
            i2.isInService.value = false
            i2.isEmergencyOnly.value = false

            // THEN the value is propagated to this interactor
            assertThat(latest).isTrue()
@@ -256,6 +258,7 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {

            // WHEN all of the connections are OOS
            i1.isInService.value = false
            i1.isEmergencyOnly.value = false

            // THEN the value is propagated to this interactor
            assertThat(latest).isTrue()
+34 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
            // GIVEN all icons are OOS
            val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
            i1.isInService.value = false
            i1.isEmergencyOnly.value = false

            // GIVEN apm is disabled
            airplaneModeRepository.setIsAirplaneMode(false)
@@ -99,6 +100,7 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
            // GIVEN all icons are not OOS
            val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
            i1.isInService.value = true
            i1.isEmergencyOnly.value = false

            // GIVEN apm is disabled
            airplaneModeRepository.setIsAirplaneMode(false)
@@ -107,6 +109,35 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
            assertThat(latest).isNull()
        }

    @Test
    fun icon_nullWhenShouldNotShow_isEmergencyOnly() =
        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
            i1.isEmergencyOnly.value = false

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

            // Wait for delay to be completed
            advanceTimeBy(10.seconds)

            // THEN icon is set because we don't have service
            assertThat(latest).isInstanceOf(Icon::class.java)

            // GIVEN the connection is emergency only
            i1.isEmergencyOnly.value = true

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

    @Test
    fun icon_nullWhenShouldNotShow_apmIsEnabled() =
        testScope.runTest {
@@ -118,6 +149,7 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
            // GIVEN all icons are OOS
            val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
            i1.isInService.value = false
            i1.isEmergencyOnly.value = false

            // GIVEN apm is enabled
            airplaneModeRepository.setIsAirplaneMode(true)
@@ -138,6 +170,7 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
            // GIVEN all icons are OOS
            val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
            i1.isInService.value = false
            i1.isEmergencyOnly.value = false

            // GIVEN apm is disabled
            airplaneModeRepository.setIsAirplaneMode(false)
@@ -161,6 +194,7 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
            // GIVEN all icons are OOS
            val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
            i1.isInService.value = false
            i1.isEmergencyOnly.value = false

            // GIVEN apm is disabled
            airplaneModeRepository.setIsAirplaneMode(false)
+2 −0
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ class FakeMobileIconInteractor(

    override val isInService = MutableStateFlow(true)

    override val isEmergencyOnly = MutableStateFlow(true)

    override val isNonTerrestrial = MutableStateFlow(false)

    private val _isDataEnabled = MutableStateFlow(true)