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

Commit 4aa07e9e 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

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

Change-Id: Ia84c43f954e3e804f368d36ae6d996b881bd44bd
parents afb588df dbac29e4
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -2052,6 +2052,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");
@@ -2059,8 +2061,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;
        }