From 396e2fd7d8443550ea790a5f5eedfb0ad5108721 Mon Sep 17 00:00:00 2001 From: Muralidhar Reddy Date: Wed, 1 Jun 2022 04:45:21 +0000 Subject: [PATCH] Adding eSIM option is not disabled if the current country is not in the allowed list When both stack 1(pSIM) and stack 2(eSIM) are not available, stack 1 starts for emergency calls only. For eSIM, modem keeps on stopped state due to power consumption concern which is as per DSDS design. Modified the logic to not call platform API if the countryCode is empty. Bug: 231952356 Test: 1) Manually verified on C10P10 and Pixel 4a Device and eSIM option is enabled. 2) Modified not allowed country list and verified the eSIM option is disabled. Change-Id: I99750f80fb2e2e180950b743ecbbbcb7a912528f --- .../network/telephony/MobileNetworkUtils.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java index 839a98cdb32..e769a4eed7d 100644 --- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java +++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java @@ -85,7 +85,9 @@ import com.android.settingslib.graph.SignalDrawable; import com.android.settingslib.utils.ThreadUtils; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -711,15 +713,17 @@ public class MobileNetworkUtils { final TelephonyManager tm = (TelephonyManager) context.getSystemService(TelephonyManager.class); + Set countrySet = new HashSet<>(); for (int i = 0; i < tm.getPhoneCount(); i++) { String countryCode = tm.getNetworkCountryIso(i); - if (em.isSupportedCountry(countryCode)) { - Log.i(TAG, "isCurrentCountrySupported: eSIM is supported in " + countryCode); - return true; + if (!TextUtils.isEmpty(countryCode)) { + countrySet.add(countryCode); } } - Log.i(TAG, "isCurrentCountrySupported: eSIM is not supported in the current country."); - return false; + boolean isSupported = countrySet.stream().anyMatch(em::isSupportedCountry); + Log.i(TAG, "isCurrentCountrySupported countryCodes: " + countrySet + + " eSIMSupported: " + isSupported); + return isSupported; } /**