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:
Antony Sargent
2019-04-09 09:49:57 -07:00
parent 81f31ef4d3
commit f5bc241627
5 changed files with 22 additions and 11 deletions

View File

@@ -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;
@@ -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;
@@ -52,6 +53,8 @@ import androidx.preference.PreferenceScreen;
@RunWith(RobolectricTestRunner.class)
public class MobileNetworkListControllerTest {
@Mock
TelephonyManager mTelephonyManager;
@Mock
EuiccManager mEuiccManager;
@@ -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(
@@ -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();

View File

@@ -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;
@@ -59,6 +60,8 @@ public class MobileNetworkSummaryControllerTest {
@Mock
private Lifecycle mLifecycle;
@Mock
private TelephonyManager mTelephonyManager;
@Mock
private EuiccManager mEuiccManager;
@Mock
private PreferenceScreen mPreferenceScreen;
@@ -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));