[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:
@@ -37,7 +37,6 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
private static final String TAG = "SwitchToEuiccSidecar";
|
||||
private static final String ACTION_SWITCH_TO_SUBSCRIPTION =
|
||||
"com.android.settings.network.SWITCH_TO_SUBSCRIPTION";
|
||||
private static final int ESIM_SLOT_ID = 1;
|
||||
|
||||
private PendingIntent mCallbackIntent;
|
||||
private int mSubId;
|
||||
@@ -92,11 +91,20 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
setState(State.RUNNING, Substate.UNUSED);
|
||||
mCallbackIntent = createCallbackIntent();
|
||||
mSubId = subscriptionId;
|
||||
int targetSlot = getTargetSlot();
|
||||
if (targetSlot < 0) {
|
||||
Log.d(TAG, "There is no esim, the TargetSlot is " + targetSlot);
|
||||
setState(State.ERROR, Substate.UNUSED);
|
||||
return;
|
||||
}
|
||||
|
||||
// To check whether the esim slot's port is active. If yes, skip setSlotMapping. If no,
|
||||
// set this slot+port into setSimSlotMapping.
|
||||
mPort = (port < 0) ? getTargetPortId(removedSubInfo) : port;
|
||||
mPort = (port < 0) ? getTargetPortId(removedSubInfo, targetSlot) : port;
|
||||
mRemovedSubInfo = removedSubInfo;
|
||||
Log.i(TAG, "The SubId is " + mSubId + ". The port is " + mPort);
|
||||
Log.d(TAG,
|
||||
String.format("set esim into the Slot%d SubId%d:Port%d",
|
||||
targetSlot, mSubId, mPort));
|
||||
|
||||
if (mTelephonyManager.isMultiSimEnabled() && removedSubInfo != null
|
||||
&& removedSubInfo.isEmbedded()) {
|
||||
@@ -108,11 +116,11 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
mEuiccManager.switchToSubscription(SubscriptionManager.INVALID_SUBSCRIPTION_ID, mPort,
|
||||
mCallbackIntent);
|
||||
} else {
|
||||
mSwitchSlotSidecar.runSwitchToEuiccSlot(getTargetSlot(), mPort, removedSubInfo);
|
||||
mSwitchSlotSidecar.runSwitchToEuiccSlot(targetSlot, mPort, removedSubInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private int getTargetPortId(SubscriptionInfo removedSubInfo) {
|
||||
private int getTargetPortId(SubscriptionInfo removedSubInfo, int targetSlot) {
|
||||
if (!mTelephonyManager.isMultiSimEnabled() || !isMultipleEnabledProfilesSupported()) {
|
||||
// In the 'SS mode' or 'DSDS+no MEP', the port is 0.
|
||||
return 0;
|
||||
@@ -124,16 +132,19 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
return removedSubInfo.getPortIndex();
|
||||
}
|
||||
|
||||
// In DSDS+MEP mode, the removedSubInfo is psim or is null, it means the this esim need
|
||||
// In DSDS+MEP mode, the removedSubInfo is psim or is null, it means this esim needs
|
||||
// another port in the esim slot.
|
||||
// To find another esim's port and value is from 0;
|
||||
// To find another esim's port and value is from 0.
|
||||
// For example:
|
||||
// 1) If there is no enabled esim and the user add new esim. This new esim's port is 0.
|
||||
// 2) If there is one enabled esim and the user add new esim. This new esim's port is 1.
|
||||
int port = 0;
|
||||
Collection<UiccSlotMapping> uiccSlotMappings = mTelephonyManager.getSimSlotMapping();
|
||||
for (UiccSlotMapping uiccSlotMapping :
|
||||
uiccSlotMappings.stream()
|
||||
.filter(
|
||||
uiccSlotMapping -> uiccSlotMapping.getPhysicalSlotIndex()
|
||||
== getTargetSlot())
|
||||
== targetSlot)
|
||||
.collect(Collectors.toList())) {
|
||||
if (uiccSlotMapping.getPortIndex() == port) {
|
||||
port++;
|
||||
@@ -143,7 +154,7 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
}
|
||||
|
||||
private int getTargetSlot() {
|
||||
return ESIM_SLOT_ID;
|
||||
return UiccSlotUtil.getEsimSlotId(getContext());
|
||||
}
|
||||
|
||||
private void onSwitchSlotSidecarStateChange() {
|
||||
|
Reference in New Issue
Block a user