Merge changes Iee650897,Icb00b3fc,I5c6ad4b3,Ief4299e7,I85800227, ... am: 31c40b00e7
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2043028 Change-Id: I473db94863284e07184f90f6f442d3d405c87e32 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import android.app.FragmentManager;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.UiccCardInfo;
|
import android.telephony.UiccCardInfo;
|
||||||
import android.telephony.UiccSlotMapping;
|
import android.telephony.UiccSlotMapping;
|
||||||
import android.telephony.euicc.EuiccManager;
|
import android.telephony.euicc.EuiccManager;
|
||||||
@@ -34,7 +35,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
/** A headless fragment encapsulating long-running eSIM enabling/disabling operations. */
|
/** A headless fragment encapsulating long-running eSIM enabling/disabling operations. */
|
||||||
public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
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 =
|
private static final String ACTION_SWITCH_TO_SUBSCRIPTION =
|
||||||
"com.android.settings.network.SWITCH_TO_SUBSCRIPTION";
|
"com.android.settings.network.SWITCH_TO_SUBSCRIPTION";
|
||||||
private static final int ESIM_SLOT_ID = 1;
|
private static final int ESIM_SLOT_ID = 1;
|
||||||
@@ -42,6 +43,8 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
|||||||
private PendingIntent mCallbackIntent;
|
private PendingIntent mCallbackIntent;
|
||||||
private int mSubId;
|
private int mSubId;
|
||||||
private int mPort;
|
private int mPort;
|
||||||
|
private SubscriptionInfo mRemovedSubInfo;
|
||||||
|
private boolean mIsDuringSimSlotMapping;
|
||||||
|
|
||||||
/** Returns a SwitchToEuiccSubscriptionSidecar sidecar instance. */
|
/** Returns a SwitchToEuiccSubscriptionSidecar sidecar instance. */
|
||||||
public static SwitchToEuiccSubscriptionSidecar get(FragmentManager fm) {
|
public static SwitchToEuiccSubscriptionSidecar get(FragmentManager fm) {
|
||||||
@@ -93,10 +96,35 @@ 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) : port;
|
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);
|
||||||
|
|
||||||
|
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);
|
mSwitchSlotSidecar.runSwitchToEuiccSlot(getTargetSlot(), mPort, removedSubInfo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int getTargetPortId(SubscriptionInfo removedSubInfo) {
|
private int getTargetPortId(SubscriptionInfo removedSubInfo) {
|
||||||
if (!mTelephonyManager.isMultiSimEnabled() || !isMultipleEnabledProfilesSupported()) {
|
if (!mTelephonyManager.isMultiSimEnabled() || !isMultipleEnabledProfilesSupported()) {
|
||||||
@@ -136,8 +164,7 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
|||||||
switch (mSwitchSlotSidecar.getState()) {
|
switch (mSwitchSlotSidecar.getState()) {
|
||||||
case State.SUCCESS:
|
case State.SUCCESS:
|
||||||
mSwitchSlotSidecar.reset();
|
mSwitchSlotSidecar.reset();
|
||||||
Log.i(TAG,
|
Log.i(TAG, "Successfully SimSlotMapping. Start to enable/disable esim");
|
||||||
"Successfully SimSlotMapping. Start to enable/disable esim");
|
|
||||||
switchToSubscription();
|
switchToSubscription();
|
||||||
break;
|
break;
|
||||||
case State.ERROR:
|
case State.ERROR:
|
||||||
@@ -174,4 +201,16 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
|||||||
mEuiccManager.switchToSubscription(mSubId, mPort, getContext().getMainExecutor(),
|
mEuiccManager.switchToSubscription(mSubId, mPort, getContext().getMainExecutor(),
|
||||||
callback);
|
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
|
public class SwitchToRemovableSlotSidecar extends EuiccOperationSidecar
|
||||||
implements SidecarFragment.Listener {
|
implements SidecarFragment.Listener {
|
||||||
|
private static final String TAG = "SwitchRemovableSidecar";
|
||||||
private static final String TAG = "DisableSubscriptionAndSwitchSlotSidecar";
|
|
||||||
private static final String ACTION_DISABLE_SUBSCRIPTION_AND_SWITCH_SLOT =
|
private static final String ACTION_DISABLE_SUBSCRIPTION_AND_SWITCH_SLOT =
|
||||||
"disable_subscription_and_switch_slot_sidecar";
|
"disable_subscription_and_switch_slot_sidecar";
|
||||||
|
|
||||||
@@ -115,10 +114,26 @@ public class SwitchToRemovableSlotSidecar extends EuiccOperationSidecar
|
|||||||
public void run(int physicalSlotId, SubscriptionInfo removedSubInfo) {
|
public void run(int physicalSlotId, SubscriptionInfo removedSubInfo) {
|
||||||
mPhysicalSlotId = physicalSlotId;
|
mPhysicalSlotId = physicalSlotId;
|
||||||
mRemovedSubInfo = removedSubInfo;
|
mRemovedSubInfo = removedSubInfo;
|
||||||
|
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.");
|
Log.i(TAG, "Start to switch to removable slot.");
|
||||||
mSwitchSlotSidecar.runSwitchToRemovableSlot(mPhysicalSlotId, mRemovedSubInfo);
|
mSwitchSlotSidecar.runSwitchToRemovableSlot(mPhysicalSlotId, mRemovedSubInfo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void onSwitchToSubscriptionSidecarStateChange() {
|
private void onSwitchToSubscriptionSidecarStateChange() {
|
||||||
switch (mSwitchToSubscriptionSidecar.getState()) {
|
switch (mSwitchToSubscriptionSidecar.getState()) {
|
||||||
|
Reference in New Issue
Block a user