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

Commit 2d58717f authored by Stanislav Zholnin's avatar Stanislav Zholnin
Browse files

Record access rejection for restricted ops.

When AppOp access is rejected (MODE_IGNORED) because op is restricted
(one of cases - secondary user trying to access phone specific appops)
we still want to record appops rejection in HistoricalRegistry to be
consistent with other cases.

Test: atest hostsidetests/statsdatom/src/android/cts/statsdatom/appops/AppOpsTests.java  --user-type secondary_user
Bug: 175034881
Change-Id: Ifa3fd26db517e7a4ac3e37bf9e7466469c5d19de
parent e90010e4
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -3131,11 +3131,6 @@ public class AppOpsService extends IAppOpsService.Stub {
                return AppOpsManager.MODE_ERRORED;
            }
            final Op op = getOpLocked(ops, code, uid, true);
            if (isOpRestrictedLocked(uid, code, packageName, bypass)) {
                scheduleOpNotedIfNeededLocked(code, uid, packageName, flags,
                        AppOpsManager.MODE_IGNORED);
                return AppOpsManager.MODE_IGNORED;
            }
            final AttributedOp attributedOp = op.getOrCreateAttribution(op, attributionTag);
            if (attributedOp.isRunning()) {
                Slog.w(TAG, "Noting op not finished: uid " + uid + " pkg " + packageName + " code "
@@ -3145,6 +3140,12 @@ public class AppOpsService extends IAppOpsService.Stub {

            final int switchCode = AppOpsManager.opToSwitch(code);
            final UidState uidState = ops.uidState;
            if (isOpRestrictedLocked(uid, code, packageName, bypass)) {
                attributedOp.rejected(uidState.state, flags);
                scheduleOpNotedIfNeededLocked(code, uid, packageName, flags,
                        AppOpsManager.MODE_IGNORED);
                return AppOpsManager.MODE_IGNORED;
            }
            // If there is a non-default per UID policy (we set UID op mode only if
            // non-default) it takes over, otherwise use the per package policy.
            if (uidState.opModes != null && uidState.opModes.indexOfKey(switchCode) >= 0) {