From 6f01512762c39eb5b0d7bd8850a76be5dc750692 Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Fri, 17 May 2024 12:22:52 +0800 Subject: [PATCH] Fix CellInfoUtilTest Fix: 337417936 Fix: 337417222 Test: unit test Change-Id: I47dfa05fd4839885ad7f2115a279a7b4675e85fc --- .../network/telephony/CellInfoUtil.kt | 33 ------------------- .../network/telephony/CellInfoUtilTest.kt | 18 +--------- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/src/com/android/settings/network/telephony/CellInfoUtil.kt b/src/com/android/settings/network/telephony/CellInfoUtil.kt index 51f60e796ff..d1fe89cb9e3 100644 --- a/src/com/android/settings/network/telephony/CellInfoUtil.kt +++ b/src/com/android/settings/network/telephony/CellInfoUtil.kt @@ -17,12 +17,9 @@ package com.android.settings.network.telephony import android.telephony.CellIdentity -import android.telephony.CellIdentityGsm import android.telephony.CellInfo -import android.telephony.CellInfoGsm import android.text.BidiFormatter import android.text.TextDirectionHeuristics -import com.android.internal.telephony.OperatorInfo /** * Add static Utility functions to get information from the CellInfo object. @@ -47,36 +44,6 @@ object CellInfoUtil { return bidiFormatter.unicodeWrap(operatorNumeric, TextDirectionHeuristics.LTR) } - /** - * Creates a CellInfo object from OperatorInfo. GsmCellInfo is used here only because - * operatorInfo does not contain technology type while CellInfo is an abstract object that - * requires to specify technology type. It doesn't matter which CellInfo type to use here, since - * we only want to wrap the operator info and PLMN to a CellInfo object. - */ - @JvmStatic - fun convertOperatorInfoToCellInfo(operatorInfo: OperatorInfo): CellInfo { - val operatorNumeric = operatorInfo.operatorNumeric - var mcc: String? = null - var mnc: String? = null - if (operatorNumeric?.matches("^[0-9]{5,6}$".toRegex()) == true) { - mcc = operatorNumeric.substring(0, 3) - mnc = operatorNumeric.substring(3) - } - return CellInfoGsm().apply { - cellIdentity = CellIdentityGsm( - /* lac = */ Int.MAX_VALUE, - /* cid = */ Int.MAX_VALUE, - /* arfcn = */ Int.MAX_VALUE, - /* bsic = */ Int.MAX_VALUE, - /* mccStr = */ mcc, - /* mncStr = */ mnc, - /* alphal = */ operatorInfo.operatorAlphaLong, - /* alphas = */ operatorInfo.operatorAlphaShort, - /* additionalPlmns = */ emptyList(), - ) - } - } - /** * Convert a list of cellInfos to readable string without sensitive info. */ diff --git a/tests/unit/src/com/android/settings/network/telephony/CellInfoUtilTest.kt b/tests/unit/src/com/android/settings/network/telephony/CellInfoUtilTest.kt index d1d4a48d324..27b5c382211 100644 --- a/tests/unit/src/com/android/settings/network/telephony/CellInfoUtilTest.kt +++ b/tests/unit/src/com/android/settings/network/telephony/CellInfoUtilTest.kt @@ -21,11 +21,9 @@ import android.telephony.CellIdentityGsm import android.telephony.CellInfoCdma import android.telephony.CellInfoGsm import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.android.internal.telephony.OperatorInfo import com.android.settings.network.telephony.CellInfoUtil.getNetworkTitle import com.android.settings.network.telephony.CellInfoUtil.getOperatorNumeric import com.google.common.truth.Truth.assertThat -import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith @@ -97,20 +95,6 @@ class CellInfoUtilTest { } @Test - @Ignore("b/337417936") - fun convertOperatorInfoToCellInfo() { - val operatorInfo = OperatorInfo(LONG, SHORT, "12301") - - val cellInfo = CellInfoUtil.convertOperatorInfoToCellInfo(operatorInfo) - - assertThat(cellInfo.cellIdentity.mccString).isEqualTo("123") - assertThat(cellInfo.cellIdentity.mncString).isEqualTo("01") - assertThat(cellInfo.cellIdentity.operatorAlphaLong).isEqualTo(LONG) - assertThat(cellInfo.cellIdentity.operatorAlphaShort).isEqualTo(SHORT) - } - - @Test - @Ignore("b/337417222") fun cellInfoListToString() { val cellInfoList = listOf( @@ -127,7 +111,7 @@ class CellInfoUtilTest { assertThat(string).isEqualTo( "{CellType = CellInfoCdma, isRegistered = false, " + - "mcc = null, mnc = null, alphaL = Long, alphaS = Short}, " + + "mcc = null, mnc = null, alphaL = Long, alphaS = Short}${System.lineSeparator()}" + "{CellType = CellInfoGsm, isRegistered = true, " + "mcc = 123, mnc = 01, alphaL = Long, alphaS = Short}" )