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

Commit 3cd16141 authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Clear calling identity before calling createContextAsUser.

In TelecomServiceImpl#callingUidMatchesPackageManagerRecords, we need to
clear the calling identity before invoking mContext.createContextAsUser.
The issue is that createContextUser is trying to enforce NETWORK_STACK
permissions. Clearing the identity beforehand should prevent this issue.

Bug: 278889696
Test: atest TelecomUnitTests
Test: Manual (verified no regressions in basic call flow when calling into TelecomServiceImpl#enforceCallingPackage, which enforces callingUidMatchesPackageManagerRecords under the hood)
Test: Manual (verified invocations to TM#getCallState are not resulting in exceptions when clearing the calling identity
Change-Id: I5d11b564a2afcbf4e3d9371aa5b1fd53189bc118
parent 9b945f2b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2707,6 +2707,7 @@ public class TelecomServiceImpl {
        int packageUid = -1;
        int callingUid = Binder.getCallingUid();
        PackageManager pm;
        long token = Binder.clearCallingIdentity();
        try{
            pm = mContext.createContextAsUser(
                    UserHandle.getUserHandleForUid(callingUid), 0).getPackageManager();
@@ -2715,6 +2716,8 @@ public class TelecomServiceImpl {
            Log.i(this, "callingUidMatchesPackageManagerRecords:"
                            + " createContextAsUser hit exception=[%s]", e.toString());
            return false;
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        if (pm != null) {
            try {