[MEP] psim's logical slot index is 0
psim's logical slot index is 0, so changing the API and adding test
cases.
Bug: 221839363
Test: atest UiccSlotUtilTest
Change-Id: I1588bd4a2f552a6b41844883b6ad50f1bfec95de
(cherry picked from commit b162438b5d
)
Merged-In: I1588bd4a2f552a6b41844883b6ad50f1bfec95de
This commit is contained in:
@@ -25,6 +25,7 @@ import android.telephony.UiccSlotInfo;
|
|||||||
import android.telephony.UiccSlotMapping;
|
import android.telephony.UiccSlotMapping;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.settingslib.utils.ThreadUtils;
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@@ -33,6 +34,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -126,7 +128,10 @@ public class UiccSlotUtil {
|
|||||||
|
|
||||||
performSwitchToSlot(telMgr,
|
performSwitchToSlot(telMgr,
|
||||||
prepareUiccSlotMappings(uiccSlotMappings,
|
prepareUiccSlotMappings(uiccSlotMappings,
|
||||||
inactiveRemovableSlot, /*removable sim's port Id*/ 0, removedSubInfo,
|
/*slot is psim*/ true,
|
||||||
|
inactiveRemovableSlot,
|
||||||
|
/*removable sim's port Id*/ TelephonyManager.DEFAULT_PORT_INDEX,
|
||||||
|
removedSubInfo,
|
||||||
telMgr.isMultiSimEnabled()),
|
telMgr.isMultiSimEnabled()),
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
@@ -159,7 +164,7 @@ public class UiccSlotUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
performSwitchToSlot(telMgr,
|
performSwitchToSlot(telMgr,
|
||||||
prepareUiccSlotMappings(uiccSlotMappings,
|
prepareUiccSlotMappings(uiccSlotMappings, /*slot is not psim*/ false,
|
||||||
physicalSlotId, port, removedSubInfo, telMgr.isMultiSimEnabled()),
|
physicalSlotId, port, removedSubInfo, telMgr.isMultiSimEnabled()),
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
@@ -251,9 +256,27 @@ public class UiccSlotUtil {
|
|||||||
return INVALID_PHYSICAL_SLOT_ID;
|
return INVALID_PHYSICAL_SLOT_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Collection<UiccSlotMapping> prepareUiccSlotMappings(
|
// Device | |Slot |
|
||||||
Collection<UiccSlotMapping> uiccSlotMappings, int physicalSlotId, int port,
|
// Working| |Mapping|
|
||||||
SubscriptionInfo removedSubInfo, boolean isMultiSimEnabled) {
|
// State |Type |Mode |Friendly name
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// Single |SIM pSIM [RIL 0] |1 |pSIM active
|
||||||
|
// Single |SIM MEP Port #0 [RIL0] |2 |eSIM Port0 active
|
||||||
|
// Single |SIM MEP Port #1 [RIL0] |2.1 |eSIM Port1 active
|
||||||
|
// DSDS |pSIM [RIL 0] + MEP Port #0 [RIL 1] |3 |pSIM+Port0
|
||||||
|
// DSDS |pSIM [RIL 0] + MEP Port #1 [RIL 1] |3.1 |pSIM+Port1
|
||||||
|
// DSDS |MEP Port #0 [RIL 0] + MEP Port #1 [RIL1]|3.2 |Dual-Ports-A
|
||||||
|
// DSDS |MEP Port #1 [RIL 0] + MEP Port #0 [RIL1]|4 |Dual-Ports-B
|
||||||
|
//
|
||||||
|
// The rules are:
|
||||||
|
// 1. pSIM's logical slots always is [RIL 0].
|
||||||
|
// 2. assign the new active port to the same stack that will be de-activated
|
||||||
|
// For example: mode#3->mode#4
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
static Collection<UiccSlotMapping> prepareUiccSlotMappings(
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings, boolean isPsim, int physicalSlotId,
|
||||||
|
int port, SubscriptionInfo removedSubInfo, boolean isMultiSimEnabled) {
|
||||||
Collection<UiccSlotMapping> newUiccSlotMappings = new ArrayList<>();
|
Collection<UiccSlotMapping> newUiccSlotMappings = new ArrayList<>();
|
||||||
if (!isMultiSimEnabled) {
|
if (!isMultiSimEnabled) {
|
||||||
// In the 'SS mode', the port is 0.
|
// In the 'SS mode', the port is 0.
|
||||||
@@ -268,25 +291,59 @@ public class UiccSlotUtil {
|
|||||||
+ "PhysicalSlotId%d-Port%d",
|
+ "PhysicalSlotId%d-Port%d",
|
||||||
removedSubInfo.getSubscriptionId(), removedSubInfo.getSimSlotIndex(),
|
removedSubInfo.getSubscriptionId(), removedSubInfo.getSimSlotIndex(),
|
||||||
removedSubInfo.getPortIndex(), physicalSlotId, port));
|
removedSubInfo.getPortIndex(), physicalSlotId, port));
|
||||||
|
|
||||||
|
int logicalSlotIndex = 0;
|
||||||
|
if (isPsim) {
|
||||||
|
// The target slot is psim
|
||||||
|
newUiccSlotMappings.add(
|
||||||
|
new UiccSlotMapping(port, physicalSlotId, logicalSlotIndex++));
|
||||||
|
}
|
||||||
|
Collection<UiccSlotMapping> tempUiccSlotMappings =
|
||||||
|
uiccSlotMappings.stream()
|
||||||
|
.sorted(Comparator.comparingInt(UiccSlotMapping::getLogicalSlotIndex))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
for (UiccSlotMapping uiccSlotMapping : tempUiccSlotMappings) {
|
||||||
|
if (isSubInfoMappingIntoUiccSlotMapping(uiccSlotMapping, removedSubInfo)) {
|
||||||
|
if (!isPsim) {
|
||||||
|
// Replace this uiccSlotMapping
|
||||||
|
newUiccSlotMappings.add(new UiccSlotMapping(port, physicalSlotId,
|
||||||
|
uiccSlotMapping.getLogicalSlotIndex()));
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the psim is inserted, then change the
|
||||||
|
// logicalSlotIndex for another uiccSlotMappings.
|
||||||
|
newUiccSlotMappings.add(isPsim
|
||||||
|
? new UiccSlotMapping(
|
||||||
|
uiccSlotMapping.getPortIndex(),
|
||||||
|
uiccSlotMapping.getPhysicalSlotIndex(),
|
||||||
|
logicalSlotIndex++
|
||||||
|
) : uiccSlotMapping);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// For no inserted psim case in DSDS+MEP, there is only one esim in device and
|
||||||
|
// then user inserts another esim in DSDS+MEP.
|
||||||
|
// If the target is esim, then replace the psim.
|
||||||
|
Log.i(TAG, "The removedSubInfo is null");
|
||||||
newUiccSlotMappings =
|
newUiccSlotMappings =
|
||||||
uiccSlotMappings.stream().map(uiccSlotMapping -> {
|
uiccSlotMappings.stream().map(uiccSlotMapping -> {
|
||||||
if (uiccSlotMapping.getLogicalSlotIndex()
|
if (!isPsim && uiccSlotMapping.getPhysicalSlotIndex() != physicalSlotId) {
|
||||||
== removedSubInfo.getSimSlotIndex()
|
|
||||||
&& uiccSlotMapping.getPortIndex()
|
|
||||||
== removedSubInfo.getPortIndex()) {
|
|
||||||
return new UiccSlotMapping(port, physicalSlotId,
|
return new UiccSlotMapping(port, physicalSlotId,
|
||||||
uiccSlotMapping.getLogicalSlotIndex());
|
uiccSlotMapping.getLogicalSlotIndex());
|
||||||
}
|
}
|
||||||
return uiccSlotMapping;
|
return uiccSlotMapping;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
} else {
|
|
||||||
// DSDS+no MEP
|
|
||||||
// The removable slot should be in UiccSlotMapping.
|
|
||||||
newUiccSlotMappings = uiccSlotMappings;
|
|
||||||
Log.i(TAG, "The removedSubInfo is null");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "The SimSlotMapping: " + newUiccSlotMappings);
|
Log.i(TAG, "The SimSlotMapping: " + newUiccSlotMappings);
|
||||||
return newUiccSlotMappings;
|
return newUiccSlotMappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isSubInfoMappingIntoUiccSlotMapping(UiccSlotMapping uiccSlotMapping,
|
||||||
|
SubscriptionInfo subscriptionInfo) {
|
||||||
|
return uiccSlotMapping != null
|
||||||
|
&& uiccSlotMapping.getLogicalSlotIndex() == subscriptionInfo.getSimSlotIndex()
|
||||||
|
&& uiccSlotMapping.getPortIndex() == subscriptionInfo.getPortIndex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,9 +24,11 @@ import static org.mockito.Mockito.spy;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.UiccPortInfo;
|
import android.telephony.UiccPortInfo;
|
||||||
import android.telephony.UiccSlotInfo;
|
import android.telephony.UiccSlotInfo;
|
||||||
|
import android.telephony.UiccSlotMapping;
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
@@ -39,8 +41,12 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class UiccSlotUtilTest {
|
public class UiccSlotUtilTest {
|
||||||
@@ -48,6 +54,9 @@ public class UiccSlotUtilTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private TelephonyManager mTelephonyManager;
|
private TelephonyManager mTelephonyManager;
|
||||||
|
|
||||||
|
private static final int ESIM_PHYSICAL_SLOT = 0;
|
||||||
|
private static final int PSIM_PHYSICAL_SLOT = 1;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
@@ -58,7 +67,7 @@ public class UiccSlotUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSlotInfos_oneSimSlotDevice_returnTheCorrectSlotInfoList() {
|
public void getSlotInfos_oneSimSlotDevice_returnTheCorrectSlotInfoList() {
|
||||||
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(oneSimSlotDevice_ActivePsim());
|
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(oneSimSlotDeviceActivePsim());
|
||||||
ImmutableList<UiccSlotInfo> testUiccSlotInfos =
|
ImmutableList<UiccSlotInfo> testUiccSlotInfos =
|
||||||
UiccSlotUtil.getSlotInfos(mTelephonyManager);
|
UiccSlotUtil.getSlotInfos(mTelephonyManager);
|
||||||
|
|
||||||
@@ -68,7 +77,7 @@ public class UiccSlotUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getSlotInfos_twoSimSlotsDevice_returnTheCorrectSlotInfoList() {
|
public void getSlotInfos_twoSimSlotsDevice_returnTheCorrectSlotInfoList() {
|
||||||
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
||||||
twoSimSlotsDevice_ActivePsimActiveEsim());
|
twoSimSlotsDeviceActivePsimActiveEsim());
|
||||||
ImmutableList<UiccSlotInfo> testUiccSlotInfos =
|
ImmutableList<UiccSlotInfo> testUiccSlotInfos =
|
||||||
UiccSlotUtil.getSlotInfos(mTelephonyManager);
|
UiccSlotUtil.getSlotInfos(mTelephonyManager);
|
||||||
|
|
||||||
@@ -78,7 +87,7 @@ public class UiccSlotUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot0_returnTheCorrectEsimSlot() {
|
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot0_returnTheCorrectEsimSlot() {
|
||||||
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
||||||
twoSimSlotsDevice_ActiveEsimActivePsim());
|
twoSimSlotsDeviceActiveEsimActivePsim());
|
||||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
|
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
|
||||||
|
|
||||||
assertThat(testSlot).isEqualTo(0);
|
assertThat(testSlot).isEqualTo(0);
|
||||||
@@ -87,7 +96,7 @@ public class UiccSlotUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot1_returnTheCorrectEsimSlot() {
|
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot1_returnTheCorrectEsimSlot() {
|
||||||
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
||||||
twoSimSlotsDevice_ActivePsimActiveEsim());
|
twoSimSlotsDeviceActivePsimActiveEsim());
|
||||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
|
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
|
||||||
|
|
||||||
assertThat(testSlot).isEqualTo(1);
|
assertThat(testSlot).isEqualTo(1);
|
||||||
@@ -96,12 +105,253 @@ public class UiccSlotUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getEsimSlotId_noEimSlotDevice_returnTheCorrectEsimSlot() {
|
public void getEsimSlotId_noEimSlotDevice_returnTheCorrectEsimSlot() {
|
||||||
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
||||||
oneSimSlotDevice_ActivePsim());
|
oneSimSlotDeviceActivePsim());
|
||||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
|
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
|
||||||
|
|
||||||
assertThat(testSlot).isEqualTo(-1);
|
assertThat(testSlot).isEqualTo(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_fromPsimActiveToEsimPort0Active_esimPort0Active() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingSsModePsimActive();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingSsModeEsimPort0Active();
|
||||||
|
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, null, false);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_fromEsimPort0ActiveToPsimActive_psimActive() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings =
|
||||||
|
createUiccSlotMappingSsModeEsimPort0Active();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingSsModePsimActive();
|
||||||
|
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, null, false);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_fromPsimAndPort0ToPsimAndPort1_psimAndPort1() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingPsimAndPort1();
|
||||||
|
SubscriptionInfo subInfo = createSubscriptionInfo(1, 0);
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, subInfo, true);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_fromPsimAndPort1ToPsimAndPort0_psimAndPort0() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingPsimAndPort0();
|
||||||
|
|
||||||
|
SubscriptionInfo subInfo = createSubscriptionInfo(1, 1);
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, subInfo, true);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_fromPsimAndPort0ToDualPortsB_dualPortsB() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingDualPortsB();
|
||||||
|
|
||||||
|
SubscriptionInfo subInfo = createSubscriptionInfo(0, 0);
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, subInfo, true);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_fromPsimAndPort1ToDualPortsA_dualPortsA() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingDualPortsA();
|
||||||
|
|
||||||
|
SubscriptionInfo subInfo = createSubscriptionInfo(0, 0);
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, subInfo, true);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_noPsimAndFromPsimAndPort0ToDualPortsB_dualPortsB() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingDualPortsB();
|
||||||
|
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, null, true);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_noPsimAndFromPsimAndPort1ToDualPortsA_dualPortsA() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingDualPortsA();
|
||||||
|
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, null, true);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_fromDualPortsAToPsimAndPort1_psimAndPort1() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingPsimAndPort1();
|
||||||
|
|
||||||
|
SubscriptionInfo subInfo = createSubscriptionInfo(0, 0);
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_fromDualPortsAToPsimAndPort0_psimAndPort0() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingPsimAndPort0();
|
||||||
|
|
||||||
|
SubscriptionInfo subInfo = createSubscriptionInfo(1, 1);
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_fromDualPortsBToPsimAndPort1_psimAndPort1() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingPsimAndPort1();
|
||||||
|
|
||||||
|
SubscriptionInfo subInfo = createSubscriptionInfo(1, 0);
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void prepareUiccSlotMappings_fromDualPortsBToPsimAndPort0_psimAndPort0() {
|
||||||
|
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB();
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings =
|
||||||
|
createUiccSlotMappingPsimAndPort0();
|
||||||
|
|
||||||
|
SubscriptionInfo subInfo = createSubscriptionInfo(0, 1);
|
||||||
|
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
|
||||||
|
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true);
|
||||||
|
|
||||||
|
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SubscriptionInfo createSubscriptionInfo(int logicalSlotIndex, int portIndex) {
|
||||||
|
return new SubscriptionInfo(
|
||||||
|
0, "", logicalSlotIndex, "", "", 0, 0, "", 0, null, "", "", "",
|
||||||
|
true /* isEmbedded */,
|
||||||
|
null, "", 25,
|
||||||
|
false, null, false, 0, 0, 0, null, null, true, portIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void compareTwoUiccSlotMappings(Collection<UiccSlotMapping> testUiccSlotMappings,
|
||||||
|
Collection<UiccSlotMapping> verifyUiccSlotMappings) {
|
||||||
|
assertThat(testUiccSlotMappings.size()).isEqualTo(verifyUiccSlotMappings.size());
|
||||||
|
Iterator<UiccSlotMapping> testIterator = testUiccSlotMappings.iterator();
|
||||||
|
Iterator<UiccSlotMapping> verifyIterator = verifyUiccSlotMappings.iterator();
|
||||||
|
while (testIterator.hasNext()) {
|
||||||
|
UiccSlotMapping testUiccSlotMapping = testIterator.next();
|
||||||
|
UiccSlotMapping verifyUiccSlotMapping = verifyIterator.next();
|
||||||
|
assertThat(testUiccSlotMapping.getLogicalSlotIndex()).isEqualTo(
|
||||||
|
verifyUiccSlotMapping.getLogicalSlotIndex());
|
||||||
|
assertThat(testUiccSlotMapping.getPortIndex()).isEqualTo(
|
||||||
|
verifyUiccSlotMapping.getPortIndex());
|
||||||
|
assertThat(testUiccSlotMapping.getPhysicalSlotIndex()).isEqualTo(
|
||||||
|
verifyUiccSlotMapping.getPhysicalSlotIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Device | |Slot |
|
||||||
|
// Working| |Mapping|
|
||||||
|
// State |Type |Mode |Friendly name
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// Single |SIM pSIM [RIL 0] |1 |pSIM active
|
||||||
|
// Single |SIM MEP Port #0 [RIL0] |2 |eSIM Port0 active
|
||||||
|
// Single |SIM MEP Port #1 [RIL0] |2.1 |eSIM Port1 active
|
||||||
|
// DSDS |pSIM [RIL 0] + MEP Port #0 [RIL 1] |3 |pSIM+Port0
|
||||||
|
// DSDS |pSIM [RIL 0] + MEP Port #1 [RIL 1] |3.1 |pSIM+Port1
|
||||||
|
// DSDS |MEP Port #0 [RIL 0] + MEP Port #1 [RIL1]|3.2 |Dual-Ports-A
|
||||||
|
// DSDS |MEP Port #1 [RIL 0] + MEP Port #0 [RIL1]|4 |Dual-Ports-B
|
||||||
|
private List<UiccSlotMapping> createUiccSlotMappingSsModePsimActive() {
|
||||||
|
List<UiccSlotMapping> slotMap = new ArrayList<>();
|
||||||
|
slotMap.add(new UiccSlotMapping(0, PSIM_PHYSICAL_SLOT, 0));
|
||||||
|
|
||||||
|
return slotMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<UiccSlotMapping> createUiccSlotMappingSsModeEsimPort0Active() {
|
||||||
|
List<UiccSlotMapping> slotMap = new ArrayList<>();
|
||||||
|
slotMap.add(new UiccSlotMapping(0, ESIM_PHYSICAL_SLOT, 0));
|
||||||
|
|
||||||
|
return slotMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<UiccSlotMapping> createUiccSlotMappingSsModeEsimPort1Active() {
|
||||||
|
List<UiccSlotMapping> slotMap = new ArrayList<>();
|
||||||
|
slotMap.add(new UiccSlotMapping(1, ESIM_PHYSICAL_SLOT, 0));
|
||||||
|
|
||||||
|
return slotMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<UiccSlotMapping> createUiccSlotMappingPsimAndPort0() {
|
||||||
|
List<UiccSlotMapping> slotMap = new ArrayList<>();
|
||||||
|
slotMap.add(new UiccSlotMapping(0, PSIM_PHYSICAL_SLOT, 0));
|
||||||
|
slotMap.add(new UiccSlotMapping(0, ESIM_PHYSICAL_SLOT, 1));
|
||||||
|
|
||||||
|
return slotMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<UiccSlotMapping> createUiccSlotMappingPsimAndPort1() {
|
||||||
|
List<UiccSlotMapping> slotMap = new ArrayList<>();
|
||||||
|
slotMap.add(new UiccSlotMapping(0, PSIM_PHYSICAL_SLOT, 0));
|
||||||
|
slotMap.add(new UiccSlotMapping(1, ESIM_PHYSICAL_SLOT, 1));
|
||||||
|
|
||||||
|
return slotMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<UiccSlotMapping> createUiccSlotMappingDualPortsA() {
|
||||||
|
List<UiccSlotMapping> slotMap = new ArrayList<>();
|
||||||
|
slotMap.add(new UiccSlotMapping(0, ESIM_PHYSICAL_SLOT, 0));
|
||||||
|
slotMap.add(new UiccSlotMapping(1, ESIM_PHYSICAL_SLOT, 1));
|
||||||
|
|
||||||
|
return slotMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<UiccSlotMapping> createUiccSlotMappingDualPortsB() {
|
||||||
|
List<UiccSlotMapping> slotMap = new ArrayList<>();
|
||||||
|
slotMap.add(new UiccSlotMapping(1, ESIM_PHYSICAL_SLOT, 0));
|
||||||
|
slotMap.add(new UiccSlotMapping(0, ESIM_PHYSICAL_SLOT, 1));
|
||||||
|
|
||||||
|
return slotMap;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "oneSimSlotDevice" has below cases
|
* The "oneSimSlotDevice" has below cases
|
||||||
* 1) The device is one psim slot and no esim slot
|
* 1) The device is one psim slot and no esim slot
|
||||||
@@ -112,27 +362,27 @@ public class UiccSlotUtilTest {
|
|||||||
* 2) The device is two psim slots
|
* 2) The device is two psim slots
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private UiccSlotInfo[] oneSimSlotDevice_ActivePsim() {
|
private UiccSlotInfo[] oneSimSlotDeviceActivePsim() {
|
||||||
return new UiccSlotInfo[]{createUiccSlotInfo(false, true, 0, true)};
|
return new UiccSlotInfo[]{createUiccSlotInfo(false, true, 0, true)};
|
||||||
}
|
}
|
||||||
|
|
||||||
private UiccSlotInfo[] oneSimSlotDevice_ActiveEsim() {
|
private UiccSlotInfo[] oneSimSlotDeviceActiveEsim() {
|
||||||
return new UiccSlotInfo[]{createUiccSlotInfo(true, false, 1, true)};
|
return new UiccSlotInfo[]{createUiccSlotInfo(true, false, 1, true)};
|
||||||
}
|
}
|
||||||
|
|
||||||
private UiccSlotInfo[] twoSimSlotsDevice_ActivePsimActiveEsim() {
|
private UiccSlotInfo[] twoSimSlotsDeviceActivePsimActiveEsim() {
|
||||||
return new UiccSlotInfo[]{
|
return new UiccSlotInfo[]{
|
||||||
createUiccSlotInfo(false, true, 0, true),
|
createUiccSlotInfo(false, true, 0, true),
|
||||||
createUiccSlotInfo(true, false, 1, true)};
|
createUiccSlotInfo(true, false, 1, true)};
|
||||||
}
|
}
|
||||||
|
|
||||||
private UiccSlotInfo[] twoSimSlotsDevice_ActiveEsimActivePsim() {
|
private UiccSlotInfo[] twoSimSlotsDeviceActiveEsimActivePsim() {
|
||||||
return new UiccSlotInfo[]{
|
return new UiccSlotInfo[]{
|
||||||
createUiccSlotInfo(true, false, 0, true),
|
createUiccSlotInfo(true, false, 0, true),
|
||||||
createUiccSlotInfo(false, true, 1, true)};
|
createUiccSlotInfo(false, true, 1, true)};
|
||||||
}
|
}
|
||||||
|
|
||||||
private UiccSlotInfo[] twoSimSlotsDevice_twoActiveEsims() {
|
private UiccSlotInfo[] twoSimSlotsDeviceTwoActiveEsims() {
|
||||||
// device supports MEP, so device can enable two esims.
|
// device supports MEP, so device can enable two esims.
|
||||||
// If device has psim slot, the UiccSlotInfo of psim always be in UiccSlotInfo[].
|
// If device has psim slot, the UiccSlotInfo of psim always be in UiccSlotInfo[].
|
||||||
return new UiccSlotInfo[]{
|
return new UiccSlotInfo[]{
|
||||||
@@ -140,19 +390,19 @@ public class UiccSlotUtilTest {
|
|||||||
createUiccSlotInfoForEsimMep(0, true, 1, true)};
|
createUiccSlotInfoForEsimMep(0, true, 1, true)};
|
||||||
}
|
}
|
||||||
|
|
||||||
private UiccSlotInfo[] twoSimSlotsDevice_ActivePsimInactiveEsim() {
|
private UiccSlotInfo[] twoSimSlotsDeviceActivePsimInactiveEsim() {
|
||||||
return new UiccSlotInfo[]{
|
return new UiccSlotInfo[]{
|
||||||
createUiccSlotInfo(false, true, 0, true),
|
createUiccSlotInfo(false, true, 0, true),
|
||||||
createUiccSlotInfo(true, false, -1, false)};
|
createUiccSlotInfo(true, false, -1, false)};
|
||||||
}
|
}
|
||||||
|
|
||||||
private UiccSlotInfo[] twoSimSlotsDevice_InactivePsimActiveEsim() {
|
private UiccSlotInfo[] twoSimSlotsDeviceInactivePsimActiveEsim() {
|
||||||
return new UiccSlotInfo[]{
|
return new UiccSlotInfo[]{
|
||||||
createUiccSlotInfo(false, true, 0, false),
|
createUiccSlotInfo(false, true, 0, false),
|
||||||
createUiccSlotInfo(true, false, 1, true)};
|
createUiccSlotInfo(true, false, 1, true)};
|
||||||
}
|
}
|
||||||
|
|
||||||
private UiccSlotInfo[] twoSimSlotsDevice_NoInsertPsimActiveEsim() {
|
private UiccSlotInfo[] twoSimSlotsDeviceNoInsertPsimActiveEsim() {
|
||||||
return new UiccSlotInfo[]{
|
return new UiccSlotInfo[]{
|
||||||
createUiccSlotInfo(false, true, -1, false),
|
createUiccSlotInfo(false, true, -1, false),
|
||||||
createUiccSlotInfo(true, false, 1, true)};
|
createUiccSlotInfo(true, false, 1, true)};
|
||||||
|
Reference in New Issue
Block a user