Loading src/com/android/settings/network/MobileNetworkListController.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); } Loading src/com/android/settings/network/MobileNetworkSummaryController.java +4 −5 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -49,7 +50,6 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController private SubscriptionManager mSubscriptionManager; private SubscriptionsChangeListener mChangeListener; private EuiccManager mEuiccManager; private AddPreference mPreference; /** Loading @@ -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); Loading Loading @@ -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); } Loading Loading @@ -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; Loading @@ -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()); } Loading src/com/android/settings/network/telephony/MobileNetworkUtils.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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); Loading tests/robotests/src/com/android/settings/network/MobileNetworkListControllerTest.java +7 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; Loading @@ -31,7 +30,9 @@ import static org.mockito.Mockito.when; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.TelephonyManager; import android.telephony.euicc.EuiccManager; import org.junit.After; Loading @@ -52,6 +53,8 @@ import androidx.preference.PreferenceScreen; @RunWith(RobolectricTestRunner.class) public class MobileNetworkListControllerTest { @Mock TelephonyManager mTelephonyManager; @Mock EuiccManager mEuiccManager; Loading @@ -69,7 +72,9 @@ public class MobileNetworkListControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(Robolectric.setupActivity(Activity.class)); when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager); when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.EUICC_PROVISIONED, 1); when(mPreferenceScreen.getContext()).thenReturn(mContext); mAddMorePreference = new Preference(mContext); when(mPreferenceScreen.findPreference(MobileNetworkListController.KEY_ADD_MORE)).thenReturn( Loading Loading @@ -99,6 +104,7 @@ public class MobileNetworkListControllerTest { @Test public void displayPreference_eSimSupported_addMoreLinkIsVisible() { when(mEuiccManager.isEnabled()).thenReturn(true); when(mTelephonyManager.getNetworkCountryIso()).thenReturn(""); mController.displayPreference(mPreferenceScreen); mController.onResume(); assertThat(mAddMorePreference.isVisible()).isTrue(); Loading tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.Intent; import android.net.ConnectivityManager; import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.TelephonyManager; import android.telephony.euicc.EuiccManager; import android.text.TextUtils; Loading @@ -59,6 +60,8 @@ public class MobileNetworkSummaryControllerTest { @Mock private Lifecycle mLifecycle; @Mock private TelephonyManager mTelephonyManager; @Mock private EuiccManager mEuiccManager; @Mock private PreferenceScreen mPreferenceScreen; Loading @@ -71,8 +74,11 @@ public class MobileNetworkSummaryControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(Robolectric.setupActivity(Activity.class)); when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager); when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager); when(mTelephonyManager.getNetworkCountryIso()).thenReturn(""); when(mEuiccManager.isEnabled()).thenReturn(true); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.EUICC_PROVISIONED, 1); mController = new MobileNetworkSummaryController(mContext, mLifecycle); mPreference = spy(new AddPreference(mContext, null)); Loading Loading
src/com/android/settings/network/MobileNetworkListController.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); } Loading
src/com/android/settings/network/MobileNetworkSummaryController.java +4 −5 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -49,7 +50,6 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController private SubscriptionManager mSubscriptionManager; private SubscriptionsChangeListener mChangeListener; private EuiccManager mEuiccManager; private AddPreference mPreference; /** Loading @@ -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); Loading Loading @@ -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); } Loading Loading @@ -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; Loading @@ -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()); } Loading
src/com/android/settings/network/telephony/MobileNetworkUtils.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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); Loading
tests/robotests/src/com/android/settings/network/MobileNetworkListControllerTest.java +7 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; Loading @@ -31,7 +30,9 @@ import static org.mockito.Mockito.when; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.TelephonyManager; import android.telephony.euicc.EuiccManager; import org.junit.After; Loading @@ -52,6 +53,8 @@ import androidx.preference.PreferenceScreen; @RunWith(RobolectricTestRunner.class) public class MobileNetworkListControllerTest { @Mock TelephonyManager mTelephonyManager; @Mock EuiccManager mEuiccManager; Loading @@ -69,7 +72,9 @@ public class MobileNetworkListControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(Robolectric.setupActivity(Activity.class)); when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager); when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.EUICC_PROVISIONED, 1); when(mPreferenceScreen.getContext()).thenReturn(mContext); mAddMorePreference = new Preference(mContext); when(mPreferenceScreen.findPreference(MobileNetworkListController.KEY_ADD_MORE)).thenReturn( Loading Loading @@ -99,6 +104,7 @@ public class MobileNetworkListControllerTest { @Test public void displayPreference_eSimSupported_addMoreLinkIsVisible() { when(mEuiccManager.isEnabled()).thenReturn(true); when(mTelephonyManager.getNetworkCountryIso()).thenReturn(""); mController.displayPreference(mPreferenceScreen); mController.onResume(); assertThat(mAddMorePreference.isVisible()).isTrue(); Loading
tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.Intent; import android.net.ConnectivityManager; import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.TelephonyManager; import android.telephony.euicc.EuiccManager; import android.text.TextUtils; Loading @@ -59,6 +60,8 @@ public class MobileNetworkSummaryControllerTest { @Mock private Lifecycle mLifecycle; @Mock private TelephonyManager mTelephonyManager; @Mock private EuiccManager mEuiccManager; @Mock private PreferenceScreen mPreferenceScreen; Loading @@ -71,8 +74,11 @@ public class MobileNetworkSummaryControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(Robolectric.setupActivity(Activity.class)); when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager); when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager); when(mTelephonyManager.getNetworkCountryIso()).thenReturn(""); when(mEuiccManager.isEnabled()).thenReturn(true); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.EUICC_PROVISIONED, 1); mController = new MobileNetworkSummaryController(mContext, mLifecycle); mPreference = spy(new AddPreference(mContext, null)); Loading