Merge "[MEP] disable enabled esim profile before set simSlotMapping"
This commit is contained in:
committed by
Android (Google) Code Review
commit
dcc1ee42c3
@@ -20,6 +20,7 @@ import android.app.FragmentManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.UiccCardInfo;
|
||||
import android.telephony.UiccSlotMapping;
|
||||
import android.telephony.euicc.EuiccManager;
|
||||
@@ -34,7 +35,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
/** A headless fragment encapsulating long-running eSIM enabling/disabling operations. */
|
||||
public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
private static final String TAG = "SwitchToEuiccSubscriptionSidecar";
|
||||
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;
|
||||
@@ -42,6 +43,8 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
private PendingIntent mCallbackIntent;
|
||||
private int mSubId;
|
||||
private int mPort;
|
||||
private SubscriptionInfo mRemovedSubInfo;
|
||||
private boolean mIsDuringSimSlotMapping;
|
||||
|
||||
/** Returns a SwitchToEuiccSubscriptionSidecar sidecar instance. */
|
||||
public static SwitchToEuiccSubscriptionSidecar get(FragmentManager fm) {
|
||||
@@ -93,9 +96,34 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
// 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;
|
||||
Log.i(TAG, "The SubId is " + mSubId + "The port is " + mPort);
|
||||
mRemovedSubInfo = removedSubInfo;
|
||||
Log.i(TAG, "The SubId is " + mSubId + ". The port is " + mPort);
|
||||
|
||||
mSwitchSlotSidecar.runSwitchToEuiccSlot(getTargetSlot(), mPort, removedSubInfo);
|
||||
if (mTelephonyManager.isMultiSimEnabled() && removedSubInfo != null
|
||||
&& removedSubInfo.isEmbedded()) {
|
||||
// In DSDS mode+MEP, if the replaced esim is active, then it should be disabled esim
|
||||
// profile before changing SimSlotMapping process.
|
||||
// Use INVALID_SUBSCRIPTION_ID to disable the esim profile.
|
||||
// The SimSlotMapping is ready, then to execute activate/inactivate esim.
|
||||
mIsDuringSimSlotMapping = true;
|
||||
EuiccManager.ResultListener callback = new EuiccManager.ResultListener() {
|
||||
@Override
|
||||
public void onComplete(int resultCode, Intent resultIntent) {
|
||||
Log.i(TAG, String.format("Result code : %d;", resultCode));
|
||||
if (resultCode == EuiccManager.EMBEDDED_SUBSCRIPTION_RESULT_OK) {
|
||||
mSwitchSlotSidecar.runSwitchToEuiccSlot(getTargetSlot(), mPort,
|
||||
removedSubInfo);
|
||||
} else {
|
||||
setState(State.ERROR, resultCode);
|
||||
}
|
||||
}
|
||||
};
|
||||
mEuiccManager.switchToSubscription(SubscriptionManager.INVALID_SUBSCRIPTION_ID, mPort,
|
||||
getContext().getMainExecutor(),
|
||||
callback);
|
||||
} else {
|
||||
mSwitchSlotSidecar.runSwitchToEuiccSlot(getTargetSlot(), mPort, removedSubInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private int getTargetPortId(SubscriptionInfo removedSubInfo) {
|
||||
@@ -136,8 +164,7 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
switch (mSwitchSlotSidecar.getState()) {
|
||||
case State.SUCCESS:
|
||||
mSwitchSlotSidecar.reset();
|
||||
Log.i(TAG,
|
||||
"Successfully SimSlotMapping. Start to enable/disable esim");
|
||||
Log.i(TAG, "Successfully SimSlotMapping. Start to enable/disable esim");
|
||||
switchToSubscription();
|
||||
break;
|
||||
case State.ERROR:
|
||||
@@ -174,4 +201,16 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
mEuiccManager.switchToSubscription(mSubId, mPort, getContext().getMainExecutor(),
|
||||
callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActionReceived() {
|
||||
if (getResultCode() == EuiccManager.EMBEDDED_SUBSCRIPTION_RESULT_OK
|
||||
&& mIsDuringSimSlotMapping) {
|
||||
// Continue to switch the SimSlotMapping, after the esim is disabled.
|
||||
mIsDuringSimSlotMapping = false;
|
||||
mSwitchSlotSidecar.runSwitchToEuiccSlot(getTargetSlot(), mPort, mRemovedSubInfo);
|
||||
} else {
|
||||
super.onActionReceived();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,8 +31,7 @@ import com.android.settings.network.telephony.EuiccOperationSidecar;
|
||||
*/
|
||||
public class SwitchToRemovableSlotSidecar extends EuiccOperationSidecar
|
||||
implements SidecarFragment.Listener {
|
||||
|
||||
private static final String TAG = "DisableSubscriptionAndSwitchSlotSidecar";
|
||||
private static final String TAG = "SwitchRemovableSidecar";
|
||||
private static final String ACTION_DISABLE_SUBSCRIPTION_AND_SWITCH_SLOT =
|
||||
"disable_subscription_and_switch_slot_sidecar";
|
||||
|
||||
@@ -115,9 +114,25 @@ public class SwitchToRemovableSlotSidecar extends EuiccOperationSidecar
|
||||
public void run(int physicalSlotId, SubscriptionInfo removedSubInfo) {
|
||||
mPhysicalSlotId = physicalSlotId;
|
||||
mRemovedSubInfo = removedSubInfo;
|
||||
|
||||
Log.i(TAG, "Start to switch to removable slot.");
|
||||
mSwitchSlotSidecar.runSwitchToRemovableSlot(mPhysicalSlotId, mRemovedSubInfo);
|
||||
SubscriptionManager subscriptionManager =
|
||||
getContext().getSystemService(SubscriptionManager.class);
|
||||
if (!mTelephonyManager.isMultiSimEnabled()
|
||||
&& SubscriptionUtil.getActiveSubscriptions(subscriptionManager).stream().anyMatch(
|
||||
SubscriptionInfo::isEmbedded)) {
|
||||
// In SS mode, the esim is active, then inactivate the esim.
|
||||
Log.i(TAG, "There is an active eSIM profile. Disable the profile first.");
|
||||
// Use INVALID_SUBSCRIPTION_ID to disable the only active profile.
|
||||
mSwitchToSubscriptionSidecar.run(SubscriptionManager.INVALID_SUBSCRIPTION_ID, 0, null);
|
||||
} else if (mTelephonyManager.isMultiSimEnabled() && mRemovedSubInfo != null) {
|
||||
// In DSDS mode+MEP, if the replaced esim is active, then it should be disabled esim
|
||||
// profile before changing SimSlotMapping process.
|
||||
// Use INVALID_SUBSCRIPTION_ID to disable the esim profile.
|
||||
mSwitchToSubscriptionSidecar.run(SubscriptionManager.INVALID_SUBSCRIPTION_ID,
|
||||
mRemovedSubInfo.getPortIndex(), null);
|
||||
} else {
|
||||
Log.i(TAG, "Start to switch to removable slot.");
|
||||
mSwitchSlotSidecar.runSwitchToRemovableSlot(mPhysicalSlotId, mRemovedSubInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void onSwitchToSubscriptionSidecarStateChange() {
|
||||
|
Reference in New Issue
Block a user