Using current esim port of active esim slot

If there is no active esim and the active esim slot, then enabling esim
uses the active esim slot's port.

Bug: 394758842
Test: manual test
Flag: EXEMPT bugfix

Change-Id: Icd478a92662584d433e16b129da98204e9e2f5f3
This commit is contained in:
songferngwang
2025-03-19 10:30:50 +00:00
parent b9fa9201af
commit 62163de585

View File

@@ -143,12 +143,14 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
return 0; return 0;
} }
Collection<UiccSlotMapping> uiccSlotMappings = mTelephonyManager.getSimSlotMapping();
Log.d(TAG, "The UiccSlotMapping: " + uiccSlotMappings);
if (!mTelephonyManager.isMultiSimEnabled()) { if (!mTelephonyManager.isMultiSimEnabled()) {
// In the 'SS mode' // In the 'SS mode'
// If there is the esim slot is active, the port is from the current esim slot. // If there is the esim slot is active, the port is from the current esim slot.
// If there is no esim slot in device, then the esim's port is 0. // If there is no esim slot in device, then the esim's port is 0.
Collection<UiccSlotMapping> uiccSlotMappings = mTelephonyManager.getSimSlotMapping(); Log.d(TAG, "In SS mode, to find the active esim slot's port."
Log.d(TAG, "In SS mode, the UiccSlotMapping: " + uiccSlotMappings); + "If no active esim slot, the port is 0");
return uiccSlotMappings.stream() return uiccSlotMappings.stream()
.filter(i -> i.getPhysicalSlotIndex() == physicalEsimSlotIndex) .filter(i -> i.getPhysicalSlotIndex() == physicalEsimSlotIndex)
.mapToInt(i -> i.getPortIndex()) .mapToInt(i -> i.getPortIndex())
@@ -164,7 +166,8 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
// In DSDS+MEP mode, the removedSubInfo is psim or is null, it means this esim needs // In DSDS+MEP mode, the removedSubInfo is psim or is null, it means this esim needs
// a new corresponding port in the esim slot. // a new corresponding port in the esim slot.
// For example: // For example:
// 1) If there is no enabled esim and the user add new esim. This new esim's port is 0. // 1) If there is no enabled esim and the user add new esim. This new esim's port is
// active esim slot's port.
// 2) If there is one enabled esim in port0 and the user add new esim. This new esim's // 2) If there is one enabled esim in port0 and the user add new esim. This new esim's
// port is 1. // port is 1.
// 3) If there is one enabled esim in port1 and the user add new esim. This new esim's // 3) If there is one enabled esim in port1 and the user add new esim. This new esim's
@@ -180,6 +183,20 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
.filter(i -> i.isEmbedded()) .filter(i -> i.isEmbedded())
.sorted(Comparator.comparingInt(SubscriptionInfo::getPortIndex)) .sorted(Comparator.comparingInt(SubscriptionInfo::getPortIndex))
.collect(Collectors.toList()); .collect(Collectors.toList());
// In DSDS+MEP mode, if there is the active esim slot and no active esim at that slot,
// then using this active esim slot's port.
// If there is no esim slot in device, then the esim's port is 0.
if (activeEsimSubInfos.isEmpty()) {
Log.d(TAG, "In DSDS+MEP mode, no active esim. return the active esim slot's port."
+ "If no active esim slot, the port is 0");
return uiccSlotMappings.stream()
.filter(i -> i.getPhysicalSlotIndex() == physicalEsimSlotIndex)
.mapToInt(i -> i.getPortIndex())
.sorted()
.findFirst().orElse(0);
}
for (SubscriptionInfo subscriptionInfo : activeEsimSubInfos) { for (SubscriptionInfo subscriptionInfo : activeEsimSubInfos) {
if (subscriptionInfo.getPortIndex() == port) { if (subscriptionInfo.getPortIndex() == port) {
port++; port++;