[DO NOT MERGE] Add country blacklist support
Adding a country blacklist, except for pixel2(walleye, taimen) will still uses whitelist
Bug: 144702079
Test: manually tested
(cherry picked from commit 3844ba12596bd518bc7af6df50a1dc1c0c328fa4)
Change-Id: I4133e38ba2a979dc0bff4ca5090004ccc9f7a757
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index cd4489d..9823d6f 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -226,16 +226,23 @@
final String currentCountry = tm.getNetworkCountryIso().toLowerCase();
final String supportedCountries =
Settings.Global.getString(cr, Settings.Global.EUICC_SUPPORTED_COUNTRIES);
+ final String unsupportedCountries =
+ Settings.Global.getString(cr, Settings.Global.EUICC_UNSUPPORTED_COUNTRIES);
+
boolean inEsimSupportedCountries = false;
- if (TextUtils.isEmpty(currentCountry)) {
- inEsimSupportedCountries = true;
- } else if (!TextUtils.isEmpty(supportedCountries)) {
- final List<String> supportedCountryList =
- Arrays.asList(TextUtils.split(supportedCountries.toLowerCase(), ","));
- if (supportedCountryList.contains(currentCountry)) {
- inEsimSupportedCountries = true;
- }
+
+ if (TextUtils.isEmpty(supportedCountries)) {
+ // White list is empty, use blacklist.
+ Log.d(TAG, "Using blacklist unsupportedCountries=" + unsupportedCountries);
+ inEsimSupportedCountries = !isEsimUnsupportedCountry(currentCountry,
+ unsupportedCountries);
+ } else {
+ Log.d(TAG, "Using whitelist supportedCountries=" + supportedCountries);
+ inEsimSupportedCountries = isEsimSupportedCountry(currentCountry, supportedCountries);
}
+
+ Log.d(TAG, "inEsimSupportedCountries=" + inEsimSupportedCountries);
+
final boolean esimIgnoredDevice =
Arrays.asList(TextUtils.split(SystemProperties.get(KEY_ESIM_CID_IGNORE, ""), ","))
.contains(SystemProperties.get(KEY_CID, null));
@@ -611,4 +618,24 @@
}
return tm.getNetworkOperatorName();
}
+
+ private static boolean isEsimSupportedCountry(String country, String countriesListString) {
+ if (TextUtils.isEmpty(country)) {
+ return true;
+ } else if (TextUtils.isEmpty(countriesListString)) {
+ return false;
+ }
+ final List<String> supportedCountries =
+ Arrays.asList(TextUtils.split(countriesListString.toLowerCase(), ","));
+ return supportedCountries.contains(country);
+ }
+
+ private static boolean isEsimUnsupportedCountry(String country, String countriesListString) {
+ if (TextUtils.isEmpty(country) || TextUtils.isEmpty(countriesListString)) {
+ return false;
+ }
+ final List<String> unsupportedCountries =
+ Arrays.asList(TextUtils.split(countriesListString.toLowerCase(), ","));
+ return unsupportedCountries.contains(country);
+ }
}