Use helper method for determining whether eSIM is supported
It turns out to be more complicated than I had thought to determine if a device should be considered to support eSIM. But the good news is that we already had a helper method for this - this CL switches to using it in some code for DSDS UI. Fixes: 129061243 Test: make RunSettingsRoboTests Change-Id: I41e500eb70b6c6b725c0ddf09fe1ca1a69df4563
This commit is contained in:
@@ -24,12 +24,12 @@ import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.euicc.EuiccManager;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.telephony.MobileNetworkActivity;
|
||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -81,8 +81,8 @@ public class MobileNetworkListController extends AbstractPreferenceController im
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreferenceScreen = screen;
|
||||
final EuiccManager euiccManager = mContext.getSystemService(EuiccManager.class);
|
||||
mPreferenceScreen.findPreference(KEY_ADD_MORE).setVisible(euiccManager.isEnabled());
|
||||
mPreferenceScreen.findPreference(KEY_ADD_MORE).setVisible(
|
||||
MobileNetworkUtils.showEuiccSettings(mContext));
|
||||
update();
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,7 @@ import android.telephony.euicc.EuiccManager;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.network.telephony.MobileNetworkActivity;
|
||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||
import com.android.settings.widget.AddPreference;
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -49,7 +50,6 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private SubscriptionsChangeListener mChangeListener;
|
||||
private EuiccManager mEuiccManager;
|
||||
private AddPreference mPreference;
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,6 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
public MobileNetworkSummaryController(Context context, Lifecycle lifecycle) {
|
||||
super(context);
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
mEuiccManager = mContext.getSystemService(EuiccManager.class);
|
||||
if (lifecycle != null) {
|
||||
mChangeListener = new SubscriptionsChangeListener(context, this);
|
||||
lifecycle.addObserver(this);
|
||||
@@ -99,7 +98,7 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(
|
||||
mSubscriptionManager);
|
||||
if (subs.isEmpty()) {
|
||||
if (mEuiccManager.isEnabled()) {
|
||||
if (MobileNetworkUtils.showEuiccSettings(mContext)) {
|
||||
return mContext.getResources().getString(
|
||||
R.string.mobile_network_summary_add_a_network);
|
||||
}
|
||||
@@ -133,7 +132,7 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
mSubscriptionManager);
|
||||
|
||||
if (subs.isEmpty()) {
|
||||
if (mEuiccManager.isEnabled()) {
|
||||
if (MobileNetworkUtils.showEuiccSettings(mContext)) {
|
||||
mPreference.setOnPreferenceClickListener((Preference pref) -> {
|
||||
startAddSimFlow();
|
||||
return true;
|
||||
@@ -142,7 +141,7 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
} else {
|
||||
// We have one or more existing subscriptions, so we want the plus button if eSIM is
|
||||
// supported.
|
||||
if (mEuiccManager.isEnabled()) {
|
||||
if (MobileNetworkUtils.showEuiccSettings(mContext)) {
|
||||
mPreference.setAddWidgetEnabled(!mChangeListener.isAirplaneModeOn());
|
||||
mPreference.setOnAddClickListener(p -> startAddSimFlow());
|
||||
}
|
||||
|
@@ -177,7 +177,7 @@ public class MobileNetworkUtils {
|
||||
*/
|
||||
public static boolean showEuiccSettings(Context context) {
|
||||
EuiccManager euiccManager =
|
||||
(EuiccManager) context.getSystemService(Context.EUICC_SERVICE);
|
||||
(EuiccManager) context.getSystemService(EuiccManager.class);
|
||||
if (!euiccManager.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ public class MobileNetworkUtils {
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
|
||||
TelephonyManager tm =
|
||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
(TelephonyManager) context.getSystemService(TelephonyManager.class);
|
||||
String currentCountry = tm.getNetworkCountryIso().toLowerCase();
|
||||
String supportedCountries =
|
||||
Settings.Global.getString(cr, Settings.Global.EUICC_SUPPORTED_COUNTRIES);
|
||||
|
Reference in New Issue
Block a user