use of android.telephony.UiccCardInfo in project android_packages_apps_Settings by omnirom.
the class SubscriptionUtil method getFirstRemovableSubscription.
/**
* Returns the subscription on a removable sim card. The device does not need to be on removable
* slot.
*/
@Nullable
public static SubscriptionInfo getFirstRemovableSubscription(Context context) {
TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
SubscriptionManager subscriptionManager = context.getSystemService(SubscriptionManager.class);
List<UiccCardInfo> cardInfos = telephonyManager.getUiccCardsInfo();
if (cardInfos == null) {
Log.w(TAG, "UICC cards info list is empty.");
return null;
}
List<SubscriptionInfo> allSubscriptions = subscriptionManager.getAllSubscriptionInfoList();
if (allSubscriptions == null) {
Log.w(TAG, "All subscription info list is empty.");
return null;
}
for (UiccCardInfo cardInfo : cardInfos) {
if (cardInfo == null) {
Log.w(TAG, "Got null card.");
continue;
}
if (!cardInfo.isRemovable() || cardInfo.getCardId() == TelephonyManager.UNSUPPORTED_CARD_ID) {
Log.i(TAG, "Skip embedded card or invalid cardId on slot: " + cardInfo.getSlotIndex());
continue;
}
Log.i(TAG, "Target removable cardId :" + cardInfo.getCardId());
for (SubscriptionInfo subInfo : allSubscriptions) {
// Match the removable card id with subscription card id.
if (cardInfo.getCardId() == subInfo.getCardId()) {
return subInfo;
}
}
}
return null;
}
use of android.telephony.UiccCardInfo in project android_packages_apps_Settings by omnirom.
the class SimStatusDialogControllerTest method setup.
@Before
@UiThreadTest
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mDialog.getContext()).thenReturn(mContext);
mLifecycle = new Lifecycle(mLifecycleOwner);
mTelephonyManager = spy(mContext.getSystemService(TelephonyManager.class));
mSubscriptionManager = spy(mContext.getSystemService(SubscriptionManager.class));
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfoForSimSlotIndex(anyInt());
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(mCarrierConfigManager);
when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
doReturn(2).when(mTelephonyManager).getCardIdForDefaultEuicc();
doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mTelephonyManager).getDataNetworkType();
mController = spy(new SimStatusDialogController(mDialog, mLifecycle, 0));
// CellSignalStrength setup
doReturn(0).when(mCellSignalStrengthCdma).getDbm();
doReturn(0).when(mCellSignalStrengthCdma).getAsuLevel();
doReturn(0).when(mCellSignalStrengthLte).getDbm();
doReturn(0).when(mCellSignalStrengthLte).getAsuLevel();
doReturn(0).when(mCellSignalStrengthWcdma).getDbm();
doReturn(0).when(mCellSignalStrengthWcdma).getAsuLevel();
doReturn(null).when(mSignalStrength).getCellSignalStrengths();
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
doReturn(new ArrayList<UiccCardInfo>()).when(mTelephonyManager).getUiccCardsInfo();
doReturn(new HashMap<Integer, Integer>()).when(mTelephonyManager).getLogicalToPhysicalSlotMapping();
when(mEuiccManager.isEnabled()).thenReturn(false);
when(mEuiccManager.getEid()).thenReturn("");
when(mEuiccManager.createForCardId(anyInt())).thenReturn(mEuiccManager);
mPersistableBundle = new PersistableBundle();
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mPersistableBundle);
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL, true);
doReturn(mServiceState).when(mTelephonyManager).getServiceState();
doReturn(mSignalStrength).when(mTelephonyManager).getSignalStrength();
}
use of android.telephony.UiccCardInfo in project android_packages_apps_Settings by omnirom.
the class SimStatusDialogControllerTest method initialize_updateEid_shouldSetEidFromCard.
@Test
public void initialize_updateEid_shouldSetEidFromCard() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo1 = new UiccCardInfo(// isEuicc
true, // cardId
0, // eid
TEST_EID_FROM_CARD, // iccid
null, // slotIndex
0, // isRemovable
false);
uiccCardInfos.add(uiccCardInfo1);
UiccCardInfo uiccCardInfo2 = new UiccCardInfo(// isEuicc
false, // cardId
1, // eid
null, // iccid
"123451234567890", // slotIndex
1, // isRemovable
true);
uiccCardInfos.add(uiccCardInfo2);
when(mTelephonyManager.getUiccCardsInfo()).thenReturn(uiccCardInfos);
Map<Integer, Integer> slotMapping = new HashMap<>();
slotMapping.put(0, 0);
slotMapping.put(1, 1);
when(mTelephonyManager.getLogicalToPhysicalSlotMapping()).thenReturn(slotMapping);
when(mEuiccManager.isEnabled()).thenReturn(true);
when(mEuiccManager.getEid()).thenReturn(TEST_EID_FROM_MANAGER);
when(mEuiccManager.createForCardId(0)).thenReturn(mEuiccManager);
doNothing().when(mController).requestForUpdateEid();
mController.updateEid(mController.getEid(0));
mController.initialize();
// Set EID retrieved from the card.
verify(mDialog).setText(EID_INFO_VALUE_ID, TEST_EID_FROM_CARD);
verify(mDialog, never()).removeSettingFromScreen(eq(EID_INFO_VALUE_ID));
}
use of android.telephony.UiccCardInfo in project android_packages_apps_Settings by omnirom.
the class SimStatusDialogControllerTest method initialize_updateEid_shouldNotSetEidInSingleSimMode.
@Test
public void initialize_updateEid_shouldNotSetEidInSingleSimMode() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo = new UiccCardInfo(// isEuicc
true, // cardId
0, // eid (not used)
TEST_EID_FROM_CARD, // iccid
null, // slotIndex
0, // isRemovable
false);
uiccCardInfos.add(uiccCardInfo);
when(mTelephonyManager.getUiccCardsInfo()).thenReturn(uiccCardInfos);
Map<Integer, Integer> slotMapping = new HashMap<>();
slotMapping.put(0, 0);
when(mTelephonyManager.getLogicalToPhysicalSlotMapping()).thenReturn(slotMapping);
when(mEuiccManager.isEnabled()).thenReturn(true);
when(mEuiccManager.getEid()).thenReturn(null);
doNothing().when(mController).requestForUpdateEid();
mController.updateEid(mController.getEid(0));
mController.initialize();
// Keep 'Not available' if the default eUICC manager cannot provide EID in Single SIM mode.
verify(mDialog, never()).setText(eq(EID_INFO_VALUE_ID), any());
verify(mDialog, never()).removeSettingFromScreen(eq(EID_INFO_VALUE_ID));
}
use of android.telephony.UiccCardInfo in project android_packages_apps_Settings by omnirom.
the class SimStatusDialogControllerTest method initialize_updateEid_shouldRemoveEidInSingleSimMode.
@Test
public void initialize_updateEid_shouldRemoveEidInSingleSimMode() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
UiccCardInfo uiccCardInfo = new UiccCardInfo(// isEuicc
false, // cardId
0, // eid
null, // iccid
"123451234567890", // slotIndex
0, // isRemovable
true);
uiccCardInfos.add(uiccCardInfo);
when(mTelephonyManager.getUiccCardsInfo()).thenReturn(uiccCardInfos);
Map<Integer, Integer> slotMapping = new HashMap<>();
slotMapping.put(0, 0);
when(mTelephonyManager.getLogicalToPhysicalSlotMapping()).thenReturn(slotMapping);
when(mEuiccManager.isEnabled()).thenReturn(false);
when(mEuiccManager.getEid()).thenReturn(null);
doNothing().when(mController).requestForUpdateEid();
mController.updateEid(mController.getEid(0));
mController.initialize();
// Remove EID if the default eUICC manager indicates that eSIM is not enabled.
verify(mDialog, never()).setText(eq(EID_INFO_VALUE_ID), any());
verify(mDialog).removeSettingFromScreen(eq(EID_INFO_LABEL_ID));
verify(mDialog).removeSettingFromScreen(eq(EID_INFO_VALUE_ID));
}
Aggregations