Merge "Remove logic to manually search inactive pSIM."
This commit is contained in:
committed by
Android (Google) Code Review
commit
69a7e054f5
@@ -80,39 +80,10 @@ public class SubscriptionUtil {
|
|||||||
return sAvailableResultsForTesting;
|
return sAvailableResultsForTesting;
|
||||||
}
|
}
|
||||||
final SubscriptionManager subMgr = context.getSystemService(SubscriptionManager.class);
|
final SubscriptionManager subMgr = context.getSystemService(SubscriptionManager.class);
|
||||||
final TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
|
|
||||||
|
|
||||||
final List<SubscriptionInfo> subscriptions =
|
final List<SubscriptionInfo> subscriptions =
|
||||||
new ArrayList<>(emptyIfNull(subMgr.getSelectableSubscriptionInfoList()));
|
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<>();
|
|
||||||
final 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()) {
|
|
||||||
return subscriptions;
|
|
||||||
}
|
|
||||||
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;
|
return subscriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,7 +38,6 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -87,37 +86,6 @@ public class SubscriptionUtilTest {
|
|||||||
assertThat(subs).hasSize(2);
|
assertThat(subs).hasSize(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailableSubscriptions_oneSelectableTwoDisabledPSimsOneAbsent_twoResults() {
|
public void getAvailableSubscriptions_oneSelectableTwoDisabledPSimsOneAbsent_twoResults() {
|
||||||
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
|
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
|
||||||
|
Reference in New Issue
Block a user