[MEP] Inserting a pSIM while user has 2 esims, showing the MEP dialog am: 650b048749
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2063562 Change-Id: I9f5686677f2ee6562e8d5ee64a6aa7db6e78ee83 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -26,12 +26,14 @@ import android.provider.Settings;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.UiccCardInfo;
|
||||
import android.telephony.UiccSlotInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
import com.android.settings.network.UiccSlotUtil;
|
||||
import com.android.settings.network.UiccSlotsException;
|
||||
import com.android.settings.network.telephony.ToggleSubscriptionDialogActivity;
|
||||
import com.android.settings.sim.ChooseSimActivity;
|
||||
import com.android.settings.sim.DsdsDialogActivity;
|
||||
import com.android.settings.sim.SimActivationNotifier;
|
||||
@@ -40,6 +42,7 @@ import com.android.settings.sim.SwitchToEsimConfirmDialogActivity;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -83,8 +86,8 @@ public class SimSlotChangeHandler {
|
||||
throw new IllegalStateException("Cannot be called from main thread.");
|
||||
}
|
||||
|
||||
if (mTelMgr.getActiveModemCount() > 1) {
|
||||
Log.i(TAG, "The device is already in DSDS mode. Do nothing.");
|
||||
if (mTelMgr.getActiveModemCount() > 1 && !isMultipleEnabledProfilesSupported()) {
|
||||
Log.i(TAG, "The device is already in DSDS mode and no MEP. Do nothing.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,17 +99,30 @@ public class SimSlotChangeHandler {
|
||||
|
||||
int lastRemovableSlotState = getLastRemovableSimSlotState(mContext);
|
||||
int currentRemovableSlotState = removableSlotInfo.getCardStateInfo();
|
||||
boolean isRemovableSimInserted =
|
||||
lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT
|
||||
&& currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT;
|
||||
boolean isRemovableSimRemoved =
|
||||
lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT
|
||||
&& currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT;
|
||||
|
||||
// Sets the current removable slot state.
|
||||
setRemovableSimSlotState(mContext, currentRemovableSlotState);
|
||||
|
||||
if (lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT
|
||||
&& currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT) {
|
||||
if (mTelMgr.getActiveModemCount() > 1 && isMultipleEnabledProfilesSupported()) {
|
||||
if(!isRemovableSimInserted) {
|
||||
Log.i(TAG, "Removable Sim is not inserted in DSDS mode and MEP. Do nothing.");
|
||||
return;
|
||||
}
|
||||
handleRemovableSimInsertUnderDsdsMep(removableSlotInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isRemovableSimInserted) {
|
||||
handleSimInsert(removableSlotInfo);
|
||||
return;
|
||||
}
|
||||
if (lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT
|
||||
&& currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT) {
|
||||
if (isRemovableSimRemoved) {
|
||||
handleSimRemove(removableSlotInfo);
|
||||
return;
|
||||
}
|
||||
@@ -232,6 +248,23 @@ public class SimSlotChangeHandler {
|
||||
startChooseSimActivity(false);
|
||||
}
|
||||
|
||||
private void handleRemovableSimInsertUnderDsdsMep(UiccSlotInfo removableSlotInfo) {
|
||||
Log.i(TAG, "Handle Removable SIM inserted under DSDS+Mep.");
|
||||
|
||||
if (removableSlotInfo.getPorts().stream().findFirst().get().isActive()) {
|
||||
Log.i(TAG, "The removable slot is already active. Do nothing. removableSlotInfo: "
|
||||
+ removableSlotInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
List<SubscriptionInfo> subscriptionInfos = getAvailableRemovableSubscription();
|
||||
if (subscriptionInfos == null && subscriptionInfos.get(0) != null) {
|
||||
Log.e(TAG, "Unable to find the removable subscriptionInfo. Do nothing.");
|
||||
return;
|
||||
}
|
||||
startSimConfirmDialogActivity(subscriptionInfos.get(0).getSubscriptionId());
|
||||
}
|
||||
|
||||
private int getLastRemovableSimSlotState(Context context) {
|
||||
final SharedPreferences prefs = context.getSharedPreferences(EUICC_PREFS, MODE_PRIVATE);
|
||||
return prefs.getInt(KEY_REMOVABLE_SLOT_STATE, UiccSlotInfo.CARD_STATE_INFO_ABSENT);
|
||||
@@ -261,7 +294,6 @@ public class SimSlotChangeHandler {
|
||||
}
|
||||
for (UiccSlotInfo slotInfo : slotInfos) {
|
||||
if (slotInfo != null && slotInfo.isRemovable()) {
|
||||
|
||||
return slotInfo;
|
||||
}
|
||||
}
|
||||
@@ -297,6 +329,16 @@ public class SimSlotChangeHandler {
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
protected List<SubscriptionInfo> getAvailableRemovableSubscription() {
|
||||
List<SubscriptionInfo> subList = new ArrayList<>();
|
||||
for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mContext)) {
|
||||
if (!info.isEmbedded()) {
|
||||
subList.add(info);
|
||||
}
|
||||
}
|
||||
return subList;
|
||||
}
|
||||
|
||||
private void startChooseSimActivity(boolean psimInserted) {
|
||||
Intent intent = ChooseSimActivity.getIntent(mContext);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -317,5 +359,25 @@ public class SimSlotChangeHandler {
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
private void startSimConfirmDialogActivity(int subId) {
|
||||
if (!SubscriptionManager.isUsableSubscriptionId(subId)) {
|
||||
Log.i(TAG, "Unable to enable subscription due to invalid subscription ID.");
|
||||
return;
|
||||
}
|
||||
Intent intent = ToggleSubscriptionDialogActivity.getIntent(mContext, subId, true);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
private boolean isMultipleEnabledProfilesSupported() {
|
||||
List<UiccCardInfo> cardInfos = mTelMgr.getUiccCardsInfo();
|
||||
if (cardInfos == null) {
|
||||
Log.w(TAG, "UICC cards info list is empty.");
|
||||
return false;
|
||||
}
|
||||
return cardInfos.stream().anyMatch(
|
||||
cardInfo -> cardInfo.isMultipleEnabledProfilesSupported());
|
||||
}
|
||||
|
||||
private SimSlotChangeHandler() {}
|
||||
}
|
||||
|
Reference in New Issue
Block a user