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

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

[Sb refactor] Use MobileMappings key for Unknown net types

ResolvedNetworkType.UnknownNetworkType was using "unknown" as the key,
but MobileMappings actually can potentially have some embedded
information about which network type icon to display in the case of
unknown. This would also always cause a lookup failure, causing the G
network indicator to show in cases where it should not be.

Test: MobileConnectionRepositoryTest
Bug: 269040632
Change-Id: I61f450faa756487983f300ff9dfefdcb74424e43
parent 49f1e9e0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
package com.android.systemui.statusbar.pipeline.mobile.data.model

import android.telephony.Annotation.NetworkType
import android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN
import com.android.settingslib.SignalIcon
import com.android.settingslib.mobile.MobileMappings
import com.android.settingslib.mobile.TelephonyIcons
import com.android.systemui.log.table.Diffable
import com.android.systemui.log.table.TableRowLogger
@@ -38,7 +40,7 @@ sealed interface ResolvedNetworkType : Diffable<ResolvedNetworkType> {
    }

    object UnknownNetworkType : ResolvedNetworkType {
        override val lookupKey: String = "unknown"
        override val lookupKey: String = MobileMappings.toIconKey(NETWORK_TYPE_UNKNOWN)

        override fun toString(): String = "Unknown"
    }
+20 −0
Original line number Diff line number Diff line
@@ -50,7 +50,9 @@ import android.telephony.TelephonyManager.EXTRA_SHOW_SPN
import android.telephony.TelephonyManager.EXTRA_SPN
import android.telephony.TelephonyManager.EXTRA_SUBSCRIPTION_ID
import android.telephony.TelephonyManager.NETWORK_TYPE_LTE
import android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN
import androidx.test.filters.SmallTest
import com.android.settingslib.mobile.MobileMappings
import com.android.systemui.SysuiTestCase
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.statusbar.pipeline.mobile.data.MobileInputLogger
@@ -391,6 +393,24 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
            job.cancel()
        }

    @Test
    fun networkType_unknown_hasCorrectKey() =
        runBlocking(IMMEDIATE) {
            var latest: ResolvedNetworkType? = null
            val job = underTest.resolvedNetworkType.onEach { latest = it }.launchIn(this)

            val callback = getTelephonyCallbackForType<TelephonyCallback.DisplayInfoListener>()
            val type = NETWORK_TYPE_UNKNOWN
            val expected = UnknownNetworkType
            val ti = mock<TelephonyDisplayInfo>().also { whenever(it.networkType).thenReturn(type) }
            callback.onDisplayInfoChanged(ti)

            assertThat(latest).isEqualTo(expected)
            assertThat(latest!!.lookupKey).isEqualTo(MobileMappings.toIconKey(type))

            job.cancel()
        }

    @Test
    fun networkType_updatesUsingDefault() =
        runBlocking(IMMEDIATE) {