Merge changes I193805ef,I2e1b9ac5

* changes:
  [Settings] Replace isImsRegistered
  Remove reference to PhoneConstant.
This commit is contained in:
Treehugger Robot
2020-03-03 10:15:27 +00:00
committed by Gerrit Code Review
2 changed files with 123 additions and 58 deletions

View File

@@ -27,6 +27,7 @@ import android.content.res.Resources;
import android.os.IBinder; import android.os.IBinder;
import android.os.PersistableBundle; import android.os.PersistableBundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.telephony.AccessNetworkConstants;
import android.telephony.Annotation; import android.telephony.Annotation;
import android.telephony.CarrierConfigManager; import android.telephony.CarrierConfigManager;
import android.telephony.CellBroadcastIntents; import android.telephony.CellBroadcastIntents;
@@ -42,13 +43,15 @@ import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.telephony.UiccCardInfo; import android.telephony.UiccCardInfo;
import android.telephony.euicc.EuiccManager; import android.telephony.euicc.EuiccManager;
import android.telephony.ims.ImsException;
import android.telephony.ims.ImsMmTelManager;
import android.telephony.ims.ImsReasonInfo;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import com.android.internal.telephony.PhoneConstants;
import com.android.settings.R; import com.android.settings.R;
import com.android.settingslib.DeviceInfoUtils; import com.android.settingslib.DeviceInfoUtils;
import com.android.settingslib.Utils; import com.android.settingslib.Utils;
@@ -101,15 +104,34 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
@VisibleForTesting @VisibleForTesting
final static int IMS_REGISTRATION_STATE_VALUE_ID = R.id.ims_reg_state_value; final static int IMS_REGISTRATION_STATE_VALUE_ID = R.id.ims_reg_state_value;
@VisibleForTesting
static final int MAX_PHONE_COUNT_SINGLE_SIM = 1;
private final OnSubscriptionsChangedListener mOnSubscriptionsChangedListener = private final OnSubscriptionsChangedListener mOnSubscriptionsChangedListener =
new OnSubscriptionsChangedListener() { new OnSubscriptionsChangedListener() {
@Override @Override
public void onSubscriptionsChanged() { public void onSubscriptionsChanged() {
mSubscriptionInfo = mSubscriptionManager.getActiveSubscriptionInfo( final int prevSubId = (mSubscriptionInfo != null)
mSubscriptionInfo.getSubscriptionId()); ? mSubscriptionInfo.getSubscriptionId()
mTelephonyManager = mTelephonyManager.createForSubscriptionId( : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
mSubscriptionInfo.getSubscriptionId());
updateNetworkProvider(); mSubscriptionInfo = getPhoneSubscriptionInfo(mSlotIndex);
final int nextSubId = (mSubscriptionInfo != null)
? mSubscriptionInfo.getSubscriptionId()
: SubscriptionManager.INVALID_SUBSCRIPTION_ID;
if (prevSubId != nextSubId) {
if (SubscriptionManager.isValidSubscriptionId(prevSubId)) {
unregisterImsRegistrationCallback(prevSubId);
}
if (SubscriptionManager.isValidSubscriptionId(nextSubId)) {
mTelephonyManager =
mTelephonyManager.createForSubscriptionId(nextSubId);
registerImsRegistrationCallback(nextSubId);
}
}
updateSubscriptionStatus();
} }
}; };
@@ -199,13 +221,17 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
} }
mPhoneStateListener = getPhoneStateListener(); mPhoneStateListener = getPhoneStateListener();
updateLatestAreaInfo();
updateSubscriptionStatus();
}
private void updateSubscriptionStatus() {
updateNetworkProvider(); updateNetworkProvider();
final ServiceState serviceState = mTelephonyManager.getServiceState(); final ServiceState serviceState = mTelephonyManager.getServiceState();
final SignalStrength signalStrength = mTelephonyManager.getSignalStrength(); final SignalStrength signalStrength = mTelephonyManager.getSignalStrength();
updatePhoneNumber(); updatePhoneNumber();
updateLatestAreaInfo();
updateServiceState(serviceState); updateServiceState(serviceState);
updateSignalStrength(signalStrength); updateSignalStrength(signalStrength);
updateNetworkType(); updateNetworkType();
@@ -239,6 +265,7 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
| PhoneStateListener.LISTEN_SERVICE_STATE); | PhoneStateListener.LISTEN_SERVICE_STATE);
mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener); mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
registerImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
if (mShowLatestAreaInfo) { if (mShowLatestAreaInfo) {
updateAreaInfoText(); updateAreaInfoText();
@@ -253,6 +280,7 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
return; return;
} }
unregisterImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener); mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
@@ -486,7 +514,7 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
boolean shouldHaveEid = false; boolean shouldHaveEid = false;
String eid = null; String eid = null;
if (mTelephonyManager.getPhoneCount() > PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM) { if (mTelephonyManager.getActiveModemCount() > MAX_PHONE_COUNT_SINGLE_SIM) {
// Get EID per-SIM in multi-SIM mode // Get EID per-SIM in multi-SIM mode
Map<Integer, Integer> mapping = mTelephonyManager.getLogicalToPhysicalSlotMapping(); Map<Integer, Integer> mapping = mTelephonyManager.getLogicalToPhysicalSlotMapping();
int pSlotId = mapping.getOrDefault(mSlotIndex, int pSlotId = mapping.getOrDefault(mSlotIndex,
@@ -523,21 +551,68 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
} }
} }
private void updateImsRegistrationState() { private boolean isImsRegistrationStateShowUp() {
final int subscriptionId = mSubscriptionInfo.getSubscriptionId(); final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
final PersistableBundle carrierConfig = final PersistableBundle carrierConfig =
mCarrierConfigManager.getConfigForSubId(subscriptionId); mCarrierConfigManager.getConfigForSubId(subscriptionId);
final boolean showImsRegState = carrierConfig == null ? false : return carrierConfig == null ? false :
carrierConfig.getBoolean( carrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_IMS_REGISTRATION_STATUS_BOOL); CarrierConfigManager.KEY_SHOW_IMS_REGISTRATION_STATUS_BOOL);
if (showImsRegState) { }
final boolean isImsRegistered = mTelephonyManager.isImsRegistered(subscriptionId);
mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(isImsRegistered ? private void updateImsRegistrationState() {
R.string.ims_reg_status_registered : R.string.ims_reg_status_not_registered)); if (isImsRegistrationStateShowUp()) {
} else { return;
mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_LABEL_ID);
mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_VALUE_ID);
} }
mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_LABEL_ID);
mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_VALUE_ID);
}
private ImsMmTelManager.RegistrationCallback mImsRegStateCallback =
new ImsMmTelManager.RegistrationCallback() {
@Override
public void onRegistered(@AccessNetworkConstants.TransportType int imsTransportType) {
mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
R.string.ims_reg_status_registered));
}
@Override
public void onRegistering(@AccessNetworkConstants.TransportType int imsTransportType) {
mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
R.string.ims_reg_status_not_registered));
}
@Override
public void onUnregistered(@Nullable ImsReasonInfo info) {
mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
R.string.ims_reg_status_not_registered));
}
@Override
public void onTechnologyChangeFailed(
@AccessNetworkConstants.TransportType int imsTransportType,
@Nullable ImsReasonInfo info) {
mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
R.string.ims_reg_status_not_registered));
}
};
private void registerImsRegistrationCallback(int subId) {
if (!isImsRegistrationStateShowUp()) {
return;
}
try {
final ImsMmTelManager imsMmTelMgr = ImsMmTelManager.createForSubscriptionId(subId);
imsMmTelMgr.registerImsRegistrationCallback(mDialog.getContext().getMainExecutor(),
mImsRegStateCallback);
} catch (ImsException exception) {
Log.w(TAG, "fail to register IMS status for subId=" + subId, exception);
}
}
private void unregisterImsRegistrationCallback(int subId) {
if (!isImsRegistrationStateShowUp()) {
return;
}
final ImsMmTelManager imsMmTelMgr = ImsMmTelManager.createForSubscriptionId(subId);
imsMmTelMgr.unregisterImsRegistrationCallback(mImsRegStateCallback);
} }
private SubscriptionInfo getPhoneSubscriptionInfo(int slotId) { private SubscriptionInfo getPhoneSubscriptionInfo(int slotId) {

View File

@@ -24,6 +24,7 @@ import static com.android.settings.deviceinfo.simstatus.SimStatusDialogControlle
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.ICCID_INFO_VALUE_ID; import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.ICCID_INFO_VALUE_ID;
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.IMS_REGISTRATION_STATE_LABEL_ID; import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.IMS_REGISTRATION_STATE_LABEL_ID;
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.IMS_REGISTRATION_STATE_VALUE_ID; import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.IMS_REGISTRATION_STATE_VALUE_ID;
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.MAX_PHONE_COUNT_SINGLE_SIM;
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.NETWORK_PROVIDER_VALUE_ID; import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.NETWORK_PROVIDER_VALUE_ID;
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.OPERATOR_INFO_LABEL_ID; import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.OPERATOR_INFO_LABEL_ID;
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.OPERATOR_INFO_VALUE_ID; import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.OPERATOR_INFO_VALUE_ID;
@@ -33,6 +34,7 @@ import static com.android.settings.deviceinfo.simstatus.SimStatusDialogControlle
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.SIGNAL_STRENGTH_LABEL_ID; import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.SIGNAL_STRENGTH_LABEL_ID;
import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.SIGNAL_STRENGTH_VALUE_ID; import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.SIGNAL_STRENGTH_VALUE_ID;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
@@ -41,6 +43,7 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
@@ -61,7 +64,6 @@ import android.telephony.euicc.EuiccManager;
import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleOwner;
import com.android.internal.telephony.PhoneConstants;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowDeviceInfoUtils; import com.android.settings.testutils.shadow.ShadowDeviceInfoUtils;
import com.android.settingslib.DeviceInfoUtils; import com.android.settingslib.DeviceInfoUtils;
@@ -79,6 +81,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows; import org.robolectric.Shadows;
import org.robolectric.annotation.Config; import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowPackageManager; import org.robolectric.shadows.ShadowPackageManager;
import org.robolectric.shadows.ShadowTelephonyManager;
import org.robolectric.util.ReflectionHelpers; import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList; import java.util.ArrayList;
@@ -92,7 +95,6 @@ public class SimStatusDialogControllerTest {
@Mock @Mock
private SimStatusDialogFragment mDialog; private SimStatusDialogFragment mDialog;
@Mock
private TelephonyManager mTelephonyManager; private TelephonyManager mTelephonyManager;
@Mock @Mock
private SubscriptionInfo mSubscriptionInfo; private SubscriptionInfo mSubscriptionInfo;
@@ -114,7 +116,6 @@ public class SimStatusDialogControllerTest {
private PersistableBundle mPersistableBundle; private PersistableBundle mPersistableBundle;
@Mock @Mock
private EuiccManager mEuiccManager; private EuiccManager mEuiccManager;
@Mock
private SubscriptionManager mSubscriptionManager; private SubscriptionManager mSubscriptionManager;
private SimStatusDialogController mController; private SimStatusDialogController mController;
@@ -125,13 +126,27 @@ public class SimStatusDialogControllerTest {
private static final String TEST_EID_FROM_CARD = "11111111111111111111111111111111"; private static final String TEST_EID_FROM_CARD = "11111111111111111111111111111111";
private static final String TEST_EID_FROM_MANAGER = "22222222222222222222222222222222"; private static final String TEST_EID_FROM_MANAGER = "22222222222222222222222222222222";
private static final int MAX_PHONE_COUNT_DUAL_SIM = 2;
@Before @Before
public void setup() { public void setup() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application; mContext = spy(RuntimeEnvironment.application);
when(mDialog.getContext()).thenReturn(mContext); when(mDialog.getContext()).thenReturn(mContext);
mLifecycleOwner = () -> mLifecycle; mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner); 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 */)); mController = spy(new SimStatusDialogController(mDialog, mLifecycle, 0 /* phone id */));
ShadowDeviceInfoUtils.setPhoneNumber(""); ShadowDeviceInfoUtils.setPhoneNumber("");
//CellSignalStrength setup //CellSignalStrength setup
@@ -152,11 +167,10 @@ public class SimStatusDialogControllerTest {
ReflectionHelpers.setField(mController, "mEuiccManager", mEuiccManager); ReflectionHelpers.setField(mController, "mEuiccManager", mEuiccManager);
ReflectionHelpers.setField(mController, "mSubscriptionManager", mSubscriptionManager); ReflectionHelpers.setField(mController, "mSubscriptionManager", mSubscriptionManager);
when(mTelephonyManager.getPhoneCount()).thenReturn( when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM); doReturn(new ArrayList<UiccCardInfo>()).when(mTelephonyManager).getUiccCardsInfo();
when(mTelephonyManager.getUiccCardsInfo()).thenReturn(new ArrayList<UiccCardInfo>()); doReturn(new HashMap<Integer, Integer>()).when(mTelephonyManager)
when(mTelephonyManager.getLogicalToPhysicalSlotMapping()).thenReturn( .getLogicalToPhysicalSlotMapping();
new HashMap<Integer, Integer>());
when(mEuiccManager.isEnabled()).thenReturn(false); when(mEuiccManager.isEnabled()).thenReturn(false);
when(mEuiccManager.getEid()).thenReturn(""); when(mEuiccManager.getEid()).thenReturn("");
@@ -166,7 +180,6 @@ public class SimStatusDialogControllerTest {
when(mPersistableBundle.getBoolean( when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)) CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
.thenReturn(true); .thenReturn(true);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
doReturn(mServiceState).when(mTelephonyManager).getServiceState(); doReturn(mServiceState).when(mTelephonyManager).getServiceState();
doReturn(mSignalStrength).when(mTelephonyManager).getSignalStrength(); doReturn(mSignalStrength).when(mTelephonyManager).getSignalStrength();
@@ -183,7 +196,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateNetworkProviderWithFoobarCarrier_shouldUpdateCarrierWithFoobar() { public void initialize_updateNetworkProviderWithFoobarCarrier_shouldUpdateCarrierWithFoobar() {
final CharSequence carrierName = "foobar"; final CharSequence carrierName = "foobar";
doReturn(carrierName).when(mSubscriptionInfo).getCarrierName(); doReturn(carrierName).when(mSubscriptionInfo).getCarrierName();
@@ -194,7 +206,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updatePhoneNumberWith1111111111_shouldUpdatePhoneNumber() { public void initialize_updatePhoneNumberWith1111111111_shouldUpdatePhoneNumber() {
ShadowDeviceInfoUtils.setPhoneNumber("1111111111"); ShadowDeviceInfoUtils.setPhoneNumber("1111111111");
@@ -207,7 +218,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateLatestAreaInfoWithCdmaPhone_shouldRemoveOperatorInfoSetting() { public void initialize_updateLatestAreaInfoWithCdmaPhone_shouldRemoveOperatorInfoSetting() {
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA); when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
@@ -218,7 +228,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateServiceStateWithInService_shouldUpdateTextToBeCInService() { public void initialize_updateServiceStateWithInService_shouldUpdateTextToBeCInService() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE); when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -229,7 +238,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateServiceStateWithPowerOff_shouldUpdateTextAndResetSignalStrength() { public void initialize_updateServiceStateWithPowerOff_shouldUpdateTextAndResetSignalStrength() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_POWER_OFF); when(mServiceState.getState()).thenReturn(ServiceState.STATE_POWER_OFF);
when(mPersistableBundle.getBoolean( when(mPersistableBundle.getBoolean(
@@ -243,7 +251,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateVoiceDataOutOfService_shouldUpdateSettingAndResetSignalStrength() { public void initialize_updateVoiceDataOutOfService_shouldUpdateSettingAndResetSignalStrength() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE); when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
when(mServiceState.getDataRegistrationState()).thenReturn( when(mServiceState.getDataRegistrationState()).thenReturn(
@@ -259,7 +266,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateTextToBeInService() { public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateTextToBeInService() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE); when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE); when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -273,7 +279,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateSignalStrengthWithLte50Wcdma40_shouldUpdateSignalStrengthTo50() { public void initialize_updateSignalStrengthWithLte50Wcdma40_shouldUpdateSignalStrengthTo50() {
final int lteDbm = 50; final int lteDbm = 50;
final int lteAsu = 50; final int lteAsu = 50;
@@ -291,7 +296,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateSignalStrengthWithLte50Cdma30_shouldUpdateSignalStrengthTo50() { public void initialize_updateSignalStrengthWithLte50Cdma30_shouldUpdateSignalStrengthTo50() {
final int lteDbm = 50; final int lteDbm = 50;
final int lteAsu = 50; final int lteAsu = 50;
@@ -309,7 +313,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateSignalStrengthTo50() { public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateSignalStrengthTo50() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE); when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE); when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -330,7 +333,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateVoiceNetworkTypeWithEdge_shouldUpdateSettingToEdge() { public void initialize_updateVoiceNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
when(mTelephonyManager.getVoiceNetworkType()).thenReturn( when(mTelephonyManager.getVoiceNetworkType()).thenReturn(
TelephonyManager.NETWORK_TYPE_EDGE); TelephonyManager.NETWORK_TYPE_EDGE);
@@ -342,7 +344,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateDataNetworkTypeWithEdge_shouldUpdateSettingToEdge() { public void initialize_updateDataNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
when(mTelephonyManager.getDataNetworkType()).thenReturn( when(mTelephonyManager.getDataNetworkType()).thenReturn(
TelephonyManager.NETWORK_TYPE_EDGE); TelephonyManager.NETWORK_TYPE_EDGE);
@@ -354,7 +355,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateRoamingStatusIsRoaming_shouldSetSettingToRoaming() { public void initialize_updateRoamingStatusIsRoaming_shouldSetSettingToRoaming() {
when(mServiceState.getRoaming()).thenReturn(true); when(mServiceState.getRoaming()).thenReturn(true);
@@ -365,7 +365,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_updateRoamingStatusNotRoaming_shouldSetSettingToRoamingOff() { public void initialize_updateRoamingStatusNotRoaming_shouldSetSettingToRoamingOff() {
when(mServiceState.getRoaming()).thenReturn(false); when(mServiceState.getRoaming()).thenReturn(false);
@@ -376,7 +375,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_doNotShowIccid_shouldRemoveIccidSetting() { public void initialize_doNotShowIccid_shouldRemoveIccidSetting() {
when(mPersistableBundle.getBoolean( when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL)).thenReturn(false); CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL)).thenReturn(false);
@@ -388,7 +386,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_doNotShowSignalStrength_shouldRemoveSignalStrengthSetting() { public void initialize_doNotShowSignalStrength_shouldRemoveSignalStrengthSetting() {
when(mPersistableBundle.getBoolean( when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)) CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
@@ -401,7 +398,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_showSignalStrengthAndIccId_shouldShowSignalStrengthAndIccIdSetting() { public void initialize_showSignalStrengthAndIccId_shouldShowSignalStrengthAndIccIdSetting() {
// getConfigForSubId is nullable, so make sure the default behavior is correct // getConfigForSubId is nullable, so make sure the default behavior is correct
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(null); when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(null);
@@ -414,7 +410,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_showIccid_shouldSetIccidToSetting() { public void initialize_showIccid_shouldSetIccidToSetting() {
final String iccid = "12351351231241"; final String iccid = "12351351231241";
when(mPersistableBundle.getBoolean( when(mPersistableBundle.getBoolean(
@@ -428,7 +423,7 @@ public class SimStatusDialogControllerTest {
@Test @Test
public void initialize_updateEid_shouldNotSetEid() { public void initialize_updateEid_shouldNotSetEid() {
when(mTelephonyManager.getPhoneCount()).thenReturn(PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM); when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>(); ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo1 = new UiccCardInfo( UiccCardInfo uiccCardInfo1 = new UiccCardInfo(
@@ -466,7 +461,7 @@ public class SimStatusDialogControllerTest {
@Test @Test
public void initialize_updateEid_shouldSetEidFromCard() { public void initialize_updateEid_shouldSetEidFromCard() {
when(mTelephonyManager.getPhoneCount()).thenReturn(PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM); when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>(); ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo1 = new UiccCardInfo( UiccCardInfo uiccCardInfo1 = new UiccCardInfo(
@@ -504,7 +499,7 @@ public class SimStatusDialogControllerTest {
@Test @Test
public void initialize_updateEid_shouldSetEidFromManager() { public void initialize_updateEid_shouldSetEidFromManager() {
when(mTelephonyManager.getPhoneCount()).thenReturn(PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM); when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>(); ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo1 = new UiccCardInfo( UiccCardInfo uiccCardInfo1 = new UiccCardInfo(
@@ -545,7 +540,7 @@ public class SimStatusDialogControllerTest {
@Test @Test
public void initialize_updateEid_shouldRemoveEid() { public void initialize_updateEid_shouldRemoveEid() {
when(mTelephonyManager.getPhoneCount()).thenReturn(PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM); when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>(); ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo1 = new UiccCardInfo( UiccCardInfo uiccCardInfo1 = new UiccCardInfo(
@@ -584,8 +579,7 @@ public class SimStatusDialogControllerTest {
@Test @Test
public void initialize_updateEid_shouldNotSetEidInSingleSimMode() { public void initialize_updateEid_shouldNotSetEidInSingleSimMode() {
when(mTelephonyManager.getPhoneCount()).thenReturn( when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>(); ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo = new UiccCardInfo( UiccCardInfo uiccCardInfo = new UiccCardInfo(
@@ -614,8 +608,7 @@ public class SimStatusDialogControllerTest {
@Test @Test
public void initialize_updateEid_shouldSetEidInSingleSimModeWithEnabledEuicc() { public void initialize_updateEid_shouldSetEidInSingleSimModeWithEnabledEuicc() {
when(mTelephonyManager.getPhoneCount()).thenReturn( when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>(); ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo = new UiccCardInfo( UiccCardInfo uiccCardInfo = new UiccCardInfo(
@@ -646,8 +639,7 @@ public class SimStatusDialogControllerTest {
@Test @Test
public void initialize_updateEid_shouldSetEidInSingleSimModeWithDisabledEuicc() { public void initialize_updateEid_shouldSetEidInSingleSimModeWithDisabledEuicc() {
when(mTelephonyManager.getPhoneCount()).thenReturn( when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>(); ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo = new UiccCardInfo( UiccCardInfo uiccCardInfo = new UiccCardInfo(
@@ -678,8 +670,7 @@ public class SimStatusDialogControllerTest {
@Test @Test
public void initialize_updateEid_shouldRemoveEidInSingleSimMode() { public void initialize_updateEid_shouldRemoveEidInSingleSimMode() {
when(mTelephonyManager.getPhoneCount()).thenReturn( when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>(); ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo = new UiccCardInfo( UiccCardInfo uiccCardInfo = new UiccCardInfo(
@@ -757,7 +748,6 @@ public class SimStatusDialogControllerTest {
} }
@Test @Test
@Ignore
public void initialize_nullSignalStrength_noCrash() { public void initialize_nullSignalStrength_noCrash() {
doReturn(null).when(mTelephonyManager).getSignalStrength(); doReturn(null).when(mTelephonyManager).getSignalStrength();
// we should not crash when running the following line // we should not crash when running the following line