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

Commit fb60e153 authored by Evan Laird's avatar Evan Laird
Browse files

[Sb refactor] Implement DataEnabledChangedListener

This CL changes the behavior of checking for mobile data enabled. The
old pipeline would await telephony callbacks and then poll for
`TelephonyManager.isDataConnectionAllowed`. Problem is that there was a
race condition with watching the settings and polling this field, so it
was often wrong on the first read.

This change implements the newer
TelephonyCallback.DataEnabledChangedListener, which can supplant the old
polling method and simplify our repositories.

Bug: 238425913
Bug: 260112365
Test: MobileConnectionRepositoryTest
Change-Id: Ied9eea844501cd03100d85286993f85df671b37d
parent e43cc99e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
        <permission name="android.permission.READ_FRAME_BUFFER"/>
        <permission name="android.permission.READ_NETWORK_USAGE_HISTORY"/>
        <permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
        <permission name="android.permission.READ_PRECISE_PHONE_STATE"/>
        <permission name="android.permission.REAL_GET_TASKS"/>
        <permission name="android.permission.REQUEST_NETWORK_SCORES"/>
        <permission name="android.permission.RECEIVE_MEDIA_RESOURCE_USAGE"/>
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" />
+0 −4
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar.pipeline.mobile.data.repository

import android.provider.Settings
import android.telephony.CarrierConfigManager
import android.telephony.SubscriptionManager
import com.android.settingslib.SignalIcon.MobileIconGroup
@@ -53,9 +52,6 @@ interface MobileConnectionsRepository {
    /** Get or create a repository for the line of service for the given subscription ID */
    fun getRepoForSubId(subId: Int): MobileConnectionRepository

    /** Observe changes to the [Settings.Global.MOBILE_DATA] setting */
    val globalMobileDataSettingChangedEvent: Flow<Unit>

    /**
     * [Config] is an object that tracks relevant configuration flags for a given subscription ID.
     * In the case of [MobileMappings], it's hard-coded to check the default data subscription's
+0 −3
Original line number Diff line number Diff line
@@ -156,9 +156,6 @@ constructor(
                realRepository.defaultMobileNetworkConnectivity.value
            )

    override val globalMobileDataSettingChangedEvent: Flow<Unit> =
        activeRepo.flatMapLatest { it.globalMobileDataSettingChangedEvent }

    override fun getRepoForSubId(subId: Int): MobileConnectionRepository {
        if (isDemoMode.value) {
            return demoMobileConnectionsRepository.getRepoForSubId(subId)
+0 −2
Original line number Diff line number Diff line
@@ -185,8 +185,6 @@ constructor(
        return CacheContainer(repo, lastMobileState = null)
    }

    override val globalMobileDataSettingChangedEvent = MutableStateFlow(Unit)

    fun startProcessingCommands() {
        mobileDemoCommandJob =
            scope.launch {
Loading