Add the Primary IMEI
As per GSMA specification TS37, below Primary IMEI requirements are mandatory to support -TS37_2.2_REQ_5 -TS37_2.2_REQ_8 (Attached the document has description about this test cases) Bug: 341006304 Test: atest MobileNetworkImeiPreferenceControllerTest Change-Id: I839440de7d2680d21832dce6d0d56db992796fca
This commit is contained in:
@@ -11855,6 +11855,10 @@
|
||||
<string name="sim_onboarding_progressbar_turning_sim_on">Turning on <xliff:g id="carrier_name" example="Google Fi">%1$s</xliff:g>…</string>
|
||||
<!-- Title of service provider name(SPN) at mobile network settings page. [CHAR LIMIT=30] -->
|
||||
<string name="mobile_network_spn_title">Mobile network</string>
|
||||
<!-- At the mobile network page, title for primary IMEI for multi-sim devices -->
|
||||
<string name="imei_primary">IMEI (primary)</string>
|
||||
<!-- At the mobile network page, title for primary MEID for multi-sim devices -->
|
||||
<string name="meid_primary">MEID (primary)</string>
|
||||
<!-- Title of phone number at mobile network settings page. [CHAR LIMIT=30] -->
|
||||
<string name="mobile_network_phone_number_title">Phone number</string>
|
||||
<!-- Title of SIM label and color editor dialog at mobile network settings page. [CHAR LIMIT=30] -->
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.network.telephony
|
||||
|
||||
import android.content.Context
|
||||
import android.os.UserManager
|
||||
import android.telephony.SubscriptionInfo
|
||||
import android.telephony.SubscriptionManager
|
||||
import android.telephony.TelephonyManager
|
||||
@@ -41,6 +40,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
/**
|
||||
* Preference controller for "IMEI"
|
||||
*/
|
||||
@@ -123,17 +123,21 @@ class MobileNetworkImeiPreferenceController(context: Context, key: String) :
|
||||
ImeiInfoDialogFragment.show(fragment, simSlot, preference.title.toString())
|
||||
return true
|
||||
}
|
||||
|
||||
private fun getImei(): String {
|
||||
val phoneType = getPhoneType()
|
||||
return if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) mTelephonyManager.meid?: String()
|
||||
else mTelephonyManager.imei?: String()
|
||||
}
|
||||
|
||||
private fun getTitleForGsmPhone(): String {
|
||||
return mContext.getString(R.string.status_imei)
|
||||
return mContext.getString(
|
||||
if (isPrimaryImei()) R.string.imei_primary else R.string.status_imei)
|
||||
}
|
||||
|
||||
private fun getTitleForCdmaPhone(): String {
|
||||
return mContext.getString(R.string.status_meid_number)
|
||||
return mContext.getString(
|
||||
if (isPrimaryImei()) R.string.meid_primary else R.string.status_meid_number)
|
||||
}
|
||||
|
||||
private fun getTitle(): String {
|
||||
@@ -142,6 +146,28 @@ class MobileNetworkImeiPreferenceController(context: Context, key: String) :
|
||||
else getTitleForGsmPhone()
|
||||
}
|
||||
|
||||
/**
|
||||
* As per GSMA specification TS37, below Primary IMEI requirements are mandatory to support
|
||||
*
|
||||
* TS37_2.2_REQ_5
|
||||
* TS37_2.2_REQ_8 (Attached the document has description about this test cases)
|
||||
*/
|
||||
protected fun isPrimaryImei(): Boolean {
|
||||
val imei = getImei()
|
||||
var primaryImei = String()
|
||||
|
||||
try {
|
||||
primaryImei = mTelephonyManager.primaryImei
|
||||
} catch (exception: Exception) {
|
||||
Log.e(TAG, "PrimaryImei not available. $exception")
|
||||
}
|
||||
return primaryImei == imei && isMultiSim()
|
||||
}
|
||||
|
||||
private fun isMultiSim(): Boolean {
|
||||
return mTelephonyManager.activeModemCount > 1
|
||||
}
|
||||
|
||||
fun getPhoneType(): Int {
|
||||
return mTelephonyManager.currentPhoneType
|
||||
}
|
||||
|
@@ -19,18 +19,16 @@ package com.android.settings.network.telephony
|
||||
import android.content.Context
|
||||
import android.telephony.SubscriptionInfo
|
||||
import android.telephony.TelephonyManager
|
||||
import android.telephony.euicc.EuiccManager
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.android.dx.mockito.inline.extended.ExtendedMockito
|
||||
import com.android.internal.telephony.PhoneConstants
|
||||
import com.android.settings.R
|
||||
import com.android.settings.core.BasePreferenceController
|
||||
import com.android.settings.network.SubscriptionInfoListViewModel
|
||||
import com.android.settings.network.SubscriptionUtil
|
||||
import com.android.settingslib.CustomDialogPreferenceCompat
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.After
|
||||
@@ -62,6 +60,8 @@ class MobileNetworkImeiPreferenceControllerTest {
|
||||
on { currentPhoneType } doReturn TelephonyManager.PHONE_TYPE_GSM
|
||||
on { imei } doReturn mockImei
|
||||
on { meid } doReturn mockImei
|
||||
on { primaryImei } doReturn mockImei
|
||||
on { activeModemCount } doReturn 2
|
||||
}
|
||||
|
||||
private val context: Context = spy(ApplicationProvider.getApplicationContext()) {
|
||||
@@ -90,7 +90,7 @@ class MobileNetworkImeiPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun refreshData_getPhoneNumber_preferenceSummaryIsExpected() = runBlocking {
|
||||
fun refreshData_getImei_preferenceSummaryIsExpected() = runBlocking {
|
||||
whenever(SubscriptionUtil.isSimHardwareVisible(context)).thenReturn(true)
|
||||
whenever(SubscriptionUtil.getActiveSubscriptions(any())).thenReturn(
|
||||
listOf(
|
||||
@@ -110,6 +110,50 @@ class MobileNetworkImeiPreferenceControllerTest {
|
||||
assertThat(preference.summary).isEqualTo(mockImei)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun refreshData_getImeiTitle_showImei() = runBlocking {
|
||||
whenever(SubscriptionUtil.isSimHardwareVisible(context)).thenReturn(true)
|
||||
whenever(SubscriptionUtil.getActiveSubscriptions(any())).thenReturn(
|
||||
listOf(
|
||||
SUB_INFO_1,
|
||||
SUB_INFO_2
|
||||
)
|
||||
)
|
||||
var mockSubId = 2
|
||||
controller.init(mockFragment, mockSubId)
|
||||
mockImei = "test imei"
|
||||
mockTelephonyManager.stub {
|
||||
on { imei } doReturn mockImei
|
||||
on { primaryImei } doReturn ""
|
||||
}
|
||||
|
||||
controller.refreshData(SUB_INFO_2)
|
||||
|
||||
assertThat(preference.title).isEqualTo(context.getString(R.string.status_imei))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun refreshData_getPrimaryImeiTitle_showPrimaryImei() = runBlocking {
|
||||
whenever(SubscriptionUtil.isSimHardwareVisible(context)).thenReturn(true)
|
||||
whenever(SubscriptionUtil.getActiveSubscriptions(any())).thenReturn(
|
||||
listOf(
|
||||
SUB_INFO_1,
|
||||
SUB_INFO_2
|
||||
)
|
||||
)
|
||||
var mockSubId = 2
|
||||
controller.init(mockFragment, mockSubId)
|
||||
mockImei = "test imei"
|
||||
mockTelephonyManager.stub {
|
||||
on { imei } doReturn mockImei
|
||||
on { primaryImei } doReturn mockImei
|
||||
}
|
||||
|
||||
controller.refreshData(SUB_INFO_2)
|
||||
|
||||
assertThat(preference.title).isEqualTo(context.getString(R.string.imei_primary))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getAvailabilityStatus_notSimHardwareVisible() {
|
||||
whenever(SubscriptionUtil.isSimHardwareVisible(context)).thenReturn(false)
|
||||
|
Reference in New Issue
Block a user