Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment