From 42d533d3179769737eeee28372960defc79278a6 Mon Sep 17 00:00:00 2001 From: Evan Severson Date: Thu, 23 Mar 2023 14:43:18 -0700 Subject: [PATCH] Only invoke for callbacks watching the given package If a watcher is registered with a packageName, it shouldn't get callbacks for changes to a different package in a different uid. Bug: 272358877 Test: atest CtsAppOpsTestCases Change-Id: I1a00e6019ab20d6b0688707e00c6bcd20be3c409 --- .../core/java/com/android/server/appop/AppOpsService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index 719bb64fad981..a3f8bdbc792a1 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -1856,6 +1856,10 @@ public class AppOpsService extends IAppOpsService.Stub { for (int i = 0; i < callbackCount; i++) { OnOpModeChangedListener callback = callbacks.valueAt(i); + if (!callback.isWatchingUid(uid)) { + continue; + } + if (onlyForeground && (callback.getFlags() & WATCH_FOREGROUND_CHANGES) == 0) { continue;