Merge "[MEP] the user can't enable the psim when revmovable esim is enabled" into tm-qpr-dev

This commit is contained in:
SongFerng Wang
2022-10-18 06:30:34 +00:00
committed by Android (Google) Code Review
3 changed files with 171 additions and 16 deletions

View File

@@ -28,7 +28,6 @@ import android.telephony.UiccSlotMapping;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.uicc.UiccController;
import com.android.settingslib.utils.ThreadUtils;
import com.google.common.collect.ImmutableList;
@@ -273,6 +272,7 @@ public class UiccSlotUtil {
if (slotId == INVALID_PHYSICAL_SLOT_ID) {
for (int i = 0; i < slots.length; i++) {
if (slots[i].isRemovable()
&& !slots[i].getIsEuicc()
&& !slots[i].getPorts().stream().findFirst().get().isActive()
&& slots[i].getCardStateInfo() != UiccSlotInfo.CARD_STATE_INFO_ERROR
&& slots[i].getCardStateInfo() != UiccSlotInfo.CARD_STATE_INFO_RESTRICTED) {
@@ -413,4 +413,29 @@ public class UiccSlotUtil {
.findFirst()
.orElse(INVALID_LOGICAL_SLOT_ID);
}
/**
* Return whether the removable psim is enabled.
*
* @param telMgr is a TelephonyManager.
* @return whether the removable psim is enabled.
*/
public static boolean isRemovableSimEnabled(TelephonyManager telMgr) {
if (telMgr == null) {
return false;
}
ImmutableList<UiccSlotInfo> slotInfos = UiccSlotUtil.getSlotInfos(telMgr);
boolean isRemovableSimEnabled =
slotInfos.stream()
.anyMatch(
slot -> slot != null
&& slot.isRemovable()
&& !slot.getIsEuicc()
&& slot.getPorts().stream().anyMatch(
port -> port.isActive())
&& slot.getCardStateInfo()
== UiccSlotInfo.CARD_STATE_INFO_PRESENT);
Log.i(TAG, "isRemovableSimEnabled: " + isRemovableSimEnabled);
return isRemovableSimEnabled;
}
}