Switch service-permissions to java_sdk_library

(partial cherry-pick)

Previously, the droidstubs generated the system-server API into the
current.txt and removed.txt files which are usually associated with the
public API surface. This change moves that specification into the
system-server....txt files and verifies that no public APIs are leaking
into the stubs.

Bug: 155164730
Test: m java
Merged-In: I907533c36dcb6c0ef679b0098d497d88476d8b95
Change-Id: I907533c36dcb6c0ef679b0098d497d88476d8b95
diff --git a/apex/Android.bp b/apex/Android.bp
index 388b24a..6eaf89c 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -66,9 +66,9 @@
     "--hide-annotation android.annotation.Hide " +
     "--hide InternalClasses " // com.android.* classes are okay in this interface
 
-// Defaults for mainline module provided java_sdk_library instances.
+// Defaults common to all mainline module java_sdk_library instances.
 java_defaults {
-    name: "framework-module-defaults",
+    name: "framework-module-common-defaults",
 
     // Additional annotations used for compiling both the implementation and the
     // stubs libraries.
@@ -95,14 +95,6 @@
         enabled: true,
         sdk_version: "module_current",
     },
-    system: {
-        enabled: true,
-        sdk_version: "module_current",
-    },
-    module_lib: {
-        enabled: true,
-        sdk_version: "module_current",
-    },
 
     // Configure framework module specific metalava options.
     droiddoc_options: [mainline_stubs_args],
@@ -132,6 +124,32 @@
     sdk_version: "module_current",
 }
 
+// Defaults for mainline module provided java_sdk_library instances.
+java_defaults {
+    name: "framework-module-defaults",
+    defaults: ["framework-module-common-defaults"],
+
+    system: {
+        enabled: true,
+        sdk_version: "module_current",
+    },
+    module_lib: {
+        enabled: true,
+        sdk_version: "module_current",
+    },
+}
+
+// Defaults for mainline module system server provided java_sdk_library instances.
+java_defaults {
+    name: "framework-system-server-module-defaults",
+    defaults: ["framework-module-common-defaults"],
+
+    system_server: {
+        enabled: true,
+        sdk_version: "module_current",
+    },
+}
+
 stubs_defaults {
     name: "framework-module-stubs-defaults-publicapi",
     args: mainline_framework_stubs_args,