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

Commit b26dc33d authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge changes I05fa65f3,Ie576d9ce into udc-dev

* changes:
  [SB Refactor] Use carrierMergedSubId for the mobile default calculation.
  [Status bar] Take underlying networks into account for wifi.
parents 208ecf20 4cb3c716
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -60,6 +60,13 @@ interface MobileConnectionsRepository {
     */
    val mobileIsDefault: StateFlow<Boolean>

    /**
     * True if the device currently has a carrier merged connection.
     *
     * See [CarrierMergedConnectionRepository] for more info.
     */
    val hasCarrierMergedConnection: Flow<Boolean>

    /** True if the default network connection is validated and false otherwise. */
    val defaultConnectionIsValidated: StateFlow<Boolean>

+9 −0
Original line number Diff line number Diff line
@@ -159,6 +159,15 @@ constructor(
            .flatMapLatest { it.mobileIsDefault }
            .stateIn(scope, SharingStarted.WhileSubscribed(), realRepository.mobileIsDefault.value)

    override val hasCarrierMergedConnection: StateFlow<Boolean> =
        activeRepo
            .flatMapLatest { it.hasCarrierMergedConnection }
            .stateIn(
                scope,
                SharingStarted.WhileSubscribed(),
                realRepository.hasCarrierMergedConnection.value,
            )

    override val defaultConnectionIsValidated: StateFlow<Boolean> =
        activeRepo
            .flatMapLatest { it.defaultConnectionIsValidated }
+3 −0
Original line number Diff line number Diff line
@@ -159,6 +159,9 @@ constructor(
    // TODO(b/261029387): not yet supported
    override val mobileIsDefault: StateFlow<Boolean> = MutableStateFlow(true)

    // TODO(b/261029387): not yet supported
    override val hasCarrierMergedConnection = MutableStateFlow(false)

    // TODO(b/261029387): not yet supported
    override val defaultConnectionIsValidated: StateFlow<Boolean> = MutableStateFlow(true)

+19 −4
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
@@ -257,18 +258,32 @@ constructor(

    override val mobileIsDefault: StateFlow<Boolean> =
        connectivityRepository.defaultConnections
            // Because carrier merged networks are displayed as mobile networks, they're
            // part of the `isDefault` calculation. See b/272586234.
            .map { it.mobile.isDefault || it.carrierMerged.isDefault }
            .map { it.mobile.isDefault }
            .distinctUntilChanged()
            .logDiffsForTable(
                tableLogger,
                columnPrefix = "",
                columnPrefix = LOGGING_PREFIX,
                columnName = "mobileIsDefault",
                initialValue = false,
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)

    override val hasCarrierMergedConnection: StateFlow<Boolean> =
        combine(
                connectivityRepository.defaultConnections,
                carrierMergedSubId,
            ) { defaultConnections, carrierMergedSubId ->
                defaultConnections.carrierMerged.isDefault || carrierMergedSubId != null
            }
            .distinctUntilChanged()
            .logDiffsForTable(
                tableLogger,
                columnPrefix = LOGGING_PREFIX,
                columnName = "hasCarrierMergedConnection",
                initialValue = false,
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)

    override val defaultConnectionIsValidated: StateFlow<Boolean> =
        connectivityRepository.defaultConnections
            .map { it.isValidated }
+16 −1
Original line number Diff line number Diff line
@@ -113,7 +113,22 @@ constructor(
    private val context: Context,
) : MobileIconsInteractor {

    override val mobileIsDefault = mobileConnectionsRepo.mobileIsDefault
    override val mobileIsDefault =
        combine(
                mobileConnectionsRepo.mobileIsDefault,
                mobileConnectionsRepo.hasCarrierMergedConnection,
            ) { mobileIsDefault, hasCarrierMergedConnection ->
                // Because carrier merged networks are displayed as mobile networks, they're part of
                // the `isDefault` calculation. See b/272586234.
                mobileIsDefault || hasCarrierMergedConnection
            }
            .logDiffsForTable(
                tableLogger,
                LOGGING_PREFIX,
                columnName = "mobileIsDefault",
                initialValue = false,
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)

    override val activeDataConnectionHasDataEnabled: StateFlow<Boolean> =
        mobileConnectionsRepo.activeMobileDataRepository
Loading