From d6a98979b5d45fff1fa842932274517e999a59c2 Mon Sep 17 00:00:00 2001 From: Alexandra Gherghina Date: Mon, 4 Aug 2014 17:05:34 +0100 Subject: [PATCH] Fix resetAllModes call to act only on the calling user This makes it consistent with other methods in different services. Also fixes the Settigns bug referenced below. Bug: 16727586 Change-Id: I0b8bcb248f621fcfa2cb12163caeec9eb8ff5b1c --- services/core/java/com/android/server/AppOpsService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java index 13e1b3761b84d..ef6e07c129336 100644 --- a/services/core/java/com/android/server/AppOpsService.java +++ b/services/core/java/com/android/server/AppOpsService.java @@ -437,13 +437,18 @@ public class AppOpsService extends IAppOpsService.Stub { @Override public void resetAllModes() { + int callingUid = Binder.getCallingUid(); mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS, - Binder.getCallingPid(), Binder.getCallingUid(), null); + Binder.getCallingPid(), callingUid, null); HashMap>> callbacks = null; synchronized (this) { boolean changed = false; for (int i=mUidOps.size()-1; i>=0; i--) { HashMap packages = mUidOps.valueAt(i); + if (UserHandle.getUserId(callingUid) != UserHandle.getUserId(mUidOps.keyAt(i))) { + // Skip any ops for a different user + continue; + } Iterator> it = packages.entrySet().iterator(); while (it.hasNext()) { Map.Entry ent = it.next();