Merge "Add more condition to avoid to open the SimOnboardingActivity" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
ac7236ec0f
@@ -28,6 +28,7 @@ import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.UiccCardInfo;
|
||||
import android.telephony.UiccPortInfo;
|
||||
import android.telephony.UiccSlotInfo;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -91,10 +92,10 @@ public class SimSlotChangeHandler {
|
||||
Log.e(TAG, "Unable to find the removable slot. Do nothing.");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.i(TAG, "The removableSlotInfo: " + removableSlotInfo);
|
||||
int lastRemovableSlotState = getLastRemovableSimSlotState(mContext);
|
||||
int currentRemovableSlotState = removableSlotInfo.getCardStateInfo();
|
||||
Log.i(TAG,
|
||||
Log.d(TAG,
|
||||
"lastRemovableSlotState: " + lastRemovableSlotState + ",currentRemovableSlotState: "
|
||||
+ currentRemovableSlotState);
|
||||
boolean isRemovableSimInserted =
|
||||
@@ -115,8 +116,12 @@ public class SimSlotChangeHandler {
|
||||
|
||||
if (Flags.isDualSimOnboardingEnabled()) {
|
||||
// ForNewUi, when the user inserts the psim, showing the sim onboarding for the user
|
||||
// to setup the sim switching or the default data subscription.
|
||||
handleRemovableSimInsertWhenDsds();
|
||||
// to setup the sim switching or the default data subscription in DSDS.
|
||||
// Will show dialog for below case.
|
||||
// 1. the psim slot is not active.
|
||||
// 2. there are one or more active sim.
|
||||
handleRemovableSimInsertWhenDsds(removableSlotInfo);
|
||||
return;
|
||||
} else if (!isMultipleEnabledProfilesSupported()) {
|
||||
Log.d(TAG, "The device is already in DSDS mode and no MEP. Do nothing.");
|
||||
return;
|
||||
@@ -124,8 +129,6 @@ public class SimSlotChangeHandler {
|
||||
handleRemovableSimInsertUnderDsdsMep(removableSlotInfo);
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "the device is already in DSDS mode and have the DDS. Do nothing.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isRemovableSimInserted) {
|
||||
@@ -258,15 +261,29 @@ public class SimSlotChangeHandler {
|
||||
startChooseSimActivity(false);
|
||||
}
|
||||
|
||||
private void handleRemovableSimInsertWhenDsds() {
|
||||
private boolean hasOtherActiveSubInfo(int psimSubId) {
|
||||
List<SubscriptionInfo> activeSubs = SubscriptionUtil.getActiveSubscriptions(mSubMgr);
|
||||
return activeSubs.stream()
|
||||
.anyMatch(subscriptionInfo -> subscriptionInfo.getSubscriptionId() != psimSubId);
|
||||
}
|
||||
|
||||
private boolean hasAnyPortActiveInSlot(UiccSlotInfo removableSlotInfo) {
|
||||
return removableSlotInfo.getPorts().stream().anyMatch(UiccPortInfo::isActive);
|
||||
}
|
||||
|
||||
private void handleRemovableSimInsertWhenDsds(UiccSlotInfo removableSlotInfo) {
|
||||
Log.i(TAG, "ForNewUi: Handle Removable SIM inserted");
|
||||
List<SubscriptionInfo> subscriptionInfos = getAvailableRemovableSubscription();
|
||||
if (subscriptionInfos.isEmpty()) {
|
||||
Log.e(TAG, "Unable to find the removable subscriptionInfo. Do nothing.");
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "ForNewUi and getAvailableRemovableSubscription:"
|
||||
+ subscriptionInfos);
|
||||
startSimConfirmDialogActivity(subscriptionInfos.get(0).getSubscriptionId());
|
||||
Log.d(TAG, "getAvailableRemovableSubscription:" + subscriptionInfos);
|
||||
int psimSubId = subscriptionInfos.get(0).getSubscriptionId();
|
||||
if (!hasAnyPortActiveInSlot(removableSlotInfo) || hasOtherActiveSubInfo(psimSubId)) {
|
||||
Log.d(TAG, "ForNewUi Start Setup flow");
|
||||
startSimConfirmDialogActivity(psimSubId);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRemovableSimInsertUnderDsdsMep(UiccSlotInfo removableSlotInfo) {
|
||||
|
||||
Reference in New Issue
Block a user