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

Commit 8e270d76 authored by Etienne Ruffieux's avatar Etienne Ruffieux Committed by Gerrit Code Review
Browse files

Merge "Use UserHandle created context to check package name."

parents 26729eba 4b9b5848
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);