[Settings] Replace isImsRegistered

Replace isImsReigstered() by callback from ImsMmTelManager.

Bug: 140542283
Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=SimStatusDialogControllerTest
Merged-In: I904da749df7074918d205ebd004a173ed109c561
Change-Id: I193805ef947636e50bb21d273be15361378d8f8a
This commit is contained in:
Bonian Chen
2020-02-06 02:55:42 +08:00
committed by SongFerngWang
parent 28c11a8c01
commit a0b4ca3684
2 changed files with 106 additions and 41 deletions

View File

@@ -43,6 +43,7 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
import android.content.Context;
import android.content.pm.PackageInfo;
@@ -80,6 +81,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowPackageManager;
import org.robolectric.shadows.ShadowTelephonyManager;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
@@ -93,7 +95,6 @@ public class SimStatusDialogControllerTest {
@Mock
private SimStatusDialogFragment mDialog;
@Mock
private TelephonyManager mTelephonyManager;
@Mock
private SubscriptionInfo mSubscriptionInfo;
@@ -115,7 +116,6 @@ public class SimStatusDialogControllerTest {
private PersistableBundle mPersistableBundle;
@Mock
private EuiccManager mEuiccManager;
@Mock
private SubscriptionManager mSubscriptionManager;
private SimStatusDialogController mController;
@@ -131,10 +131,22 @@ public class SimStatusDialogControllerTest {
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mContext = spy(RuntimeEnvironment.application);
when(mDialog.getContext()).thenReturn(mContext);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mSubscriptionManager = spy(mContext.getSystemService(SubscriptionManager.class));
mTelephonyManager = spy(mContext.getSystemService(TelephonyManager.class));
final ShadowTelephonyManager shadowTelephonyMgr = shadowOf(mTelephonyManager);
shadowTelephonyMgr.setTelephonyManagerForSubscriptionId(
SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mTelephonyManager);
doReturn(2).when(mTelephonyManager).getCardIdForDefaultEuicc();
doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mTelephonyManager).getDataNetworkType();
doReturn(mEuiccManager).when(mContext).getSystemService(EuiccManager.class);
mController = spy(new SimStatusDialogController(mDialog, mLifecycle, 0 /* phone id */));
ShadowDeviceInfoUtils.setPhoneNumber("");
//CellSignalStrength setup
@@ -156,9 +168,9 @@ public class SimStatusDialogControllerTest {
ReflectionHelpers.setField(mController, "mSubscriptionManager", mSubscriptionManager);
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
when(mTelephonyManager.getUiccCardsInfo()).thenReturn(new ArrayList<UiccCardInfo>());
when(mTelephonyManager.getLogicalToPhysicalSlotMapping()).thenReturn(
new HashMap<Integer, Integer>());
doReturn(new ArrayList<UiccCardInfo>()).when(mTelephonyManager).getUiccCardsInfo();
doReturn(new HashMap<Integer, Integer>()).when(mTelephonyManager)
.getLogicalToPhysicalSlotMapping();
when(mEuiccManager.isEnabled()).thenReturn(false);
when(mEuiccManager.getEid()).thenReturn("");
@@ -168,7 +180,6 @@ public class SimStatusDialogControllerTest {
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
.thenReturn(true);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
doReturn(mServiceState).when(mTelephonyManager).getServiceState();
doReturn(mSignalStrength).when(mTelephonyManager).getSignalStrength();
@@ -185,7 +196,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateNetworkProviderWithFoobarCarrier_shouldUpdateCarrierWithFoobar() {
final CharSequence carrierName = "foobar";
doReturn(carrierName).when(mSubscriptionInfo).getCarrierName();
@@ -196,7 +206,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updatePhoneNumberWith1111111111_shouldUpdatePhoneNumber() {
ShadowDeviceInfoUtils.setPhoneNumber("1111111111");
@@ -209,7 +218,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateLatestAreaInfoWithCdmaPhone_shouldRemoveOperatorInfoSetting() {
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
@@ -220,7 +228,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateServiceStateWithInService_shouldUpdateTextToBeCInService() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -231,7 +238,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateServiceStateWithPowerOff_shouldUpdateTextAndResetSignalStrength() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_POWER_OFF);
when(mPersistableBundle.getBoolean(
@@ -245,7 +251,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateVoiceDataOutOfService_shouldUpdateSettingAndResetSignalStrength() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
when(mServiceState.getDataRegistrationState()).thenReturn(
@@ -261,7 +266,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateTextToBeInService() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -275,7 +279,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateSignalStrengthWithLte50Wcdma40_shouldUpdateSignalStrengthTo50() {
final int lteDbm = 50;
final int lteAsu = 50;
@@ -293,7 +296,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateSignalStrengthWithLte50Cdma30_shouldUpdateSignalStrengthTo50() {
final int lteDbm = 50;
final int lteAsu = 50;
@@ -311,7 +313,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateSignalStrengthTo50() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -332,7 +333,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateVoiceNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
when(mTelephonyManager.getVoiceNetworkType()).thenReturn(
TelephonyManager.NETWORK_TYPE_EDGE);
@@ -344,7 +344,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateDataNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
when(mTelephonyManager.getDataNetworkType()).thenReturn(
TelephonyManager.NETWORK_TYPE_EDGE);
@@ -356,7 +355,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateRoamingStatusIsRoaming_shouldSetSettingToRoaming() {
when(mServiceState.getRoaming()).thenReturn(true);
@@ -367,7 +365,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_updateRoamingStatusNotRoaming_shouldSetSettingToRoamingOff() {
when(mServiceState.getRoaming()).thenReturn(false);
@@ -378,7 +375,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_doNotShowIccid_shouldRemoveIccidSetting() {
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL)).thenReturn(false);
@@ -390,7 +386,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_doNotShowSignalStrength_shouldRemoveSignalStrengthSetting() {
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
@@ -403,7 +398,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_showSignalStrengthAndIccId_shouldShowSignalStrengthAndIccIdSetting() {
// getConfigForSubId is nullable, so make sure the default behavior is correct
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(null);
@@ -416,7 +410,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_showIccid_shouldSetIccidToSetting() {
final String iccid = "12351351231241";
when(mPersistableBundle.getBoolean(
@@ -755,7 +748,6 @@ public class SimStatusDialogControllerTest {
}
@Test
@Ignore
public void initialize_nullSignalStrength_noCrash() {
doReturn(null).when(mTelephonyManager).getSignalStrength();
// we should not crash when running the following line