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

Commit 68cb37f7 authored by Jordan Liu's avatar Jordan Liu Committed by Gerrit Code Review
Browse files

Merge "Do no persist default card"

parents 8dbd0163 af02f756
Loading
Loading
Loading
Loading
+6 −17
Original line number Diff line number Diff line
@@ -129,7 +129,8 @@ public class UiccController extends Handler {
    // considered sensetive information.
    private ArrayList<String> mCardStrings;

    // This is the card ID of the default eUICC. It is set to the first ever seen eUICC
    // This is the card ID of the default eUICC. Whenever we receive slot status, we set it to the
    // eUICC with the lowest slot index
    private int mDefaultEuiccCardId;

    private static final int INVALID_CARD_ID = TelephonyManager.INVALID_CARD_ID;
@@ -208,7 +209,7 @@ public class UiccController extends Handler {

        mLauncher = new UiccStateChangedLauncher(c, this);
        mCardStrings = loadCardStrings();
        mDefaultEuiccCardId = loadDefaultEuiccCardId();
        mDefaultEuiccCardId = INVALID_CARD_ID;
    }

    private int getSlotIdFromPhoneId(int phoneId) {
@@ -646,19 +647,6 @@ public class UiccController extends Handler {
        editor.commit();
    }

    private int loadDefaultEuiccCardId() {
        return PreferenceManager.getDefaultSharedPreferences(mContext)
                .getInt(DEFAULT_CARD, INVALID_CARD_ID);
    }

    private void setDefaultEuiccCardId(int cardId) {
        mDefaultEuiccCardId = cardId;
        SharedPreferences.Editor editor =
                PreferenceManager.getDefaultSharedPreferences(mContext).edit();
        editor.putInt(DEFAULT_CARD, mDefaultEuiccCardId);
        editor.commit();
    }

    private synchronized void onGetSlotStatusDone(AsyncResult ar) {
        if (!mIsSlotStatusSupported) {
            if (VDBG) log("onGetSlotStatusDone: ignoring since mIsSlotStatusSupported is false");
@@ -695,6 +683,7 @@ public class UiccController extends Handler {
        sLastSlotStatus = status;

        int numActiveSlots = 0;
        mDefaultEuiccCardId = INVALID_CARD_ID;
        for (int i = 0; i < status.size(); i++) {
            IccSlotStatus iss = status.get(i);
            boolean isActive = (iss.slotState == IccSlotStatus.SlotState.SLOTSTATE_ACTIVE);
@@ -728,10 +717,10 @@ public class UiccController extends Handler {
                String eid = iss.eid;
                addCardId(eid);

                // If default eUICC card ID is unset, set it to the card ID of the eUICC with the
                // whenever slot status is received, set default card to the eUICC with the
                // lowest slot index.
                if (mDefaultEuiccCardId == INVALID_CARD_ID) {
                    setDefaultEuiccCardId(convertToPublicCardId(eid));
                    mDefaultEuiccCardId = convertToPublicCardId(eid);
                }
            }
        }