[MEP] The subscriptionInfo's getSimSlotIndex is logical slotId

1. The subscriptionInfo's getSimSlotIndex is logical slotId. The code
   should compare it with uiccSlotMapping.getLogicalSlotIndex()
2. Rename the parameters for the readability.
3. The mobile network selection dialog did not be closed after user clicked.

Bug: 219951253
Test: manual test.
Change-Id: I7fef78547f4e6283791cd15a03275eaefeb50e3c
(cherry picked from commit 181f8179f1)
This commit is contained in:
SongFerngWang
2022-02-18 19:29:16 +08:00
committed by SongFerng Wang
parent 8f84e7a9e7
commit e90d80cc52
4 changed files with 46 additions and 55 deletions

View File

@@ -78,11 +78,19 @@ public class SwitchSlotSidecar
super.run(param); super.run(param);
} }
/** Starts switching to the removable slot. */ /**
public void runSwitchToEuiccSlot(int id, int port, SubscriptionInfo removedSubInfo) { * Start the SimSlotMapping process if the euicc slot is not in SimSlotMapping list.
* @param physicalSlotId The physical slot id.
* @param port The port id.
* @param removedSubInfo The subscriptionInfo which is selected by the user to disable when all
* of sim slots are full in the device. If all of slots are not full in
* the device, then this is null.
*/
public void runSwitchToEuiccSlot(int physicalSlotId, int port,
SubscriptionInfo removedSubInfo) {
Param param = new Param(); Param param = new Param();
param.command = Command.SWITCH_TO_EUICC_SIM; param.command = Command.SWITCH_TO_EUICC_SIM;
param.slotId = id; param.slotId = physicalSlotId;
param.removedSubInfo = removedSubInfo; param.removedSubInfo = removedSubInfo;
param.port = port; param.port = port;
super.run(param); super.run(param);

View File

@@ -101,7 +101,7 @@ public class SwitchToRemovableSlotSidecar extends EuiccOperationSidecar
// Use INVALID_SUBSCRIPTION_ID to disable the only active profile. // Use INVALID_SUBSCRIPTION_ID to disable the only active profile.
mSwitchToSubscriptionSidecar.run(SubscriptionManager.INVALID_SUBSCRIPTION_ID, 0, null); mSwitchToSubscriptionSidecar.run(SubscriptionManager.INVALID_SUBSCRIPTION_ID, 0, null);
} else if (mTelephonyManager.isMultiSimEnabled() && mRemovedSubInfo != null) { } else if (mTelephonyManager.isMultiSimEnabled() && mRemovedSubInfo != null) {
// In DSDS mode+MEP, if the replaced esim is active, then it should be disabled esim // In DSDS mode+MEP, if the replaced esim is active, then it should disable that esim
// profile before changing SimSlotMapping process. // profile before changing SimSlotMapping process.
// Use INVALID_SUBSCRIPTION_ID to disable the esim profile. // Use INVALID_SUBSCRIPTION_ID to disable the esim profile.
mSwitchToSubscriptionSidecar.run(SubscriptionManager.INVALID_SUBSCRIPTION_ID, mSwitchToSubscriptionSidecar.run(SubscriptionManager.INVALID_SUBSCRIPTION_ID,

View File

@@ -113,9 +113,21 @@ public class UiccSlotUtil {
} }
TelephonyManager telMgr = context.getSystemService(TelephonyManager.class); TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
int inactiveRemovableSlot = getInactiveRemovableSlot(telMgr.getUiccSlotsInfo(), slotId); int inactiveRemovableSlot = getInactiveRemovableSlot(telMgr.getUiccSlotsInfo(), slotId);
Log.i(TAG, "The InactiveRemovableSlot: " + inactiveRemovableSlot);
Collection<UiccSlotMapping> uiccSlotMappings = telMgr.getSimSlotMapping();
Log.i(TAG, "The SimSlotMapping: " + uiccSlotMappings);
if (inactiveRemovableSlot == INVALID_PHYSICAL_SLOT_ID) {
// The slot is invalid slot id, then to skip this.
// The slot is active, then the sim can enable directly.
return;
}
performSwitchToSlot(telMgr, performSwitchToSlot(telMgr,
prepareUiccSlotMappingsForRemovableSlot(telMgr.getSimSlotMapping(), prepareUiccSlotMappings(uiccSlotMappings,
inactiveRemovableSlot, removedSubInfo, telMgr.isMultiSimEnabled()), inactiveRemovableSlot, /*removable sim's port Id*/ 0, removedSubInfo,
telMgr.isMultiSimEnabled()),
context); context);
} }
@@ -123,7 +135,7 @@ public class UiccSlotUtil {
* Switches to the Euicc slot. It waits for SIM_STATE_LOADED after switch. * Switches to the Euicc slot. It waits for SIM_STATE_LOADED after switch.
* *
* @param context the application context. * @param context the application context.
* @param slotId the Euicc slot id. * @param physicalSlotId the Euicc slot id.
* @param port the Euicc slot port id. * @param port the Euicc slot port id.
* @param removedSubInfo In the DSDS+MEP mode, if the all of slots have sims, it should * @param removedSubInfo In the DSDS+MEP mode, if the all of slots have sims, it should
* remove the one of active sim. * remove the one of active sim.
@@ -131,7 +143,7 @@ public class UiccSlotUtil {
* The default value is the esim slot and portId 0. * The default value is the esim slot and portId 0.
* @throws UiccSlotsException if there is an error. * @throws UiccSlotsException if there is an error.
*/ */
public static synchronized void switchToEuiccSlot(Context context, int slotId, int port, public static synchronized void switchToEuiccSlot(Context context, int physicalSlotId, int port,
SubscriptionInfo removedSubInfo) throws UiccSlotsException { SubscriptionInfo removedSubInfo) throws UiccSlotsException {
if (ThreadUtils.isMainThread()) { if (ThreadUtils.isMainThread()) {
throw new IllegalThreadStateException( throw new IllegalThreadStateException(
@@ -141,38 +153,15 @@ public class UiccSlotUtil {
Collection<UiccSlotMapping> uiccSlotMappings = telMgr.getSimSlotMapping(); Collection<UiccSlotMapping> uiccSlotMappings = telMgr.getSimSlotMapping();
Log.i(TAG, "The SimSlotMapping: " + uiccSlotMappings); Log.i(TAG, "The SimSlotMapping: " + uiccSlotMappings);
if (isTargetSlotActive(uiccSlotMappings, slotId, port)) { if (isTargetSlotActive(uiccSlotMappings, physicalSlotId, port)) {
Log.i(TAG, "The slot is active, then the sim can enable directly."); Log.i(TAG, "The slot is active, then the sim can enable directly.");
return; return;
} }
Collection<UiccSlotMapping> newUiccSlotMappings = new ArrayList<>(); performSwitchToSlot(telMgr,
if (!telMgr.isMultiSimEnabled()) { prepareUiccSlotMappings(uiccSlotMappings,
// In the 'SS mode', the port is 0. physicalSlotId, port, removedSubInfo, telMgr.isMultiSimEnabled()),
newUiccSlotMappings.add(new UiccSlotMapping(port, slotId, 0)); context);
} else {
// DSDS+MEP
// The target slot+port is not active, but the all of logical slots are full. It
// needs to replace one of logical slots.
int removedSlot =
(removedSubInfo != null) ? removedSubInfo.getSimSlotIndex() : slotId;
int removedPort = (removedSubInfo != null) ? removedSubInfo.getPortIndex() : 0;
Log.i(TAG,
String.format("Start to set SimSlotMapping from slot%d-port%d to slot%d-port%d",
slotId, port, removedSlot, removedPort));
newUiccSlotMappings =
uiccSlotMappings.stream().map(uiccSlotMapping -> {
if (uiccSlotMapping.getPhysicalSlotIndex() == removedSlot
&& uiccSlotMapping.getPortIndex() == removedPort) {
return new UiccSlotMapping(port, slotId,
uiccSlotMapping.getLogicalSlotIndex());
}
return uiccSlotMapping;
}).collect(Collectors.toList());
}
Log.i(TAG, "The SimSlotMapping: " + newUiccSlotMappings);
performSwitchToSlot(telMgr, newUiccSlotMappings, context);
} }
/** /**
@@ -198,10 +187,10 @@ public class UiccSlotUtil {
} }
private static boolean isTargetSlotActive(Collection<UiccSlotMapping> uiccSlotMappings, private static boolean isTargetSlotActive(Collection<UiccSlotMapping> uiccSlotMappings,
int slotId, int port) { int physicalSlotId, int port) {
return uiccSlotMappings.stream() return uiccSlotMappings.stream()
.anyMatch( .anyMatch(
uiccSlotMapping -> uiccSlotMapping.getPhysicalSlotIndex() == slotId uiccSlotMapping -> uiccSlotMapping.getPhysicalSlotIndex() == physicalSlotId
&& uiccSlotMapping.getPortIndex() == port); && uiccSlotMapping.getPortIndex() == port);
} }
@@ -262,37 +251,30 @@ public class UiccSlotUtil {
return INVALID_PHYSICAL_SLOT_ID; return INVALID_PHYSICAL_SLOT_ID;
} }
private static Collection<UiccSlotMapping> prepareUiccSlotMappingsForRemovableSlot( private static Collection<UiccSlotMapping> prepareUiccSlotMappings(
Collection<UiccSlotMapping> uiccSlotMappings, int slotId, Collection<UiccSlotMapping> uiccSlotMappings, int physicalSlotId, int port,
SubscriptionInfo removedSubInfo, boolean isMultiSimEnabled) { SubscriptionInfo removedSubInfo, boolean isMultiSimEnabled) {
if (slotId == INVALID_PHYSICAL_SLOT_ID
|| uiccSlotMappings.stream().anyMatch(uiccSlotMapping ->
uiccSlotMapping.getPhysicalSlotIndex() == slotId
&& uiccSlotMapping.getPortIndex() == 0)) {
// The slot is invalid slot id, then to skip this.
// The slot is active, then the sim can enable directly.
return uiccSlotMappings;
}
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.
newUiccSlotMappings.add(new UiccSlotMapping(0, slotId, 0)); newUiccSlotMappings.add(new UiccSlotMapping(port, physicalSlotId, 0));
} else if (removedSubInfo != null) { } else if (removedSubInfo != null) {
// DSDS+MEP // DSDS+MEP
// The target slot+port is not active, but the all of logical slots are full. It // The target slot+port is not active, but the all of logical slots are full. It
// needs to replace one of logical slots. // needs to replace one of logical slots.
Log.i(TAG, Log.i(TAG,
String.format("Start to set SimSlotMapping from slot%d-port%d to slot%d-port%d", String.format(
slotId, 0, removedSubInfo.getSimSlotIndex(), "Start to set SimSlotMapping from subId%d(LogicalSlot%d-Port%d) to "
removedSubInfo.getPortIndex())); + "PhysicalSlotId%d-Port%d",
removedSubInfo.getSubscriptionId(), removedSubInfo.getSimSlotIndex(),
removedSubInfo.getPortIndex(), physicalSlotId, port));
newUiccSlotMappings = newUiccSlotMappings =
uiccSlotMappings.stream().map(uiccSlotMapping -> { uiccSlotMappings.stream().map(uiccSlotMapping -> {
if (uiccSlotMapping.getPhysicalSlotIndex() if (uiccSlotMapping.getLogicalSlotIndex()
== removedSubInfo.getSimSlotIndex() == removedSubInfo.getSimSlotIndex()
&& uiccSlotMapping.getPortIndex() && uiccSlotMapping.getPortIndex()
== removedSubInfo.getPortIndex()) { == removedSubInfo.getPortIndex()) {
return new UiccSlotMapping(0, slotId, return new UiccSlotMapping(port, physicalSlotId,
uiccSlotMapping.getLogicalSlotIndex()); uiccSlotMapping.getLogicalSlotIndex());
} }
return uiccSlotMapping; return uiccSlotMapping;

View File

@@ -116,6 +116,7 @@ public class SimListDialogFragment extends SimDialogFragment {
final SimDialogActivity activity = (SimDialogActivity) getActivity(); final SimDialogActivity activity = (SimDialogActivity) getActivity();
activity.onSubscriptionSelected(getDialogType(), subId); activity.onSubscriptionSelected(getDialogType(), subId);
} }
dismiss();
} }
protected List<SubscriptionInfo> getCurrentSubscriptions() { protected List<SubscriptionInfo> getCurrentSubscriptions() {