Move role into module.

These changes have to be in this CL together because:

- Code in service-permission depends on IRoleManager in
framework-permission, so the APIs in framework-permission and the code
in service-permission need to be moved together.

- The changes to service-permission build rules doesn't make sense
without the code moved in, so they have to be together as well.

Other details:

- framework-annotations: Several annotations are added into
framework-annoatations. Since the discussion with API council seems to
allow user IDs in system server in-process APIs, @UserIdInt and
@AppIdInt is added. @MainThread and @AnyThread is added since
@WorkerThread is already added. @CallSuper is added since @CheckResult
is also already added and they are similar in terms of category of
functionality.

- framework-permission-s-shared-srcs: 3 classes (and 2 AIDL files)
from framework is copied as shared source files and jarjared for
framework-permission, and an additional 3 is added for
service-permission as service-permission-shared-srcs. Similar to
framework-wifi and service-wifi, the 3 classes in framework-permission
is also available to service-permission by the stub library
framework-permission-pre-jarjar, and the other 3 classes used only for
service-permission is included separately to minimize our impact on
classes loaded into boot classpath. framework-permission and
service-permission shares the same jarjar rules to make sure the
classes remain available, and for the same reason framework-permission
cannot be shrank during any optimization.

- framework-permission-s-shared: A java_library target for
framework-permission-shared-srcs is created to make sure that the
public classes won't be counted as APIs, as it would be if directly
included as srcs for framework-permission
java_sdk_library. service-permission-shared is the same thing for
service-permission.

- framework-permission-s: A new java_sdk_library target created to be
loaded into bootclasspath by Android S+.

- Dumpsys Protobuf: The dumpsys protobuf
file (rolemanagerservice.proto) is moved into the module, and both the
platform (incident.proto) and the module uses protoc-gen-javastream to
generate the Java classes from it. This should be fine since it's a
"source level inclusion", and we jarjar the generated classes in our
module to avoid conflict with platform copies.

Bug: 158736025
Test: manual
Test: device boots, default apps can be changed successfully.
Change-Id: I1914774f631e51d0c587a7e527a1c9bc05ee1595
diff --git a/Android.bp b/Android.bp
index c957aed..d170913 100644
--- a/Android.bp
+++ b/Android.bp
@@ -761,6 +761,7 @@
         ":libstats_atom_enum_protos",
         "core/proto/**/*.proto",
         "libs/incident/**/*.proto",
+        ":service-permission-protos",
     ],
     output_extension: "srcjar",
 }
@@ -788,6 +789,7 @@
         ":libstats_atom_enum_protos",
         "core/proto/**/*.proto",
         "libs/incident/**/*.proto",
+        ":service-permission-protos",
     ],
 
     output_extension: "proto.h",
@@ -796,6 +798,9 @@
 filegroup {
     name: "framework-annotations",
     srcs: [
+        "core/java/android/annotation/AnyThread.java",
+        "core/java/android/annotation/AppIdInt.java",
+        "core/java/android/annotation/CallSuper.java",
         "core/java/android/annotation/CallbackExecutor.java",
         "core/java/android/annotation/CheckResult.java",
         "core/java/android/annotation/CurrentTimeMillisLong.java",
@@ -803,6 +808,7 @@
         "core/java/android/annotation/IntDef.java",
         "core/java/android/annotation/IntRange.java",
         "core/java/android/annotation/LongDef.java",
+        "core/java/android/annotation/MainThread.java",
         "core/java/android/annotation/NonNull.java",
         "core/java/android/annotation/Nullable.java",
         "core/java/android/annotation/RequiresPermission.java",
@@ -812,6 +818,7 @@
         "core/java/android/annotation/SystemApi.java",
         "core/java/android/annotation/SystemService.java",
         "core/java/android/annotation/TestApi.java",
+        "core/java/android/annotation/UserIdInt.java",
         "core/java/android/annotation/WorkerThread.java",
         "core/java/com/android/internal/annotations/GuardedBy.java",
         "core/java/com/android/internal/annotations/VisibleForTesting.java",
@@ -906,6 +913,30 @@
     ],
 }
 
+// Keep these files in sync with the apex/permission/jarjar-rules.txt for the permission module.
+filegroup {
+    name: "framework-permission-s-shared-srcs",
+    srcs: [
+        "core/java/com/android/internal/infra/AndroidFuture.java",
+        "core/java/com/android/internal/infra/ServiceConnector.java",
+        "core/java/com/android/internal/util/Preconditions.java",
+        "core/java/com/android/internal/infra/AndroidFuture.aidl",
+        "core/java/com/android/internal/infra/IAndroidFuture.aidl",
+        "core/java/android/os/HandlerExecutor.java",
+    ],
+    path: "core/java",
+}
+
+// Keep these files in sync with the apex/permission/jarjar-rules.txt for the permission module.
+filegroup {
+    name: "service-permission-shared-srcs",
+    srcs: [
+        "core/java/android/util/IndentingPrintWriter.java",
+        "core/java/com/android/internal/util/dump/DualDumpOutputStream.java",
+    ],
+    path: "core/java",
+}
+
 // Build ext.jar
 // ============================================================
 java_library {
@@ -932,6 +963,7 @@
         "cmds/statsd/src/**/*.proto",
         "core/proto/**/*.proto",
         "libs/incident/proto/**/*.proto",
+        ":service-permission-protos",
     ],
     proto: {
         include_dirs: [
@@ -965,6 +997,7 @@
         ":libstats_atom_enum_protos",
         "core/proto/**/*.proto",
         "libs/incident/proto/android/os/**/*.proto",
+        ":service-permission-protos",
     ],
 }
 
@@ -981,6 +1014,7 @@
         ":libstats_atom_enum_protos",
         "core/proto/**/*.proto",
         "libs/incident/proto/android/os/**/*.proto",
+        ":service-permission-protos",
     ],
     exclude_srcs: [
         "core/proto/android/privacy.proto",
@@ -1015,6 +1049,7 @@
         ":ipconnectivity-proto-src",
         ":libstats_atom_enum_protos",
         "core/proto/**/*.proto",
+        ":service-permission-protos",
     ],
 }