Further flesh out app ops foreground state.

Fix some bugs, add the ability to monitor state changes, improve
dumpsys output to help debugging, add a new check API that allows
the caller to get the real state.

Bug: 78480444
Test: atest FrameworksServicesTests:AppOpsServiceTest
Test: atest CtsPermissionTestCases:AppOpsTest
Change-Id: I3d41be9968c1d95a1456f4052da958ea64aa068d
diff --git a/core/java/com/android/internal/app/IAppOpsService.aidl b/core/java/com/android/internal/app/IAppOpsService.aidl
index 2505ea5..0ed9724 100644
--- a/core/java/com/android/internal/app/IAppOpsService.aidl
+++ b/core/java/com/android/internal/app/IAppOpsService.aidl
@@ -54,4 +54,6 @@
     void startWatchingActive(in int[] ops, IAppOpsActiveCallback callback);
     void stopWatchingActive(IAppOpsActiveCallback callback);
     boolean isOperationActive(int code, int uid, String packageName);
+
+    void startWatchingModeWithFlags(int op, String packageName, int flags, IAppOpsCallback callback);
 }