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
diff --git a/src/com/android/settings/network/apn/ApnEditor.java b/src/com/android/settings/network/apn/ApnEditor.java
index 25d8e84..a66a33f 100644
--- a/src/com/android/settings/network/apn/ApnEditor.java
+++ b/src/com/android/settings/network/apn/ApnEditor.java
@@ -429,15 +429,20 @@
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;
}