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

Commit 1dde6704 authored by joonhunshin's avatar joonhunshin Committed by Joonhun Shin
Browse files

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

android.hardware.telephony.euicc feature

Bug: 320169439
Test: build pass
      verify that no crash occurs using ABTD on mokey_go32-trunk_staging-userdebug
Test: Basic telelephony functionality tests
Change-Id: Ic7cb5da8c0d35ac8127b9a03fd3c069e344d59c3
parent 4b60fe72
Loading
Loading
Loading
Loading
+21 −10
Original line number Original line Diff line number Diff line
@@ -43,6 +43,7 @@ import android.telephony.euicc.EuiccCardManager.ResetOption;
import android.util.Log;
import android.util.Log;


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


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


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


    private static void sendUnavailableError(PendingIntent callbackIntent) {
    private static void sendUnavailableError(PendingIntent callbackIntent) {
@@ -1672,6 +1666,23 @@ public class EuiccManager {
                        .get());
                        .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.
     * Returns whether the passing portIndex is available.
     * A port is available if it is active without enabled profile on it or
     * A port is available if it is active without enabled profile on it or