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

Commit c144becd authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB Refactor] Remove `type` from ResolvedNetworkType.

ag/20614195 made `type` obsolete.

Bug: 238425913
Test: atest MobileConnectionRepositoryTest
Change-Id: Ieb73c357e41836e18c3ad7613a8c772a7becf682
parent 1d08a471
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.pipeline.mobile.data.model

import android.telephony.Annotation.NetworkType
import android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN
import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy

/**
@@ -26,21 +25,17 @@ import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy
 * methods on [MobileMappingsProxy] to generate an icon lookup key.
 */
sealed interface ResolvedNetworkType {
    @NetworkType val type: Int
    val lookupKey: String

    object UnknownNetworkType : ResolvedNetworkType {
        override val type: Int = NETWORK_TYPE_UNKNOWN
        override val lookupKey: String = "unknown"
    }

    data class DefaultNetworkType(
        @NetworkType override val type: Int,
        override val lookupKey: String,
    ) : ResolvedNetworkType

    data class OverrideNetworkType(
        @NetworkType override val type: Int,
        override val lookupKey: String,
    ) : ResolvedNetworkType
}
+1 −3
Original line number Diff line number Diff line
@@ -253,15 +253,13 @@ constructor(

    private fun SignalIcon.MobileIconGroup?.toResolvedNetworkType(): ResolvedNetworkType {
        val key = mobileMappingsReverseLookup.value[this] ?: "dis"
        return DefaultNetworkType(DEMO_NET_TYPE, key)
        return DefaultNetworkType(key)
    }

    companion object {
        private const val TAG = "DemoMobileConnectionsRepo"

        private const val DEFAULT_SUB_ID = 1

        private const val DEMO_NET_TYPE = 1234
    }
}

+0 −2
Original line number Diff line number Diff line
@@ -186,14 +186,12 @@ class MobileConnectionRepositoryImpl(
                                        OVERRIDE_NETWORK_TYPE_NONE
                                ) {
                                    DefaultNetworkType(
                                        telephonyDisplayInfo.networkType,
                                        mobileMappingsProxy.toIconKey(
                                            telephonyDisplayInfo.networkType
                                        )
                                    )
                                } else {
                                    OverrideNetworkType(
                                        telephonyDisplayInfo.overrideNetworkType,
                                        mobileMappingsProxy.toIconKeyOverride(
                                            telephonyDisplayInfo.overrideNetworkType
                                        )
+2 −2
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {

            val callback = getTelephonyCallbackForType<TelephonyCallback.DisplayInfoListener>()
            val type = NETWORK_TYPE_LTE
            val expected = DefaultNetworkType(type, mobileMappings.toIconKey(type))
            val expected = DefaultNetworkType(mobileMappings.toIconKey(type))
            val ti = mock<TelephonyDisplayInfo>().also { whenever(it.networkType).thenReturn(type) }
            callback.onDisplayInfoChanged(ti)

@@ -336,7 +336,7 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {

            val callback = getTelephonyCallbackForType<TelephonyCallback.DisplayInfoListener>()
            val type = OVERRIDE_NETWORK_TYPE_LTE_CA
            val expected = OverrideNetworkType(type, mobileMappings.toIconKeyOverride(type))
            val expected = OverrideNetworkType(mobileMappings.toIconKeyOverride(type))
            val ti =
                mock<TelephonyDisplayInfo>().also {
                    whenever(it.networkType).thenReturn(type)
+4 −17
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.pipeline.mobile.domain.interactor

import android.telephony.CellSignalStrength
import android.telephony.SubscriptionInfo
import android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN
import androidx.test.filters.SmallTest
import com.android.settingslib.SignalIcon.MobileIconGroup
@@ -34,7 +33,6 @@ import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.FakeMobi
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.FakeMobileIconsInteractor.Companion.THREE_G
import com.android.systemui.statusbar.pipeline.mobile.util.FakeMobileMappingsProxy
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -197,8 +195,7 @@ class MobileIconInteractorTest : SysuiTestCase() {
        runBlocking(IMMEDIATE) {
            connectionRepository.setConnectionInfo(
                MobileConnectionModel(
                    resolvedNetworkType =
                        DefaultNetworkType(THREE_G, mobileMappingsProxy.toIconKey(THREE_G))
                    resolvedNetworkType = DefaultNetworkType(mobileMappingsProxy.toIconKey(THREE_G))
                ),
            )

@@ -215,8 +212,7 @@ class MobileIconInteractorTest : SysuiTestCase() {
        runBlocking(IMMEDIATE) {
            connectionRepository.setConnectionInfo(
                MobileConnectionModel(
                    resolvedNetworkType =
                        DefaultNetworkType(THREE_G, mobileMappingsProxy.toIconKey(THREE_G))
                    resolvedNetworkType = DefaultNetworkType(mobileMappingsProxy.toIconKey(THREE_G))
                ),
            )

@@ -227,7 +223,6 @@ class MobileIconInteractorTest : SysuiTestCase() {
                MobileConnectionModel(
                    resolvedNetworkType =
                        DefaultNetworkType(
                            FOUR_G,
                            mobileMappingsProxy.toIconKey(FOUR_G),
                        ),
                ),
@@ -245,10 +240,7 @@ class MobileIconInteractorTest : SysuiTestCase() {
            connectionRepository.setConnectionInfo(
                MobileConnectionModel(
                    resolvedNetworkType =
                        OverrideNetworkType(
                            FIVE_G_OVERRIDE,
                            mobileMappingsProxy.toIconKeyOverride(FIVE_G_OVERRIDE)
                        )
                        OverrideNetworkType(mobileMappingsProxy.toIconKeyOverride(FIVE_G_OVERRIDE))
                ),
            )

@@ -266,10 +258,7 @@ class MobileIconInteractorTest : SysuiTestCase() {
            connectionRepository.setConnectionInfo(
                MobileConnectionModel(
                    resolvedNetworkType =
                        DefaultNetworkType(
                            NETWORK_TYPE_UNKNOWN,
                            mobileMappingsProxy.toIconKey(NETWORK_TYPE_UNKNOWN)
                        ),
                        DefaultNetworkType(mobileMappingsProxy.toIconKey(NETWORK_TYPE_UNKNOWN)),
                ),
            )

@@ -524,8 +513,6 @@ class MobileIconInteractorTest : SysuiTestCase() {
        private const val CDMA_LEVEL = 2

        private const val SUB_1_ID = 1
        private val SUB_1 =
            mock<SubscriptionInfo>().also { whenever(it.subscriptionId).thenReturn(SUB_1_ID) }

        private val DEFAULT_NAME = NetworkNameModel.Default("test default name")
        private val DERIVED_NAME = NetworkNameModel.Derived("test derived name")