Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93af35c1 authored by Amruth Ramachandran's avatar Amruth Ramachandran Committed by Automerger Merge Worker
Browse files

Merge "[MEP] set removable eSIM as default eUICC to pass GCF/PTCRB" into tm-dev am: ce64199a

parents f0e1c6de ce64199a
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -172,12 +172,18 @@ public class UiccController extends Handler {
    // SharedPreference key for saving the known card strings (ICCIDs and EIDs) ordered by card ID
    private static final String CARD_STRINGS = "card_strings";

    // SharedPreference key for saving the flag to set removable eSIM as default eUICC or not.
    private static final String REMOVABLE_ESIM_AS_DEFAULT = "removable_esim";

    // Whether the device has an eUICC built in.
    private boolean mHasBuiltInEuicc = false;

    // Whether the device has a currently active built in eUICC
    private boolean mHasActiveBuiltInEuicc = false;

    // Use removable eSIM as default eUICC. This flag will be set from phone debug hidden menu
    private boolean mUseRemovableEsimAsDefault = false;

    // The physical slots which correspond to built-in eUICCs
    private final int[] mEuiccSlots;

@@ -260,6 +266,10 @@ public class UiccController extends Handler {
                this, EVENT_MULTI_SIM_CONFIG_CHANGED, null);

        mPinStorage = new PinStorage(mContext);
        if (!TelephonyUtils.IS_USER) {
            mUseRemovableEsimAsDefault = PreferenceManager.getDefaultSharedPreferences(mContext)
                    .getBoolean(REMOVABLE_ESIM_AS_DEFAULT, false);
        }
    }

    /**
@@ -935,6 +945,21 @@ public class UiccController extends Handler {
        if (mDefaultEuiccCardId == TEMPORARILY_UNSUPPORTED_CARD_ID) {
            return UNSUPPORTED_CARD_ID;
        }
        // To support removable eSIM to pass GCT/PTCRB test in DSDS mode, we should make sure all
        // the download/activation requests are by default route to the removable eSIM slot.
        // To satisfy above condition, we should return removable eSIM cardId as default.
        if (mUseRemovableEsimAsDefault && !TelephonyUtils.IS_USER) {
            for (UiccSlot slot : mUiccSlots) {
                if (slot != null && slot.isRemovable() && slot.isEuicc() && slot.isActive()) {
                    int cardId = convertToPublicCardId(slot.getEid());
                    Rlog.d(LOG_TAG,
                            "getCardIdForDefaultEuicc: Removable eSIM is default, cardId: "
                                    + cardId);
                    return cardId;
                }
            }
            Rlog.d(LOG_TAG, "getCardIdForDefaultEuicc: No removable eSIM slot is found");
        }
        return mDefaultEuiccCardId;
    }

@@ -1398,6 +1423,30 @@ public class UiccController extends Handler {
        return false;
    }

    /**
     * Set removable eSIM as default.
     * This API is added for test purpose to set removable eSIM as default eUICC.
     * @param isDefault Flag to set removable eSIM as default or not.
     */
    public void setRemovableEsimAsDefaultEuicc(boolean isDefault) {
        mUseRemovableEsimAsDefault = isDefault;
        SharedPreferences.Editor editor =
                PreferenceManager.getDefaultSharedPreferences(mContext).edit();
        editor.putBoolean(REMOVABLE_ESIM_AS_DEFAULT, isDefault);
        editor.apply();
        Rlog.d(LOG_TAG, "setRemovableEsimAsDefaultEuicc isDefault: " + isDefault);
    }

    /**
     * Returns whether the removable eSIM is default eUICC or not.
     * This API is added for test purpose to check whether removable eSIM is default eUICC or not.
     */
    public boolean isRemovableEsimDefaultEuicc() {
        Rlog.d(LOG_TAG, "mUseRemovableEsimAsDefault: " + mUseRemovableEsimAsDefault);
        return mUseRemovableEsimAsDefault;
    }


    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private void log(String string) {
        Rlog.d(LOG_TAG, string);
@@ -1435,6 +1484,7 @@ public class UiccController extends Handler {
        pw.println(" mCardStrings=" + mCardStrings);
        pw.println(" mDefaultEuiccCardId=" + mDefaultEuiccCardId);
        pw.println(" mPhoneIdToSlotId=" + Arrays.toString(mPhoneIdToSlotId));
        pw.println(" mUseRemovableEsimAsDefault=" + mUseRemovableEsimAsDefault);
        pw.println(" mUiccSlots: size=" + mUiccSlots.length);
        for (int i = 0; i < mUiccSlots.length; i++) {
            if (mUiccSlots[i] == null) {