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

Commit 819e72bb authored by Holly Jiuyu Sun's avatar Holly Jiuyu Sun
Browse files

Catch SecurityException in EuiccCardController and trigger callback.

Currently, if checkCallingPackage() throws a SecurityException, it won't
trigger the callback. Since, EuiccCardManager is async which will return
after invoke EuiccCardController, the throwed SecurityException will get
lost. In this CL, the exception is caught in EuiccCardController and
triggers the callback in this case.
Also, fix a typo in EuiccCardManager.

Bug: 78599148
Bug: 110845244
Test: test on phone
Merged-In: I0883d3948793a9312e744277a0374e16d328fd81
Change-Id: I0883d3948793a9312e744277a0374e16d328fd81
parent 732aecd8
Loading
Loading
Loading
Loading
+220 −22
Original line number Diff line number Diff line
@@ -194,7 +194,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void getAllProfiles(String callingPackage, String cardId,
            IGetAllProfilesCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -234,7 +243,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void getProfile(String callingPackage, String cardId, String iccid,
            IGetProfileCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -273,7 +291,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void disableProfile(String callingPackage, String cardId, String iccid, boolean refresh,
            IDisableProfileCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -312,7 +339,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void switchToProfile(String callingPackage, String cardId, String iccid, boolean refresh,
            ISwitchToProfileCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -369,7 +405,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void setNickname(String callingPackage, String cardId, String iccid, String nickname,
            ISetNicknameCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -408,7 +453,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void deleteProfile(String callingPackage, String cardId, String iccid,
            IDeleteProfileCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -449,7 +503,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void resetMemory(String callingPackage, String cardId,
            @EuiccCardManager.ResetOption int options, IResetMemoryCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -490,7 +553,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void getDefaultSmdpAddress(String callingPackage, String cardId,
            IGetDefaultSmdpAddressCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -529,7 +601,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void getSmdsAddress(String callingPackage, String cardId,
            IGetSmdsAddressCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -568,7 +649,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void setDefaultSmdpAddress(String callingPackage, String cardId, String address,
            ISetDefaultSmdpAddressCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -607,7 +697,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void getRulesAuthTable(String callingPackage, String cardId,
            IGetRulesAuthTableCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -647,7 +746,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void getEuiccChallenge(String callingPackage, String cardId,
            IGetEuiccChallengeCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -686,7 +794,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void getEuiccInfo1(String callingPackage, String cardId,
            IGetEuiccInfo1Callback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -725,7 +842,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void getEuiccInfo2(String callingPackage, String cardId,
            IGetEuiccInfo2Callback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -765,7 +891,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    public void authenticateServer(String callingPackage, String cardId, String matchingId,
            byte[] serverSigned1, byte[] serverSignature1, byte[] euiccCiPkIdToBeUsed,
            byte[] serverCertificate, IAuthenticateServerCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -806,7 +941,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    public void prepareDownload(String callingPackage, String cardId, @Nullable byte[] hashCc,
            byte[] smdpSigned2, byte[] smdpSignature2, byte[] smdpCertificate,
            IPrepareDownloadCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -846,7 +990,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void loadBoundProfilePackage(String callingPackage, String cardId,
            byte[] boundProfilePackage, ILoadBoundProfilePackageCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -887,7 +1040,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void cancelSession(String callingPackage, String cardId, byte[] transactionId,
            @EuiccCardManager.CancelReason int reason, ICancelSessionCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -926,7 +1088,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void listNotifications(String callingPackage, String cardId,
            @EuiccNotification.Event int events, IListNotificationsCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -966,7 +1137,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void retrieveNotificationList(String callingPackage, String cardId,
            @EuiccNotification.Event int events, IRetrieveNotificationListCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -1006,7 +1186,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void retrieveNotification(String callingPackage, String cardId, int seqNumber,
            IRetrieveNotificationCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -1046,7 +1235,16 @@ public class EuiccCardController extends IEuiccCardController.Stub {
    @Override
    public void removeNotificationFromList(String callingPackage, String cardId, int seqNumber,
            IRemoveNotificationFromListCallback callback) {
        try {
            checkCallingPackage(callingPackage);
        } catch (SecurityException se) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED);
            } catch (RemoteException re) {
                loge("callback onComplete failure after checkCallingPackage.", re);
            }
            return;
        }

        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {