use of android.telephony.UiccSlotInfo in project android_packages_apps_Settings by omnirom.
the class SimSlotChangeHandler method onSuwFinish.
void onSuwFinish(Context context) {
init(context);
if (Looper.myLooper() == Looper.getMainLooper()) {
throw new IllegalStateException("Cannot be called from main thread.");
}
if (mTelMgr.getActiveModemCount() > 1) {
Log.i(TAG, "The device is already in DSDS mode. Do nothing.");
return;
}
UiccSlotInfo removableSlotInfo = getRemovableUiccSlotInfo();
if (removableSlotInfo == null) {
Log.e(TAG, "Unable to find the removable slot. Do nothing.");
return;
}
boolean embeddedSimExist = getGroupedEmbeddedSubscriptions().size() != 0;
int removableSlotAction = getSuwRemovableSlotAction(mContext);
setSuwRemovableSlotAction(mContext, LAST_USER_ACTION_IN_SUW_NONE);
if (embeddedSimExist && removableSlotInfo.getCardStateInfo() == UiccSlotInfo.CARD_STATE_INFO_PRESENT) {
if (mTelMgr.isMultiSimSupported() == TelephonyManager.MULTISIM_ALLOWED) {
Log.i(TAG, "DSDS condition satisfied. Show notification.");
SimNotificationService.scheduleSimNotification(mContext, SimActivationNotifier.NotificationType.ENABLE_DSDS);
} else if (removableSlotAction == LAST_USER_ACTION_IN_SUW_INSERT) {
Log.i(TAG, "Both removable SIM and eSIM are present. DSDS condition doesn't" + " satisfied. User inserted pSIM during SUW. Show choose SIM" + " screen.");
startChooseSimActivity(true);
}
} else if (removableSlotAction == LAST_USER_ACTION_IN_SUW_REMOVE) {
handleSimRemove(removableSlotInfo);
}
}
use of android.telephony.UiccSlotInfo in project robolectric by robolectric.
the class ShadowTelephonyManagerTest method getUiccSlotsInfo.
@Test
@Config(minSdk = P)
public void getUiccSlotsInfo() {
UiccSlotInfo slotInfo1 = new UiccSlotInfo(true, true, null, 0, 0, true);
UiccSlotInfo slotInfo2 = new UiccSlotInfo(true, true, null, 0, 1, true);
UiccSlotInfo[] slotInfos = new UiccSlotInfo[] { slotInfo1, slotInfo2 };
shadowOf(telephonyManager).setUiccSlotsInfo(slotInfos);
assertThat(shadowOf(telephonyManager).getUiccSlotsInfo()).isEqualTo(slotInfos);
}
use of android.telephony.UiccSlotInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SubscriptionUtilTest method getAvailableSubscriptions_oneSelectableOneDisabledPSim_twoResults.
@Test
public void getAvailableSubscriptions_oneSelectableOneDisabledPSim_twoResults() {
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
when(info1.getSubscriptionId()).thenReturn(111);
when(info1.getSimSlotIndex()).thenReturn(-1);
when(info1.getCardString()).thenReturn("info1_cardid");
when(info2.getSubscriptionId()).thenReturn(222);
when(info2.getSimSlotIndex()).thenReturn(0);
when(info2.getCardString()).thenReturn("info2_cardid");
when(mSubMgr.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info1));
when(mSubMgr.getAllSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
final UiccSlotInfo info2slot = mock(UiccSlotInfo.class);
when(info2slot.getCardStateInfo()).thenReturn(CARD_STATE_INFO_PRESENT);
when(info2slot.getLogicalSlotIdx()).thenReturn(0);
when(info2slot.getCardId()).thenReturn("info2_cardid");
final UiccSlotInfo[] slotInfos = { info2slot };
when(mTelMgr.getUiccSlotsInfo()).thenReturn(slotInfos);
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mContext);
assertThat(subs).hasSize(2);
assertThat(subs.get(0).getSubscriptionId()).isEqualTo(111);
assertThat(subs.get(1).getSubscriptionId()).isEqualTo(222);
}
use of android.telephony.UiccSlotInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SubscriptionUtilTest method getAvailableSubscriptions_oneSelectableTwoDisabledPSimsOneAbsent_twoResults.
@Test
public void getAvailableSubscriptions_oneSelectableTwoDisabledPSimsOneAbsent_twoResults() {
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
when(info1.getSubscriptionId()).thenReturn(111);
when(info1.getSimSlotIndex()).thenReturn(-1);
when(info1.getCardString()).thenReturn("info1_cardid");
when(info2.getSubscriptionId()).thenReturn(222);
when(info2.getSimSlotIndex()).thenReturn(-1);
when(info2.getCardString()).thenReturn("info2_cardid");
when(info3.getSubscriptionId()).thenReturn(333);
when(info3.getSimSlotIndex()).thenReturn(0);
when(info3.getCardString()).thenReturn("info3_cardid");
when(mSubMgr.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info1));
when(mSubMgr.getAllSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2, info3));
final UiccSlotInfo info2slot = mock(UiccSlotInfo.class);
final UiccSlotInfo info3slot = mock(UiccSlotInfo.class);
when(info2slot.getLogicalSlotIdx()).thenReturn(-1);
when(info2slot.getCardStateInfo()).thenReturn(CARD_STATE_INFO_ABSENT);
when(info2slot.getCardId()).thenReturn("info2_cardid");
when(info3slot.getLogicalSlotIdx()).thenReturn(0);
when(info3slot.getCardStateInfo()).thenReturn(CARD_STATE_INFO_PRESENT);
when(info3slot.getCardId()).thenReturn("info3_cardid");
final UiccSlotInfo[] slotInfos = { info2slot, info3slot };
when(mTelMgr.getUiccSlotsInfo()).thenReturn(slotInfos);
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mContext);
assertThat(subs).hasSize(2);
assertThat(subs.get(0).getSubscriptionId()).isEqualTo(111);
assertThat(subs.get(1).getSubscriptionId()).isEqualTo(333);
}
use of android.telephony.UiccSlotInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SubscriptionUtil method getAvailableSubscriptions.
public static List<SubscriptionInfo> getAvailableSubscriptions(Context context) {
if (sAvailableResultsForTesting != null) {
return sAvailableResultsForTesting;
}
final SubscriptionManager subMgr = context.getSystemService(SubscriptionManager.class);
final TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
List<SubscriptionInfo> subscriptions = new ArrayList<>(emptyIfNull(subMgr.getSelectableSubscriptionInfoList()));
// Look for inactive but present physical SIMs that are missing from the selectable list.
final List<UiccSlotInfo> missing = new ArrayList<>();
UiccSlotInfo[] slotsInfo = telMgr.getUiccSlotsInfo();
for (int i = 0; slotsInfo != null && i < slotsInfo.length; i++) {
final UiccSlotInfo slotInfo = slotsInfo[i];
if (isInactiveInsertedPSim(slotInfo)) {
final int index = slotInfo.getLogicalSlotIdx();
final String cardId = slotInfo.getCardId();
final boolean found = subscriptions.stream().anyMatch(info -> index == info.getSimSlotIndex() && cardId.equals(info.getCardString()));
if (!found) {
missing.add(slotInfo);
}
}
}
if (!missing.isEmpty()) {
for (SubscriptionInfo info : subMgr.getAllSubscriptionInfoList()) {
for (UiccSlotInfo slotInfo : missing) {
if (info.getSimSlotIndex() == slotInfo.getLogicalSlotIdx() && info.getCardString().equals(slotInfo.getCardId())) {
subscriptions.add(info);
break;
}
}
}
}
return subscriptions;
}
Aggregations