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

Commit 0baea084 authored by Evan Laird's avatar Evan Laird
Browse files

[Sat] Data layer listener for non terrestrial networks

Adds a new field on MobileConnectionRepository, `isNonTerrestrial`,
which is a direct mapping from
ServiceState.isUsingNonterrestrialNetwork.

This is a property of the service state itself, and will be used to
determine the view state of the icon in future CLs. Due to there being
no listeners of this value yet, the code will not be called until the
(flagged) CL lands.

Test: MobileConnectionRepositoryTest
Test: DemoMobileConnectionRepository
Test: DemoMobileConnectionParameterizedTest
Bug: 311417356
Flag: NONE
Change-Id: If80e6f66f460f95bb225dccd88eae062cec621b6
parent bcd04bd9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ interface MobileConnectionRepository {
     */
    val isInService: StateFlow<Boolean>

    /** Reflects [android.telephony.ServiceState.isUsingNonTerrestrialNetwork] */
    val isNonTerrestrial: StateFlow<Boolean>

    /** True if [android.telephony.SignalStrength] told us that this connection is using GSM */
    val isGsm: StateFlow<Boolean>

+13 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullM
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_EMERGENCY
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_IS_GSM
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_IS_IN_SERVICE
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_IS_NTN
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_OPERATOR
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_PRIMARY_LEVEL
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_ROAMING
@@ -109,6 +110,17 @@ class DemoMobileConnectionRepository(
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), _isInService.value)

    private val _isNonTerrestrial = MutableStateFlow(false)
    override val isNonTerrestrial =
        _isNonTerrestrial
            .logDiffsForTable(
                tableLogBuffer,
                columnPrefix = "",
                columnName = COL_IS_NTN,
                _isNonTerrestrial.value
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), _isNonTerrestrial.value)

    private val _isGsm = MutableStateFlow(false)
    override val isGsm =
        _isGsm
@@ -227,6 +239,7 @@ class DemoMobileConnectionRepository(
            (event.activity ?: TelephonyManager.DATA_ACTIVITY_NONE).toMobileDataActivityModel()
        _carrierNetworkChangeActive.value = event.carrierNetworkChange
        _resolvedNetworkType.value = resolvedNetworkType
        _isNonTerrestrial.value = event.ntn

        isAllowedDuringAirplaneMode.value = false
        hasPrioritizedNetworkCapabilities.value = event.slice
+2 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ constructor(
        val roaming = getString("roam") == "show"
        val name = getString("networkname") ?: "demo mode"
        val slice = getString("slice").toBoolean()
        val ntn = getString("ntn").toBoolean()

        return Mobile(
            level = level,
@@ -89,6 +90,7 @@ constructor(
            roaming = roaming,
            name = name,
            slice = slice,
            ntn = ntn,
        )
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ sealed interface FakeNetworkEventModel {
        val roaming: Boolean,
        val name: String,
        val slice: Boolean = false,
        val ntn: Boolean = false,
    ) : FakeNetworkEventModel

    data class MobileDisabled(
+1 −0
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ class CarrierMergedConnectionRepository(
    override val isEmergencyOnly = MutableStateFlow(false).asStateFlow()
    override val operatorAlphaShort = MutableStateFlow(null).asStateFlow()
    override val isInService = MutableStateFlow(true).asStateFlow()
    override val isNonTerrestrial = MutableStateFlow(false).asStateFlow()
    override val isGsm = MutableStateFlow(false).asStateFlow()
    override val carrierNetworkChangeActive = MutableStateFlow(false).asStateFlow()

Loading