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

Commit 2e46a835 authored by Thomas Stuart's avatar Thomas Stuart Committed by Android (Google) Code Review
Browse files

Merge "fix test failure by wrapping createContextAsUser with catch block"

parents 5d9e7621 15c81089
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -1046,7 +1046,6 @@ public class TelecomServiceImpl {
        private boolean isPrivilegedUid(String callingPackage) {
            int callingUid = Binder.getCallingUid();
            boolean isPrivileged = false;

            switch (callingUid) {
                case Process.ROOT_UID:
                case Process.SYSTEM_UID:
@@ -1054,10 +1053,6 @@ public class TelecomServiceImpl {
                    isPrivileged = true;
                    break;
            }

            Log.i(this, "isPrivilegedUid: callingPackage=[%s], callingUid=[%d], isPrivileged=[%b]",
                    callingPackage, callingUid, isPrivileged);

            return isPrivileged;
        }

@@ -2443,9 +2438,16 @@ public class TelecomServiceImpl {
    private boolean callingUidMatchesPackageManagerRecords(String packageName) {
        int packageUid = -1;
        int callingUid = Binder.getCallingUid();
        PackageManager pm = mContext.createContextAsUser(
        PackageManager pm;
        try{
            pm = mContext.createContextAsUser(
                    UserHandle.getUserHandleForUid(callingUid), 0).getPackageManager();

        }
        catch (Exception e){
            Log.i(this, "callingUidMatchesPackageManagerRecords:"
                            + " createContextAsUser hit exception=[%s]", e.toString());
            return false;
        }
        if (pm != null) {
            try {
                packageUid = pm.getPackageUid(packageName, 0);