Merge "Telephony.Carriers.MVNO_TYPE is Deprecated." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
f062d1cd6e
@@ -47,8 +47,6 @@ import java.util.Base64
|
||||
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 @@ object ApnEditPageProvider : SettingsPageProvider {
|
||||
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 @@ object ApnEditPageProvider : SettingsPageProvider {
|
||||
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 @@ fun ApnPage(apnDataCur: MutableState<ApnData>) {
|
||||
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 @@ fun ApnPage(apnDataCur: MutableState<ApnData>) {
|
||||
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 @@ fun ApnPage(apnDataCur: MutableState<ApnData>) {
|
||||
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) }
|
||||
}
|
||||
}
|
||||
}
|
@@ -157,7 +157,7 @@ public class ApnPreference extends Preference
|
||||
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);
|
||||
|
@@ -31,21 +31,17 @@ const val USER_INDEX = 5
|
||||
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 @@ val sProjection = arrayOf(
|
||||
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 @@ fun getApnDataFromUri(uri: Uri, context: Context): ApnData {
|
||||
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 @@ fun getApnDataFromUri(uri: Uri, context: Context): ApnData {
|
||||
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 @@ fun getApnDataFromUri(uri: Uri, context: Context): ApnData {
|
||||
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 @@ fun getApnDataFromUri(uri: Uri, context: Context): ApnData {
|
||||
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
|
||||
|
@@ -38,16 +38,12 @@ data class ApnData(
|
||||
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 @@ data class ApnData(
|
||||
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 @@ data class CustomizedConfig(
|
||||
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 @@ fun getApnDataInit(arguments: Bundle, context: Context, uriInit: Uri, subId: Int
|
||||
|
||||
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 @@ fun getApnDataInit(arguments: Bundle, context: Context, uriInit: Uri, subId: Int
|
||||
*
|
||||
* @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,
|
||||
|
@@ -51,7 +51,6 @@ class ApnEditPageProviderTest {
|
||||
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 @@ class ApnEditPageProviderTest {
|
||||
name = apnName,
|
||||
mmsc = mmsc,
|
||||
mmsProxy = mmsProxy,
|
||||
mnc = mnc,
|
||||
apnType = apnType,
|
||||
apnRoaming = apnProtocolOptions.indexOf(apnRoaming),
|
||||
apnEnable = true
|
||||
@@ -120,18 +118,6 @@ class ApnEditPageProviderTest {
|
||||
composeTestRule.onNodeWithText(mmsProxy, true).assertIsDisplayed()
|
||||
}
|
||||
|
||||
@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 {
|
||||
|
@@ -41,10 +41,26 @@ class ApnRepositoryTest {
|
||||
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)
|
||||
|
@@ -26,13 +26,17 @@ import org.mockito.kotlin.mock
|
||||
|
||||
@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 @@ class ApnStatusTest {
|
||||
|
||||
@Test
|
||||
fun getCarrierCustomizedConfig_test() {
|
||||
assert(getCarrierCustomizedConfig(configManager, subId).isAddApnAllowed)
|
||||
assert(getCarrierCustomizedConfig(apnData, configManager).isAddApnAllowed)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user