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

Commit f11c2e64 authored by Etienne Ruffieux's avatar Etienne Ruffieux Committed by Automerger Merge Worker
Browse files

Merge "Use UserHandle created context to check package name." am: 8e270d76

parents 9ba178e0 8e270d76
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -372,9 +372,12 @@ public final class Utils {
     */
    public static boolean isPackageNameAccurate(Context context, String callingPackage,
            int callingUid) {
        UserHandle callingUser = UserHandle.getUserHandleForUid(callingUid);

        // Verifies the integrity of the calling package name
        try {
            int packageUid = context.getPackageManager().getPackageUid(callingPackage, 0);
            int packageUid = context.createContextAsUser(callingUser, 0)
                    .getPackageManager().getPackageUid(callingPackage, 0);
            if (packageUid != callingUid) {
                Log.e(TAG, "isPackageNameAccurate: App with package name " + callingPackage
                        + " is UID " + packageUid + " but caller is " + callingUid);