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

Commit 984306a8 authored by Joonhun Shin's avatar Joonhun Shin Committed by Android (Google) Code Review
Browse files

Merge "Change Euicc card Id to use default value when the device does not have...

Merge "Change Euicc card Id to use default value when the device does not have android.hardware.telephony.euicc feature" into main
parents 6a52bfc2 1dde6704
Loading
Loading
Loading
Loading
+21 −10
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.telephony.euicc.EuiccCardManager.ResetOption;
import android.util.Log;

import com.android.internal.telephony.euicc.IEuiccController;
import com.android.internal.telephony.flags.Flags;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -897,9 +898,7 @@ public class EuiccManager {
    /** @hide */
    public EuiccManager(Context context) {
        mContext = context;
        TelephonyManager tm = (TelephonyManager)
                context.getSystemService(Context.TELEPHONY_SERVICE);
        mCardId = tm.getCardIdForDefaultEuicc();
        mCardId = getCardIdForDefaultEuicc();
    }

    /** @hide */
@@ -1646,14 +1645,9 @@ public class EuiccManager {
    private boolean refreshCardIdIfUninitialized() {
        // Refresh mCardId if its UNINITIALIZED_CARD_ID
        if (mCardId == TelephonyManager.UNINITIALIZED_CARD_ID) {
            TelephonyManager tm = (TelephonyManager)
                    mContext.getSystemService(Context.TELEPHONY_SERVICE);
            mCardId = tm.getCardIdForDefaultEuicc();
            mCardId = getCardIdForDefaultEuicc();
        }
        if (mCardId == TelephonyManager.UNINITIALIZED_CARD_ID) {
            return false;
        }
        return true;
        return mCardId != TelephonyManager.UNINITIALIZED_CARD_ID;
    }

    private static void sendUnavailableError(PendingIntent callbackIntent) {
@@ -1672,6 +1666,23 @@ public class EuiccManager {
                        .get());
    }

    private int getCardIdForDefaultEuicc() {
        int cardId = TelephonyManager.UNINITIALIZED_CARD_ID;

        if (Flags.enforceTelephonyFeatureMappingForPublicApis()) {
            PackageManager pm = mContext.getPackageManager();
            if (pm != null && pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_EUICC)) {
                TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
                cardId = tm.getCardIdForDefaultEuicc();
            }
        } else {
            TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
            cardId = tm.getCardIdForDefaultEuicc();
        }

        return cardId;
    }

    /**
     * Returns whether the passing portIndex is available.
     * A port is available if it is active without enabled profile on it or