APIs to watch active op changes

System singed components can watch for starting/finishing of
long running app ops. Also protected the APIs to watch op mode
changes with a singature permission for the cross-uid use case.

Test: atest com.android.server.appops.AppOpsActiveWatcherTest

bug:64085448

Change-Id: Id7fe79ce1de4c5690b4f52786424ec5a5d9eb0fa
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 3a527b5..caeca592 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -3839,6 +3839,11 @@
     <permission android:name="android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS"
         android:protectionLevel="signature|privileged" />
 
+    <!-- Allows an application to watch changes and/or active state of app ops.
+         @hide <p>Not for use by third-party applications. -->
+    <permission android:name="android.permission.WATCH_APPOPS"
+        android:protectionLevel="signature" />
+
     <application android:process="system"
                  android:persistent="true"
                  android:hasCode="false"