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

Commit 0aae61ce authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Status Bar] Allow carrier merged to be displayed even in airplane mode.

Fixes: 291993542
Test: manual: be in airplane mode, then trigger carrier merged via demo
mode (adb shell am broadcast -a com.android.systemui.demo -e command
network -e wifi carriermerged -e level 4 -e slot 4) -> verify triangle
with W+ displays
Test: atest FullMobileConnectionRepositoryTest MobileIconInteractorTest
MobileIconViewModelTest

Change-Id: Ie9ca23724891ae6563557bc2c82980723b2e5015
parent 872d54fb
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -118,6 +118,11 @@ interface MobileConnectionRepository {
    /** The service provider name for this network connection, or the default name */
    val networkName: StateFlow<NetworkNameModel>

    /**
     * True if this type of connection is allowed while airplane mode is on, and false otherwise.
     */
    val isAllowedDuringAirplaneMode: StateFlow<Boolean>

    companion object {
        /** The default number of levels to use for [numberOfLevels]. */
        const val DEFAULT_NUM_LEVELS = 4
+5 −0
Original line number Diff line number Diff line
@@ -186,6 +186,8 @@ class DemoMobileConnectionRepository(

    override val networkName = MutableStateFlow(NetworkNameModel.IntentDerived("demo network"))

    override val isAllowedDuringAirplaneMode = MutableStateFlow(false)

    /**
     * Process a new demo mobile event. Note that [resolvedNetworkType] must be passed in separately
     * from the event, due to the requirement to reverse the mobile mappings lookup in the top-level
@@ -217,6 +219,8 @@ class DemoMobileConnectionRepository(
            (event.activity ?: TelephonyManager.DATA_ACTIVITY_NONE).toMobileDataActivityModel()
        _carrierNetworkChangeActive.value = event.carrierNetworkChange
        _resolvedNetworkType.value = resolvedNetworkType

        isAllowedDuringAirplaneMode.value = false
    }

    fun processCarrierMergedEvent(event: FakeWifiEventModel.CarrierMerged) {
@@ -240,6 +244,7 @@ class DemoMobileConnectionRepository(
        _isInService.value = true
        _isGsm.value = false
        _carrierNetworkChangeActive.value = false
        isAllowedDuringAirplaneMode.value = true
    }

    companion object {
+7 −0
Original line number Diff line number Diff line
@@ -165,6 +165,13 @@ class CarrierMergedConnectionRepository(
    override val isGsm = MutableStateFlow(false).asStateFlow()
    override val carrierNetworkChangeActive = MutableStateFlow(false).asStateFlow()

    /**
     * Carrier merged connections happen over wifi but are displayed as a mobile triangle. Because
     * they occur over wifi, it's possible to have a valid carrier merged connection even during
     * airplane mode. See b/291993542.
     */
    override val isAllowedDuringAirplaneMode = MutableStateFlow(true).asStateFlow()

    override val dataEnabled: StateFlow<Boolean> = wifiRepository.isWifiEnabled

    companion object {
+9 −0
Original line number Diff line number Diff line
@@ -287,6 +287,15 @@ class FullMobileConnectionRepository(
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), activeRepo.value.networkName.value)

    override val isAllowedDuringAirplaneMode =
        activeRepo
            .flatMapLatest { it.isAllowedDuringAirplaneMode }
            .stateIn(
                scope,
                SharingStarted.WhileSubscribed(),
                activeRepo.value.isAllowedDuringAirplaneMode.value,
            )

    class Factory
    @Inject
    constructor(
+5 −0
Original line number Diff line number Diff line
@@ -59,8 +59,10 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.asExecutor
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map
@@ -331,6 +333,9 @@ class MobileConnectionRepositoryImpl(
            .stateIn(scope, SharingStarted.WhileSubscribed(), initial)
    }

    /** Typical mobile connections aren't available during airplane mode. */
    override val isAllowedDuringAirplaneMode = MutableStateFlow(false).asStateFlow()

    class Factory
    @Inject
    constructor(
Loading