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

Commit 0dbfccfb authored by Evan Laird's avatar Evan Laird Committed by Android Build Coastguard Worker
Browse files

Revert "[Mobile] Add SPN to network name calculation"

This reverts commit 73f375e2.

Reason for revert: Created a different bug b/356077157
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:0061c2530203107d5aee18823cd4e3033ca81679)
Merged-In: I2d6d12ff1c6b816cfea78d43bfaf05ad50abcb41
Change-Id: I2d6d12ff1c6b816cfea78d43bfaf05ad50abcb41
parent 374ade0d
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.telephony.TelephonyManager.EXTRA_DATA_SPN
import android.telephony.TelephonyManager.EXTRA_PLMN
import android.telephony.TelephonyManager.EXTRA_SHOW_PLMN
import android.telephony.TelephonyManager.EXTRA_SHOW_SPN
import android.telephony.TelephonyManager.EXTRA_SPN
import com.android.systemui.log.table.Diffable
import com.android.systemui.log.table.TableRowLogger

@@ -97,8 +96,7 @@ sealed interface NetworkNameModel : Diffable<NetworkNameModel> {

fun Intent.toNetworkNameModel(separator: String): NetworkNameModel? {
    val showSpn = getBooleanExtra(EXTRA_SHOW_SPN, false)
    val spn = getStringExtra(EXTRA_SPN)
    val dataSpn = getStringExtra(EXTRA_DATA_SPN)
    val spn = getStringExtra(EXTRA_DATA_SPN)
    val showPlmn = getBooleanExtra(EXTRA_SHOW_PLMN, false)
    val plmn = getStringExtra(EXTRA_PLMN)

@@ -114,12 +112,6 @@ fun Intent.toNetworkNameModel(separator: String): NetworkNameModel? {
        }
        str.append(spn)
    }
    if (showSpn && dataSpn != null) {
        if (str.isNotEmpty()) {
            str.append(separator)
        }
        str.append(dataSpn)
    }

    return if (str.isNotEmpty()) NetworkNameModel.IntentDerived(str.toString()) else null
}
+16 −102
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ import android.telephony.TelephonyManager.DATA_UNKNOWN
import android.telephony.TelephonyManager.ERI_OFF
import android.telephony.TelephonyManager.ERI_ON
import android.telephony.TelephonyManager.EXTRA_CARRIER_ID
import android.telephony.TelephonyManager.EXTRA_DATA_SPN
import android.telephony.TelephonyManager.EXTRA_PLMN
import android.telephony.TelephonyManager.EXTRA_SHOW_PLMN
import android.telephony.TelephonyManager.EXTRA_SHOW_SPN
@@ -85,6 +84,7 @@ import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionMod
import com.android.systemui.statusbar.pipeline.mobile.data.model.SystemUiCarrierConfig
import com.android.systemui.statusbar.pipeline.mobile.data.model.SystemUiCarrierConfigTest.Companion.configWithOverride
import com.android.systemui.statusbar.pipeline.mobile.data.model.SystemUiCarrierConfigTest.Companion.createTestConfig
import com.android.systemui.statusbar.pipeline.mobile.data.model.toNetworkNameModel
import com.android.systemui.statusbar.pipeline.mobile.data.repository.FakeMobileConnectionsRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionRepository.Companion.DEFAULT_NUM_LEVELS
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.MobileTelephonyHelpers.signalStrength
@@ -92,6 +92,8 @@ import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.Mobil
import com.android.systemui.statusbar.pipeline.mobile.util.FakeMobileMappingsProxy
import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel
import com.android.systemui.statusbar.pipeline.shared.data.model.toMobileDataActivityModel
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.argumentCaptor
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.android.systemui.util.mockito.withArgCaptor
@@ -108,8 +110,6 @@ import org.junit.Test
import org.mockito.Mock
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
import org.mockito.kotlin.any
import org.mockito.kotlin.argumentCaptor

@Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
@OptIn(ExperimentalCoroutinesApi::class)
@@ -812,11 +812,9 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
            val intent = spnIntent()
            val captor = argumentCaptor<BroadcastReceiver>()
            verify(context).registerReceiver(captor.capture(), any())
            captor.lastValue.onReceive(context, intent)
            captor.value!!.onReceive(context, intent)

            // spnIntent() sets all values to true and test strings
            assertThat(latest)
                .isEqualTo(NetworkNameModel.IntentDerived("$PLMN$SEP$SPN$SEP$DATA_SPN"))
            assertThat(latest).isEqualTo(intent.toNetworkNameModel(SEP))

            job.cancel()
        }
@@ -830,19 +828,17 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
            val intent = spnIntent()
            val captor = argumentCaptor<BroadcastReceiver>()
            verify(context).registerReceiver(captor.capture(), any())
            captor.lastValue.onReceive(context, intent)
            captor.value!!.onReceive(context, intent)

            assertThat(latest)
                .isEqualTo(NetworkNameModel.IntentDerived("$PLMN$SEP$SPN$SEP$DATA_SPN"))
            assertThat(latest).isEqualTo(intent.toNetworkNameModel(SEP))

            // WHEN an intent with a different subId is sent
            val wrongSubIntent = spnIntent(subId = 101)

            captor.lastValue.onReceive(context, wrongSubIntent)
            captor.value!!.onReceive(context, wrongSubIntent)

            // THEN the previous intent's name is still used
            assertThat(latest)
                .isEqualTo(NetworkNameModel.IntentDerived("$PLMN$SEP$SPN$SEP$DATA_SPN"))
            assertThat(latest).isEqualTo(intent.toNetworkNameModel(SEP))

            job.cancel()
        }
@@ -856,10 +852,9 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
            val intent = spnIntent()
            val captor = argumentCaptor<BroadcastReceiver>()
            verify(context).registerReceiver(captor.capture(), any())
            captor.lastValue.onReceive(context, intent)
            captor.value!!.onReceive(context, intent)

            assertThat(latest)
                .isEqualTo(NetworkNameModel.IntentDerived("$PLMN$SEP$SPN$SEP$DATA_SPN"))
            assertThat(latest).isEqualTo(intent.toNetworkNameModel(SEP))

            val intentWithoutInfo =
                spnIntent(
@@ -867,7 +862,7 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
                    showPlmn = false,
                )

            captor.lastValue.onReceive(context, intentWithoutInfo)
            captor.value!!.onReceive(context, intentWithoutInfo)

            assertThat(latest).isEqualTo(DEFAULT_NAME_MODEL)

@@ -886,88 +881,10 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
            val intent = spnIntent()
            val captor = argumentCaptor<BroadcastReceiver>()
            verify(context).registerReceiver(captor.capture(), any())
            captor.lastValue.onReceive(context, intent)
            captor.value!!.onReceive(context, intent)

            // The value is still there despite no active subscribers
            assertThat(underTest.networkName.value)
                .isEqualTo(NetworkNameModel.IntentDerived("$PLMN$SEP$SPN$SEP$DATA_SPN"))
        }

    @Test
    fun networkName_allFieldsSet() =
        testScope.runTest {
            val latest by collectLastValue(underTest.networkName)
            val captor = argumentCaptor<BroadcastReceiver>()
            verify(context).registerReceiver(captor.capture(), any())

            val intent =
                spnIntent(
                    subId = SUB_1_ID,
                    showSpn = true,
                    spn = SPN,
                    dataSpn = null,
                    showPlmn = true,
                    plmn = PLMN,
                )
            captor.lastValue.onReceive(context, intent)
            assertThat(latest).isEqualTo(NetworkNameModel.IntentDerived("$PLMN$SEP$SPN"))
        }

    @Test
    fun networkName_showPlmn_plmnNotNull_showSpn_spnNull_dataSpnNotNull() =
        testScope.runTest {
            val latest by collectLastValue(underTest.networkName)
            val captor = argumentCaptor<BroadcastReceiver>()
            verify(context).registerReceiver(captor.capture(), any())
            val intent =
                spnIntent(
                    subId = SUB_1_ID,
                    showSpn = true,
                    spn = null,
                    dataSpn = DATA_SPN,
                    showPlmn = true,
                    plmn = PLMN,
                )
            captor.lastValue.onReceive(context, intent)
            assertThat(latest).isEqualTo(NetworkNameModel.IntentDerived("$PLMN$SEP$DATA_SPN"))
        }

    @Test
    fun networkName_showPlmn_noShowSPN() =
        testScope.runTest {
            val latest by collectLastValue(underTest.networkName)
            val captor = argumentCaptor<BroadcastReceiver>()
            verify(context).registerReceiver(captor.capture(), any())
            val intent =
                spnIntent(
                    subId = SUB_1_ID,
                    showSpn = false,
                    spn = SPN,
                    dataSpn = DATA_SPN,
                    showPlmn = true,
                    plmn = PLMN,
                )
            captor.lastValue.onReceive(context, intent)
            assertThat(latest).isEqualTo(NetworkNameModel.IntentDerived("$PLMN"))
        }

    @Test
    fun networkName_showPlmn_plmnNull_showSpn() =
        testScope.runTest {
            val latest by collectLastValue(underTest.networkName)
            val captor = argumentCaptor<BroadcastReceiver>()
            verify(context).registerReceiver(captor.capture(), any())
            val intent =
                spnIntent(
                    subId = SUB_1_ID,
                    showSpn = true,
                    spn = SPN,
                    dataSpn = DATA_SPN,
                    showPlmn = true,
                    plmn = null,
                )
            captor.lastValue.onReceive(context, intent)
            assertThat(latest).isEqualTo(NetworkNameModel.IntentDerived("$SPN$SEP$DATA_SPN"))
            assertThat(underTest.networkName.value).isEqualTo(intent.toNetworkNameModel(SEP))
        }

    @Test
@@ -1208,16 +1125,14 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
    private fun spnIntent(
        subId: Int = SUB_1_ID,
        showSpn: Boolean = true,
        spn: String? = SPN,
        dataSpn: String? = DATA_SPN,
        spn: String = SPN,
        showPlmn: Boolean = true,
        plmn: String? = PLMN,
        plmn: String = PLMN,
    ): Intent =
        Intent(TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED).apply {
            putExtra(EXTRA_SUBSCRIPTION_INDEX, subId)
            putExtra(EXTRA_SHOW_SPN, showSpn)
            putExtra(EXTRA_SPN, spn)
            putExtra(EXTRA_DATA_SPN, dataSpn)
            putExtra(EXTRA_SHOW_PLMN, showPlmn)
            putExtra(EXTRA_PLMN, plmn)
        }
@@ -1230,7 +1145,6 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
        private const val SEP = "-"

        private const val SPN = "testSpn"
        private const val DATA_SPN = "testDataSpn"
        private const val PLMN = "testPlmn"
    }
}