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

Commit 4078aa3c authored by Evan Severson's avatar Evan Severson Committed by Evelyn Torres
Browse files

Add logcat for bad appop call

When a process calls noteOp or startOp and the uid and package don't
match it's hard to tell who that is coming from when looking at a
bugreport. This adds a log to give us the caller and the bad parameters.

Test: Make bad call from test app
Fixes: 198341491
Change-Id: Ie07f32756a56ec098b0d607a625e6e9ae94e1469
parent aa134cb3
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -4569,8 +4569,10 @@ public class AppOpsService extends IAppOpsService.Stub {
        }
        if (pkgUid != Process.INVALID_UID) {
            if (pkgUid != UserHandle.getAppId(uid)) {
                Slog.e(TAG, "Bad call made by uid " + callingUid + ". "
                        + "Package \"" + packageName + "\" does not belong to uid " + uid + ".");
                String otherUidMessage = DEBUG ? " but it is really " + pkgUid : " but it is not";
                throw new SecurityException("Specified package " + packageName + " under uid "
                throw new SecurityException("Specified package \"" + packageName + "\" under uid "
                        +  UserHandle.getAppId(uid) + otherUidMessage);
            }
            return new PackageVerificationResult(RestrictionBypass.UNRESTRICTED,
@@ -4625,8 +4627,10 @@ public class AppOpsService extends IAppOpsService.Stub {
        }

        if (pkgUid != uid) {
            Slog.e(TAG, "Bad call made by uid " + callingUid + ". "
                    + "Package \"" + packageName + "\" does not belong to uid " + uid + ".");
            String otherUidMessage = DEBUG ? " but it is really " + pkgUid : " but it is not";
            throw new SecurityException("Specified package " + packageName + " under uid " + uid
            throw new SecurityException("Specified package \"" + packageName + "\" under uid " + uid
                    + otherUidMessage);
        }