[MEP] Inserting a pSIM while user has 2 esims, showing the MEP dialog am: 650b048749
am: e0e40b1e88
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2063562 Change-Id: I3ed592f99798051fc56100e7bbadbf1c0fcc9260 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.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.telephony.UiccCardInfo;
|
||||||
import android.telephony.UiccSlotInfo;
|
import android.telephony.UiccSlotInfo;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
import com.android.settings.network.UiccSlotUtil;
|
import com.android.settings.network.UiccSlotUtil;
|
||||||
import com.android.settings.network.UiccSlotsException;
|
import com.android.settings.network.UiccSlotsException;
|
||||||
|
import com.android.settings.network.telephony.ToggleSubscriptionDialogActivity;
|
||||||
import com.android.settings.sim.ChooseSimActivity;
|
import com.android.settings.sim.ChooseSimActivity;
|
||||||
import com.android.settings.sim.DsdsDialogActivity;
|
import com.android.settings.sim.DsdsDialogActivity;
|
||||||
import com.android.settings.sim.SimActivationNotifier;
|
import com.android.settings.sim.SimActivationNotifier;
|
||||||
@@ -40,6 +42,7 @@ import com.android.settings.sim.SwitchToEsimConfirmDialogActivity;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -83,8 +86,8 @@ public class SimSlotChangeHandler {
|
|||||||
throw new IllegalStateException("Cannot be called from main thread.");
|
throw new IllegalStateException("Cannot be called from main thread.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTelMgr.getActiveModemCount() > 1) {
|
if (mTelMgr.getActiveModemCount() > 1 && !isMultipleEnabledProfilesSupported()) {
|
||||||
Log.i(TAG, "The device is already in DSDS mode. Do nothing.");
|
Log.i(TAG, "The device is already in DSDS mode and no MEP. Do nothing.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,17 +99,30 @@ public class SimSlotChangeHandler {
|
|||||||
|
|
||||||
int lastRemovableSlotState = getLastRemovableSimSlotState(mContext);
|
int lastRemovableSlotState = getLastRemovableSimSlotState(mContext);
|
||||||
int currentRemovableSlotState = removableSlotInfo.getCardStateInfo();
|
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.
|
// Sets the current removable slot state.
|
||||||
setRemovableSimSlotState(mContext, currentRemovableSlotState);
|
setRemovableSimSlotState(mContext, currentRemovableSlotState);
|
||||||
|
|
||||||
if (lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT
|
if (mTelMgr.getActiveModemCount() > 1 && isMultipleEnabledProfilesSupported()) {
|
||||||
&& currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT) {
|
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);
|
handleSimInsert(removableSlotInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT
|
if (isRemovableSimRemoved) {
|
||||||
&& currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT) {
|
|
||||||
handleSimRemove(removableSlotInfo);
|
handleSimRemove(removableSlotInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -232,6 +248,23 @@ public class SimSlotChangeHandler {
|
|||||||
startChooseSimActivity(false);
|
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) {
|
private int getLastRemovableSimSlotState(Context context) {
|
||||||
final SharedPreferences prefs = context.getSharedPreferences(EUICC_PREFS, MODE_PRIVATE);
|
final SharedPreferences prefs = context.getSharedPreferences(EUICC_PREFS, MODE_PRIVATE);
|
||||||
return prefs.getInt(KEY_REMOVABLE_SLOT_STATE, UiccSlotInfo.CARD_STATE_INFO_ABSENT);
|
return prefs.getInt(KEY_REMOVABLE_SLOT_STATE, UiccSlotInfo.CARD_STATE_INFO_ABSENT);
|
||||||
@@ -261,7 +294,6 @@ public class SimSlotChangeHandler {
|
|||||||
}
|
}
|
||||||
for (UiccSlotInfo slotInfo : slotInfos) {
|
for (UiccSlotInfo slotInfo : slotInfos) {
|
||||||
if (slotInfo != null && slotInfo.isRemovable()) {
|
if (slotInfo != null && slotInfo.isRemovable()) {
|
||||||
|
|
||||||
return slotInfo;
|
return slotInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,6 +329,16 @@ public class SimSlotChangeHandler {
|
|||||||
.collect(Collectors.toList()));
|
.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) {
|
private void startChooseSimActivity(boolean psimInserted) {
|
||||||
Intent intent = ChooseSimActivity.getIntent(mContext);
|
Intent intent = ChooseSimActivity.getIntent(mContext);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
@@ -317,5 +359,25 @@ public class SimSlotChangeHandler {
|
|||||||
mContext.startActivity(intent);
|
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() {}
|
private SimSlotChangeHandler() {}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user