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

Commit a481261a authored by Nazanin Bakhshi's avatar Nazanin Bakhshi
Browse files

Clear and restore callingIdentity for getSubscriberId

to be able to call isActiveSubId with permission checks

Bug: 136062407
Test: ran failing cts test module CtsAppSecurityHostTestCases
Change-Id: I1b64b985aac1eccb489d2205da3b3bcaea3d2509
parent 2ea06507
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -126,7 +126,14 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub {


    public String getSubscriberIdForSubscriber(int subId, String callingPackage) {
    public String getSubscriberIdForSubscriber(int subId, String callingPackage) {
        String message = "getSubscriberId";
        String message = "getSubscriberId";
        if (SubscriptionController.getInstance().isActiveSubId(subId, callingPackage)) {
        long identity = Binder.clearCallingIdentity();
        boolean isActive;
        try {
            isActive = SubscriptionController.getInstance().isActiveSubId(subId, callingPackage);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
        if (isActive) {
            return callPhoneMethodForSubIdWithReadSubscriberIdentifiersCheck(subId, callingPackage,
            return callPhoneMethodForSubIdWithReadSubscriberIdentifiersCheck(subId, callingPackage,
                    message, (phone) -> phone.getSubscriberId());
                    message, (phone) -> phone.getSubscriberId());
        } else {
        } else {
@@ -134,7 +141,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub {
                    mContext, subId, callingPackage, message)) {
                    mContext, subId, callingPackage, message)) {
                return null;
                return null;
            }
            }
            final long identity = Binder.clearCallingIdentity();
            identity = Binder.clearCallingIdentity();
            try {
            try {
                return SubscriptionController.getInstance().getImsiPrivileged(subId);
                return SubscriptionController.getInstance().getImsiPrivileged(subId);
            } finally {
            } finally {