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

Commit f75bb134 authored by Jordan Liu's avatar Jordan Liu
Browse files

Add EuiccCardManager requestEnabledProfileForPort

Also expose DEFAULT_PORT_INDEX.

Bug: 205504646
Fixes: 207392528
Test: manual, atest TelephonyEuiccHostTest
Change-Id: I25dc041225e897ccf707473192287f2446b40b32
parent 9af5b089
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43422,6 +43422,7 @@ package android.telephony {
    field public static final int DATA_ENABLED_REASON_USER = 0; // 0x0
    field public static final int DATA_SUSPENDED = 3; // 0x3
    field public static final int DATA_UNKNOWN = -1; // 0xffffffff
    field public static final int DEFAULT_PORT_INDEX = 0; // 0x0
    field public static final int ERI_FLASH = 2; // 0x2
    field public static final int ERI_OFF = 1; // 0x1
    field public static final int ERI_ON = 0; // 0x0
+2 −0
Original line number Diff line number Diff line
@@ -13171,6 +13171,7 @@ package android.telephony.euicc {
    method public void removeNotificationFromList(String, int, java.util.concurrent.Executor, android.telephony.euicc.EuiccCardManager.ResultCallback<java.lang.Void>);
    method public void requestAllProfiles(String, java.util.concurrent.Executor, android.telephony.euicc.EuiccCardManager.ResultCallback<android.service.euicc.EuiccProfileInfo[]>);
    method public void requestDefaultSmdpAddress(String, java.util.concurrent.Executor, android.telephony.euicc.EuiccCardManager.ResultCallback<java.lang.String>);
    method public void requestEnabledProfileForPort(@NonNull String, int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.euicc.EuiccCardManager.ResultCallback<android.service.euicc.EuiccProfileInfo>);
    method public void requestEuiccChallenge(String, java.util.concurrent.Executor, android.telephony.euicc.EuiccCardManager.ResultCallback<byte[]>);
    method public void requestEuiccInfo1(String, java.util.concurrent.Executor, android.telephony.euicc.EuiccCardManager.ResultCallback<byte[]>);
    method public void requestEuiccInfo2(String, java.util.concurrent.Executor, android.telephony.euicc.EuiccCardManager.ResultCallback<byte[]>);
@@ -13194,6 +13195,7 @@ package android.telephony.euicc {
    field public static final int RESULT_CALLER_NOT_ALLOWED = -3; // 0xfffffffd
    field public static final int RESULT_EUICC_NOT_FOUND = -2; // 0xfffffffe
    field public static final int RESULT_OK = 0; // 0x0
    field public static final int RESULT_PROFILE_NOT_FOUND = -4; // 0xfffffffc
    field public static final int RESULT_UNKNOWN_ERROR = -1; // 0xffffffff
  }
+7 −2
Original line number Diff line number Diff line
@@ -320,8 +320,13 @@ public class TelephonyManager {
    public static final int UNINITIALIZED_CARD_ID = -2;
    /**
     * Default port index for the UICC Card
     * @hide
     * Default port index for a UICC.
     *
     * On physical SIM cards the only available port is 0.
     * See {@link android.telephony.UiccPortInfo} for more information on ports.
     *
     * See {@link android.telephony.euicc.EuiccManager#isSimPortAvailable(int)} for information on
     * how portIndex is used on eUICCs.
     */
    public static final int DEFAULT_PORT_INDEX = 0;
+67 −30
Original line number Diff line number Diff line
@@ -73,7 +73,8 @@ public class EuiccCardManager {
            CANCEL_REASON_PPR_NOT_ALLOWED
    })
    /** @hide */
    public @interface CancelReason {}
    public @interface CancelReason {
    }

    /**
     * The end user has rejected the download. The profile will be put into the error state and
@@ -102,7 +103,8 @@ public class EuiccCardManager {
            RESET_OPTION_RESET_DEFAULT_SMDP_ADDRESS
    })
    /** @hide */
    public @interface ResetOption {}
    public @interface ResetOption {
    }

    /** Deletes all operational profiles. */
    public static final int RESET_OPTION_DELETE_OPERATIONAL_PROFILES = 1;
@@ -124,6 +126,10 @@ public class EuiccCardManager {

    /** Result code indicating the caller is not the active LPA. */
    public static final int RESULT_CALLER_NOT_ALLOWED = -3;

    /** Result code when the requested profile is not found */
    public static final int RESULT_PROFILE_NOT_FOUND = -4;

    /**
     * Callback to receive the result of an eUICC card API.
     *
@@ -213,6 +219,38 @@ public class EuiccCardManager {
        }
    }

    /**
     * Requests the enabled profile for a given port on an eUicc.
     *
     * @param cardId    The Id of the eUICC.
     * @param portIndex The portIndex to use. The port may be active or inactive. As long as the
     *                  ICCID is known, an APDU will be sent through to read the enabled profile.
     * @param executor  The executor through which the callback should be invoked.
     * @param callback  The callback to get the result code and the profile.
     */
    public void requestEnabledProfileForPort(@NonNull String cardId, int portIndex,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull ResultCallback<EuiccProfileInfo> callback) {
        try {
            getIEuiccCardController().getEnabledProfile(mContext.getOpPackageName(), cardId,
                    portIndex,
                    new IGetProfileCallback.Stub() {
                        @Override
                        public void onComplete(int resultCode, EuiccProfileInfo profile) {
                            final long token = Binder.clearCallingIdentity();
                            try {
                                executor.execute(() -> callback.onComplete(resultCode, profile));
                            } finally {
                                Binder.restoreCallingIdentity(token);
                            }
                        }
                    });
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling requestEnabledProfileForPort", e);
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Disables the profile of the given iccid.
     *
@@ -221,7 +259,6 @@ public class EuiccCardManager {
     * @param refresh  Whether sending the REFRESH command to modem.
     * @param executor The executor through which the callback should be invoked.
     * @param callback The callback to get the result code.
     *
     * @deprecated instead use {@link #disableProfile(String, String, int, boolean, Executor,
     * ResultCallback)}
     */
@@ -247,6 +284,7 @@ public class EuiccCardManager {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Disables the profile of the given ICCID.
     *
@@ -288,7 +326,6 @@ public class EuiccCardManager {
     * @param refresh  Whether sending the REFRESH command to modem.
     * @param executor The executor through which the callback should be invoked.
     * @param callback The callback to get the result code and the EuiccProfileInfo enabled.
     *
     * @deprecated instead use {@link #switchToProfile(String, String, int, boolean, Executor,
     * ResultCallback)}
     */
+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@ interface IEuiccCardController {
        in IGetAllProfilesCallback callback);
    oneway void getProfile(String callingPackage, String cardId, String iccid,
        in IGetProfileCallback callback);
    oneway void getEnabledProfile(String callingPackage, String cardId, int portIndex,
        in IGetProfileCallback callback);
    oneway void disableProfile(String callingPackage, String cardId, String iccid, int portIndex,
            boolean refresh, in IDisableProfileCallback callback);
    oneway void switchToProfile(String callingPackage, String cardId, String iccid, int portIndex,