Merge "Telephony.Carriers.MVNO_TYPE is Deprecated." into main
diff --git a/src/com/android/settings/network/apn/ApnEditPageProvider.kt b/src/com/android/settings/network/apn/ApnEditPageProvider.kt
index 820a9d5..ad16ae3 100644
--- a/src/com/android/settings/network/apn/ApnEditPageProvider.kt
+++ b/src/com/android/settings/network/apn/ApnEditPageProvider.kt
@@ -47,8 +47,6 @@
const val URI_TYPE = "uriType"
const val URI = "uri"
const val SUB_ID = "subId"
-const val MVNO_TYPE = "mvnoType"
-const val MVNO_MATCH_DATA = "mvnoMatchData"
const val EDIT_URL = "editUrl"
const val INSERT_URL = "insertUrl"
@@ -61,8 +59,6 @@
navArgument(URI_TYPE) { type = NavType.StringType },
navArgument(URI) { type = NavType.StringType },
navArgument(SUB_ID) { type = NavType.IntType },
- navArgument(MVNO_TYPE) { type = NavType.StringType },
- navArgument(MVNO_MATCH_DATA) { type = NavType.StringType },
)
@Composable
@@ -80,12 +76,10 @@
fun getRoute(
uriType: String,
uri: Uri,
- subId: Int,
- mMvnoType: String,
- mMvnoMatchData: String
+ subId: Int
): String = "${name}/$uriType/${
Base64.getUrlEncoder().encodeToString(uri.toString().toByteArray())
- }/$subId/$mMvnoType/$mMvnoMatchData"
+ }/$subId"
}
@Composable
@@ -94,7 +88,6 @@
val context = LocalContext.current
val authTypeOptions = stringArrayResource(R.array.apn_auth_entries).toList()
val apnProtocolOptions = stringArrayResource(R.array.apn_protocol_entries).toList()
- val mvnoTypeOptions = stringArrayResource(R.array.mvno_type_entries).toList()
val networkTypeSelectedOptionsState = remember {
getNetworkTypeSelectedOptionsState(apnData.networkType)
}
@@ -152,16 +145,6 @@
label = stringResource(R.string.apn_mms_port),
enabled = apnData.mmsPortEnabled
) { apnData = apnData.copy(mmsPort = it) }
- SettingsOutlinedTextField(
- value = apnData.mcc,
- label = stringResource(R.string.apn_mcc),
- enabled = apnData.mccEnabled
- ) { apnData = apnData.copy(mcc = it) }
- SettingsOutlinedTextField(
- value = apnData.mnc,
- label = stringResource(R.string.apn_mnc),
- enabled = apnData.mncEnabled
- ) { apnData = apnData.copy(mnc = it) }
// Warning: apnProtocol, apnRoaming, mvnoType string2Int
SettingsExposedDropdownMenuBox(
label = stringResource(R.string.apn_auth_type),
@@ -205,19 +188,6 @@
emptyVal = stringResource(R.string.network_type_unspecified),
enabled = apnData.networkTypeEnabled
) {}
- SettingsExposedDropdownMenuBox(
- label = stringResource(R.string.mvno_type),
- options = mvnoTypeOptions,
- selectedOptionIndex = apnData.mvnoType,
- enabled = apnData.mvnoTypeEnabled
- ) {
- apnData = apnData.copy(mvnoType = it)
- } // TODO: mvnoDescription
- SettingsOutlinedTextField(
- value = apnData.mvnoValue,
- label = stringResource(R.string.mvno_match_data),
- enabled = apnData.mvnoValueEnabled
- ) { apnData = apnData.copy(mvnoValue = it) }
}
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/network/apn/ApnPreference.java b/src/com/android/settings/network/apn/ApnPreference.java
index 07d371a..dcc50cd 100755
--- a/src/com/android/settings/network/apn/ApnPreference.java
+++ b/src/com/android/settings/network/apn/ApnPreference.java
@@ -157,7 +157,7 @@
final Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
if (Flags.newApnPageEnabled()) {
- String route = ApnEditPageProvider.INSTANCE.getRoute(EDIT_URL, url, mSubId, "_", "_");
+ String route = ApnEditPageProvider.INSTANCE.getRoute(EDIT_URL, url, mSubId);
SpaActivity.startSpaActivity(context, route);
} else {
final Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
diff --git a/src/com/android/settings/network/apn/ApnRepository.kt b/src/com/android/settings/network/apn/ApnRepository.kt
index 3ce7567..f758439 100644
--- a/src/com/android/settings/network/apn/ApnRepository.kt
+++ b/src/com/android/settings/network/apn/ApnRepository.kt
@@ -31,21 +31,17 @@
const val SERVER_INDEX = 6
const val PASSWORD_INDEX = 7
const val MMSC_INDEX = 8
-const val MCC_INDEX = 9
-const val MNC_INDEX = 10
-const val MMSPROXY_INDEX = 12
-const val MMSPORT_INDEX = 13
-const val AUTH_TYPE_INDEX = 14
-const val TYPE_INDEX = 15
-const val PROTOCOL_INDEX = 16
-const val CARRIER_ENABLED_INDEX = 17
-const val NETWORK_TYPE_INDEX = 18
-const val ROAMING_PROTOCOL_INDEX = 19
-const val MVNO_TYPE_INDEX = 20
-const val MVNO_MATCH_DATA_INDEX = 21
-const val EDITED_INDEX = 22
-const val USER_EDITABLE_INDEX = 23
-const val CARRIER_ID_INDEX = 24
+const val MMSPROXY_INDEX = 9
+const val MMSPORT_INDEX = 10
+const val AUTH_TYPE_INDEX = 11
+const val TYPE_INDEX = 12
+const val PROTOCOL_INDEX = 13
+const val CARRIER_ENABLED_INDEX = 14
+const val NETWORK_TYPE_INDEX = 15
+const val ROAMING_PROTOCOL_INDEX = 16
+const val EDITED_INDEX = 17
+const val USER_EDITABLE_INDEX = 18
+const val CARRIER_ID_INDEX = 19
val sProjection = arrayOf(
Telephony.Carriers._ID, // 0
@@ -57,22 +53,17 @@
Telephony.Carriers.SERVER, // 6
Telephony.Carriers.PASSWORD, // 7
Telephony.Carriers.MMSC, // 8
- Telephony.Carriers.MCC, // 9
- Telephony.Carriers.MNC, // 10
- Telephony.Carriers.NUMERIC, // 11
- Telephony.Carriers.MMSPROXY, // 12
- Telephony.Carriers.MMSPORT, // 13
- Telephony.Carriers.AUTH_TYPE, // 14
- Telephony.Carriers.TYPE, // 15
- Telephony.Carriers.PROTOCOL, // 16
- Telephony.Carriers.CARRIER_ENABLED, // 17
- Telephony.Carriers.NETWORK_TYPE_BITMASK, // 18
- Telephony.Carriers.ROAMING_PROTOCOL, // 19
- Telephony.Carriers.MVNO_TYPE, // 20
- Telephony.Carriers.MVNO_MATCH_DATA, // 21
- Telephony.Carriers.EDITED_STATUS, // 22
- Telephony.Carriers.USER_EDITABLE, // 23
- Telephony.Carriers.CARRIER_ID // 24
+ Telephony.Carriers.MMSPROXY, // 9
+ Telephony.Carriers.MMSPORT, // 10
+ Telephony.Carriers.AUTH_TYPE, // 11
+ Telephony.Carriers.TYPE, // 12
+ Telephony.Carriers.PROTOCOL, // 13
+ Telephony.Carriers.CARRIER_ENABLED, // 14
+ Telephony.Carriers.NETWORK_TYPE_BITMASK, // 15
+ Telephony.Carriers.ROAMING_PROTOCOL, // 16
+ Telephony.Carriers.EDITED_STATUS, // 17
+ Telephony.Carriers.USER_EDITABLE, // 18
+ Telephony.Carriers.CARRIER_ID // 19
)
const val TAG = "ApnRepository"
@@ -87,7 +78,6 @@
var apnData = ApnData()
val contentResolver = context.contentResolver
val apnProtocolOptions = context.resources.getStringArray(R.array.apn_protocol_entries).toList()
- val mvnoTypeOptions = context.resources.getStringArray(R.array.mvno_type_entries).toList()
contentResolver.query(
uri,
@@ -105,8 +95,6 @@
val server = cursor.getString(SERVER_INDEX)
val passWord = cursor.getString(PASSWORD_INDEX)
val mmsc = cursor.getString(MMSC_INDEX)
- val mcc = cursor.getString(MCC_INDEX)
- val mnc = cursor.getString(MNC_INDEX)
val mmsProxy = cursor.getString(MMSPROXY_INDEX)
val mmsPort = cursor.getString(MMSPORT_INDEX)
val authType = cursor.getInt(AUTH_TYPE_INDEX)
@@ -116,8 +104,6 @@
convertProtocol2Options(cursor.getString(ROAMING_PROTOCOL_INDEX), context)
val apnEnable = cursor.getInt(CARRIER_ENABLED_INDEX) == 1
val networkType = cursor.getLong(NETWORK_TYPE_INDEX)
- val mvnoType = cursor.getString(MVNO_TYPE_INDEX)
- val mvnoValue = cursor.getString(MVNO_MATCH_DATA_INDEX)
val edited = cursor.getInt(EDITED_INDEX)
val userEditable = cursor.getInt(USER_EDITABLE_INDEX)
@@ -134,16 +120,12 @@
mmsc = mmsc,
mmsProxy = mmsProxy,
mmsPort = mmsPort,
- mcc = mcc,
- mnc = mnc,
authType = authType,
apnType = apnType,
apnProtocol = apnProtocolOptions.indexOf(apnProtocol),
apnRoaming = apnProtocolOptions.indexOf(apnRoaming),
apnEnable = apnEnable,
networkType = networkType,
- mvnoType = mvnoTypeOptions.indexOf(mvnoType),
- mvnoValue = mvnoValue,
edited = edited,
userEditable = userEditable,
carrierId = carrierId
diff --git a/src/com/android/settings/network/apn/ApnStatus.kt b/src/com/android/settings/network/apn/ApnStatus.kt
index ac9f28b..304658e 100644
--- a/src/com/android/settings/network/apn/ApnStatus.kt
+++ b/src/com/android/settings/network/apn/ApnStatus.kt
@@ -38,16 +38,12 @@
val mmsc: String = "",
val mmsProxy: String = "",
val mmsPort: String = "",
- val mcc: String = "",
- val mnc: String = "",
val authType: Int = -1,
val apnType: String = "",
val apnProtocol: Int = -1,
val apnRoaming: Int = -1,
val apnEnable: Boolean = true,
val networkType: Long = 0,
- val mvnoType: Int = -1,
- var mvnoValue: String = "",
val edited: Int = Telephony.Carriers.USER_EDITED,
val userEditable: Int = 1,
val carrierId: Int = TelephonyManager.UNKNOWN_CARRIER_ID,
@@ -61,17 +57,15 @@
val mmscEnabled: Boolean = true,
val mmsProxyEnabled: Boolean = true,
val mmsPortEnabled: Boolean = true,
- val mccEnabled: Boolean = true,
- val mncEnabled: Boolean = true,
val authTypeEnabled: Boolean = true,
val apnTypeEnabled: Boolean = true,
val apnProtocolEnabled: Boolean = true,
val apnRoamingEnabled: Boolean = true,
val apnEnableEnabled: Boolean = true,
val networkTypeEnabled: Boolean = true,
- val mvnoTypeEnabled: Boolean = true,
- val mvnoValueEnabled: Boolean = false,
val newApn: Boolean = false,
+ val subId: Int = -1,
+ val customizedConfig: CustomizedConfig = CustomizedConfig()
)
data class CustomizedConfig(
@@ -96,13 +90,6 @@
fun getApnDataInit(arguments: Bundle, context: Context, uriInit: Uri, subId: Int): ApnData {
val uriType = arguments.getString(URI_TYPE)!!
- val mvnoType = arguments.getString(MVNO_TYPE)
- val mvnoValue = arguments.getString(MVNO_MATCH_DATA)
- val mvnoTypeOptions = context.resources.getStringArray(R.array.mvno_type_entries).toList()
-
- val configManager =
- context.getSystemService(Context.CARRIER_CONFIG_SERVICE) as CarrierConfigManager
- getCarrierCustomizedConfig(configManager, subId)
if (!uriInit.isPathPrefixMatch(Telephony.Carriers.CONTENT_URI)) {
Log.e(TAG, "Insert request not for carrier table. Uri: $uriInit")
@@ -111,19 +98,20 @@
var apnDataInit = when (uriType) {
EDIT_URL -> getApnDataFromUri(uriInit, context)
- INSERT_URL -> ApnData(
- mvnoType = mvnoTypeOptions.indexOf(mvnoType!!),
- mvnoValue = mvnoValue!!
- )
-
+ INSERT_URL -> ApnData()
else -> ApnData() //TODO: finish
}
+ apnDataInit = apnDataInit.copy(subId = subId)
+ val configManager =
+ context.getSystemService(Context.CARRIER_CONFIG_SERVICE) as CarrierConfigManager
+ apnDataInit =
+ apnDataInit.copy(customizedConfig = getCarrierCustomizedConfig(apnDataInit, configManager))
+
if (uriType == INSERT_URL) {
apnDataInit = apnDataInit.copy(newApn = true)
}
- // TODO: mvnoDescription
apnDataInit = apnDataInit.copy(
apnEnableEnabled =
context.resources.getBoolean(R.bool.config_allow_edit_carrier_enabled)
@@ -138,9 +126,12 @@
*
* @return Initialized CustomizedConfig information.
*/
-fun getCarrierCustomizedConfig(configManager: CarrierConfigManager, subId: Int): CustomizedConfig {
+fun getCarrierCustomizedConfig(
+ apnInit: ApnData,
+ configManager: CarrierConfigManager
+): CustomizedConfig {
val b = configManager.getConfigForSubId(
- subId,
+ apnInit.subId,
CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY,
CarrierConfigManager.KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY,
CarrierConfigManager.KEY_APN_SETTINGS_DEFAULT_APN_TYPES_STRING_ARRAY,
diff --git a/tests/spa_unit/src/com/android/settings/network/apn/ApnEditPageProviderTest.kt b/tests/spa_unit/src/com/android/settings/network/apn/ApnEditPageProviderTest.kt
index 8d1b223..7cd0f5d 100644
--- a/tests/spa_unit/src/com/android/settings/network/apn/ApnEditPageProviderTest.kt
+++ b/tests/spa_unit/src/com/android/settings/network/apn/ApnEditPageProviderTest.kt
@@ -51,7 +51,6 @@
private val apnName = "apn_name"
private val mmsc = "mmsc"
private val mmsProxy = "mms_proxy"
- private val mnc = "mnc"
private val apnType = "apn_type"
private val apnRoaming = "IPv4"
private val apnEnable = context.resources.getString(R.string.carrier_enabled)
@@ -64,7 +63,6 @@
name = apnName,
mmsc = mmsc,
mmsProxy = mmsProxy,
- mnc = mnc,
apnType = apnType,
apnRoaming = apnProtocolOptions.indexOf(apnRoaming),
apnEnable = true
@@ -121,18 +119,6 @@
}
@Test
- fun mnc_displayed() {
- composeTestRule.setContent {
- ApnPage(remember {
- apnData
- })
- }
- composeTestRule.onRoot().onChild().onChildAt(0)
- .performScrollToNode(hasText(mnc, true))
- composeTestRule.onNodeWithText(mnc, true).assertIsDisplayed()
- }
-
- @Test
fun apn_type_displayed() {
composeTestRule.setContent {
ApnPage(remember {
diff --git a/tests/spa_unit/src/com/android/settings/network/apn/ApnRepositoryTest.kt b/tests/spa_unit/src/com/android/settings/network/apn/ApnRepositoryTest.kt
index 47f2a7f..44ec926 100644
--- a/tests/spa_unit/src/com/android/settings/network/apn/ApnRepositoryTest.kt
+++ b/tests/spa_unit/src/com/android/settings/network/apn/ApnRepositoryTest.kt
@@ -41,10 +41,26 @@
val cursor = MatrixCursor(sProjection)
cursor.addRow(
arrayOf<Any?>(
- 0, "name", "apn", "proxy", "port",
- "userName", "server", "passWord", "mmsc", "mcc", "mnc", "numeric",
- "mmsProxy", "mmsPort", 0, "apnType", "apnProtocol", 0,
- 0, "apnRoaming", "mvnoType", "mvnoValue", 0, 1, 0
+ 0,
+ "name",
+ "apn",
+ "proxy",
+ "port",
+ "userName",
+ "server",
+ "passWord",
+ "mmsc",
+ "mmsProxy",
+ "mmsPort",
+ 0,
+ "apnType",
+ "apnProtocol",
+ 0,
+ 0,
+ "apnRoaming",
+ 0,
+ 1,
+ 0
)
)
val context = Mockito.spy(context)
diff --git a/tests/spa_unit/src/com/android/settings/network/apn/ApnStatusTest.kt b/tests/spa_unit/src/com/android/settings/network/apn/ApnStatusTest.kt
index e590c28..539783c 100644
--- a/tests/spa_unit/src/com/android/settings/network/apn/ApnStatusTest.kt
+++ b/tests/spa_unit/src/com/android/settings/network/apn/ApnStatusTest.kt
@@ -26,13 +26,17 @@
@RunWith(AndroidJUnit4::class)
class ApnStatusTest {
- private val subId = 1
+ private val apnData = mock<ApnData> {
+ on {
+ it.subId
+ } doReturn 1
+ }
private val configManager = mock<CarrierConfigManager> {
val p = PersistableBundle()
p.putBoolean(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL, true)
on {
getConfigForSubId(
- subId,
+ apnData.subId,
CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY,
CarrierConfigManager.KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY,
CarrierConfigManager.KEY_APN_SETTINGS_DEFAULT_APN_TYPES_STRING_ARRAY,
@@ -45,6 +49,6 @@
@Test
fun getCarrierCustomizedConfig_test() {
- assert(getCarrierCustomizedConfig(configManager, subId).isAddApnAllowed)
+ assert(getCarrierCustomizedConfig(apnData, configManager).isAddApnAllowed)
}
}
\ No newline at end of file