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

Commit 432c26de authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by Automerger Merge Worker
Browse files

Allow perm controller to read historical app-op data am: dbac29e4 am: 4aa07e9e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12061588

Change-Id: Ice72500055814c5f75a73f01cc0ce6f66a25c2da
parents 59677e14 4aa07e9e
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -2059,6 +2059,8 @@ public class AppOpsService extends IAppOpsService.Stub {
    public void getHistoricalOps(int uid, String packageName, String attributionTag,
            List<String> opNames, int filter, long beginTimeMillis, long endTimeMillis,
            int flags, RemoteCallback callback) {
        PackageManager pm = mContext.getPackageManager();

        ensureHistoricalOpRequestIsValid(uid, packageName, attributionTag, opNames, filter,
                beginTimeMillis, endTimeMillis, flags);
        Objects.requireNonNull(callback, "callback cannot be null");
@@ -2066,8 +2068,16 @@ public class AppOpsService extends IAppOpsService.Stub {
        ActivityManagerInternal ami = LocalServices.getService(ActivityManagerInternal.class);
        boolean isCallerInstrumented = ami.isUidCurrentlyInstrumented(Binder.getCallingUid());
        boolean isCallerSystem = Binder.getCallingPid() == Process.myPid();
        boolean isCallerPermissionController;
        try {
            isCallerPermissionController = pm.getPackageUid(
                    mContext.getPackageManager().getPermissionControllerPackageName(), 0)
                    == Binder.getCallingUid();
        } catch (PackageManager.NameNotFoundException doesNotHappen) {
            return;
        }

        if (!isCallerSystem && !isCallerInstrumented) {
        if (!isCallerSystem && !isCallerInstrumented && !isCallerPermissionController) {
            mHandler.post(() -> callback.sendResult(new Bundle()));
            return;
        }