[MEP] the port id is wrong am: 9ee91da8e1
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2063563 Change-Id: I439d109e094d572c9bf645e75b46e4eb510d474b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -21,14 +21,13 @@ import android.app.PendingIntent;
|
|||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.UiccCardInfo;
|
import android.telephony.UiccCardInfo;
|
||||||
import android.telephony.UiccSlotMapping;
|
|
||||||
import android.telephony.euicc.EuiccManager;
|
import android.telephony.euicc.EuiccManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.SidecarFragment;
|
import com.android.settings.SidecarFragment;
|
||||||
import com.android.settings.network.telephony.EuiccOperationSidecar;
|
import com.android.settings.network.telephony.EuiccOperationSidecar;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -95,11 +94,11 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
|||||||
|
|
||||||
// To check whether the esim slot's port is active. If yes, skip setSlotMapping. If no,
|
// To check whether the esim slot's port is active. If yes, skip setSlotMapping. If no,
|
||||||
// set this slot+port into setSimSlotMapping.
|
// set this slot+port into setSimSlotMapping.
|
||||||
mPort = (port < 0) ? getTargetPortId(removedSubInfo, targetSlot) : port;
|
mPort = (port < 0) ? getTargetPortId(removedSubInfo) : port;
|
||||||
mRemovedSubInfo = removedSubInfo;
|
mRemovedSubInfo = removedSubInfo;
|
||||||
Log.d(TAG,
|
Log.d(TAG,
|
||||||
String.format("set esim into the Slot%d SubId%d:Port%d",
|
String.format("set esim into the SubId%d Slot%d:Port%d",
|
||||||
targetSlot, mSubId, mPort));
|
mSubId, targetSlot, mPort));
|
||||||
|
|
||||||
if (mTelephonyManager.isMultiSimEnabled() && removedSubInfo != null
|
if (mTelephonyManager.isMultiSimEnabled() && removedSubInfo != null
|
||||||
&& removedSubInfo.isEmbedded()) {
|
&& removedSubInfo.isEmbedded()) {
|
||||||
@@ -115,7 +114,7 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getTargetPortId(SubscriptionInfo removedSubInfo, int targetSlot) {
|
private int getTargetPortId(SubscriptionInfo removedSubInfo) {
|
||||||
if (!mTelephonyManager.isMultiSimEnabled() || !isMultipleEnabledProfilesSupported()) {
|
if (!mTelephonyManager.isMultiSimEnabled() || !isMultipleEnabledProfilesSupported()) {
|
||||||
// In the 'SS mode' or 'DSDS+no MEP', the port is 0.
|
// In the 'SS mode' or 'DSDS+no MEP', the port is 0.
|
||||||
return 0;
|
return 0;
|
||||||
@@ -128,20 +127,25 @@ 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
|
||||||
// another port in the esim slot.
|
// a new corresponding port in the esim slot.
|
||||||
// To find another esim's port and value is from 0.
|
|
||||||
// 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 0.
|
||||||
// 2) If there is one enabled esim and the user add new esim. This new esim's port is 1.
|
// 2) If there is one enabled esim in port0 and the user add new esim. This new esim's
|
||||||
|
// port is 1.
|
||||||
|
// 3) If there is one enabled esim in port1 and the user add new esim. This new esim's
|
||||||
|
// port is 0.
|
||||||
|
|
||||||
int port = 0;
|
int port = 0;
|
||||||
Collection<UiccSlotMapping> uiccSlotMappings = mTelephonyManager.getSimSlotMapping();
|
SubscriptionManager subscriptionManager = getContext().getSystemService(
|
||||||
for (UiccSlotMapping uiccSlotMapping :
|
SubscriptionManager.class);
|
||||||
uiccSlotMappings.stream()
|
List<SubscriptionInfo> activeEsimSubInfos =
|
||||||
.filter(
|
SubscriptionUtil.getActiveSubscriptions(subscriptionManager)
|
||||||
uiccSlotMapping -> uiccSlotMapping.getPhysicalSlotIndex()
|
.stream()
|
||||||
== targetSlot)
|
.filter(i -> i.isEmbedded())
|
||||||
.collect(Collectors.toList())) {
|
.sorted(Comparator.comparingInt(SubscriptionInfo::getPortIndex))
|
||||||
if (uiccSlotMapping.getPortIndex() == port) {
|
.collect(Collectors.toList());
|
||||||
|
for (SubscriptionInfo subscriptionInfo : activeEsimSubInfos) {
|
||||||
|
if (subscriptionInfo.getPortIndex() == port) {
|
||||||
port++;
|
port++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user