From ffddadb04a8df12f05f42721cc59e242e78c2a64 Mon Sep 17 00:00:00 2001 From: Suprabh Shukla Date: Fri, 20 May 2016 16:37:26 -0700 Subject: [PATCH] Fixing isOpRestricted in AppOpsService AppOpsService was returning false for a restricted operation if the operation did not allow the system to bypass the restrictions on it. Bug: 28860721 Change-Id: I487e23f1d3bf6ea602caee439fb500c058e7c8ff --- .../java/com/android/server/AppOpsService.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java index ca3c39f51e626..dab7d706a6d2c 100644 --- a/services/core/java/com/android/server/AppOpsService.java +++ b/services/core/java/com/android/server/AppOpsService.java @@ -1316,13 +1316,14 @@ public class AppOpsService extends IAppOpsService.Stub { // For each client, check that the given op is not restricted, or that the given // package is exempt from the restriction. ClientRestrictionState restrictionState = mOpUserRestrictions.valueAt(i); - if (restrictionState.hasRestriction(code, packageName, userHandle) - && AppOpsManager.opAllowSystemBypassRestriction(code)) { - // If we are the system, bypass user restrictions for certain codes - synchronized (this) { - Ops ops = getOpsRawLocked(uid, packageName, true); - if ((ops != null) && ops.isPrivileged) { - return false; + if (restrictionState.hasRestriction(code, packageName, userHandle)) { + if (AppOpsManager.opAllowSystemBypassRestriction(code)) { + // If we are the system, bypass user restrictions for certain codes + synchronized (this) { + Ops ops = getOpsRawLocked(uid, packageName, true); + if ((ops != null) && ops.isPrivileged) { + return false; + } } } return true;