Match APN types with ignoring the case

Currently APN types which are set on ApnEditor are compared with the
types which are configured with read_only_apn_types_string_array in a
case-sensitive manner. So upper case types such as "DUN" or "IMS" can be
set if read_only_apn_types_string_array is configured as "dun" or "ims."
Then the APN with types such as "DUN" or "IMS" can be added and may be
used for the network connection unintentionally.

This patch compares APN types with ignoring the case on ApnEditor to
prevent the problem above.

Bug: 200194310
Test: Manual test passed
Change-Id: I0f68bf470699df388855ec7277c0cfc24a2c30ba
This commit is contained in:
Hideki Ishii
2020-04-08 17:10:53 +08:00
committed by Takeshi Tanigawa
parent 24db817a65
commit 8bce735fa0

View File

@@ -429,15 +429,20 @@ public class ApnEditor extends SettingsPreferenceFragment
return false;
}
if (hasAllApns(apnTypesArray1) || TextUtils.isEmpty(apnTypes2)) {
final String[] apnTypesArray1LowerCase = new String[apnTypesArray1.length];
for (int i = 0; i < apnTypesArray1.length; i++) {
apnTypesArray1LowerCase[i] = apnTypesArray1[i].toLowerCase();
}
if (hasAllApns(apnTypesArray1LowerCase) || TextUtils.isEmpty(apnTypes2)) {
return true;
}
final List apnTypesList1 = Arrays.asList(apnTypesArray1);
final List apnTypesList1 = Arrays.asList(apnTypesArray1LowerCase);
final String[] apnTypesArray2 = apnTypes2.split(",");
for (String apn : apnTypesArray2) {
if (apnTypesList1.contains(apn.trim())) {
if (apnTypesList1.contains(apn.trim().toLowerCase())) {
Log.d(TAG, "apnTypesMatch: true because match found for " + apn.trim());
return true;
}