[MEP]The Esim's PhysicalSlotIndex is wrong
Using the getUiccSlotInfo API to get the PhysicalSlotIndex of esim Bug: 215302360 Test: atest UiccSlotUtilTest Change-Id: Ic43d6c4a3209d24673769b71b9a148e780ee81ab
This commit is contained in:
@@ -36,6 +36,7 @@ import java.util.Collection;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
// ToDo: to do the refactor for renaming
|
||||
public class UiccSlotUtil {
|
||||
@@ -174,6 +175,28 @@ public class UiccSlotUtil {
|
||||
performSwitchToSlot(telMgr, newUiccSlotMappings, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context the application context.
|
||||
* @return the esim slot. If the value is -1, there is not the esim.
|
||||
*/
|
||||
public static int getEsimSlotId(Context context) {
|
||||
TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
|
||||
ImmutableList<UiccSlotInfo> slotInfos = UiccSlotUtil.getSlotInfos(telMgr);
|
||||
int firstEsimSlot = IntStream.range(0, slotInfos.size())
|
||||
.filter(
|
||||
index -> {
|
||||
UiccSlotInfo slotInfo = slotInfos.get(index);
|
||||
if (slotInfo == null) {
|
||||
return false;
|
||||
}
|
||||
return !slotInfo.isRemovable();
|
||||
})
|
||||
.findFirst().orElse(-1);
|
||||
|
||||
Log.i(TAG, "firstEsimSlot: " + firstEsimSlot);
|
||||
return firstEsimSlot;
|
||||
}
|
||||
|
||||
private static boolean isTargetSlotActive(Collection<UiccSlotMapping> uiccSlotMappings,
|
||||
int slotId, int port) {
|
||||
return uiccSlotMappings.stream()
|
||||
|
Reference in New Issue
Block a user