Build complete api-versions.xml files for module-lib/system-server

Previously, APIs from updatable modules and information about the SDK
extensions was only included in `api_versions_public` and
`api_versions_system`. This change adds the following two modules:
* `api_versions_module_lib_complete`
* `api_versions_system_server_complete`

It did not change `api_versions_module_lib` or
`api_versions_system_server` because Android Lint requires that they do
not include information about APIs from updatable modules because
otherwise it will report calls within a module as it has no way to
determine whether a call crosses an API boundary or not.

Bug: 336993217
Test: TARGETS=$(for i in public system module-lib module-lib-complete system-server-complete; do U=$(echo $i | sed "s|-|_|g"); echo "out/target/common/obj/PACKAGING/api_versions_${U}_generated-api-versions.xml"; done)
      m $TARGETS; mkdir -p before; cp $TARGETS before
      m $TARGETS; mkdir -p after; cp $TARGETS after
      meld before after
      # Review differences.
Change-Id: Ia542fbdc517fb223a0488f0e3f81b8727cb204e4
diff --git a/api/StubLibraries.bp b/api/StubLibraries.bp
index 525c208..f2c39be 100644
--- a/api/StubLibraries.bp
+++ b/api/StubLibraries.bp
@@ -1214,6 +1214,32 @@
     api_levels_sdk_type: "module-lib",
 }
 
+// Create a single jar containing the whole module-lib API surface.
+// This is needed because Metalava only consumes the first jar file it is given
+// and ignores the rest.
+java_library {
+    name: "android_module_stubs_complete_current_with_test_libs",
+    static_libs: [
+        "android_module_stubs_current_with_test_libs",
+        "framework-updatable-stubs-module_libs_api-exportable",
+    ],
+    defaults: ["android.jar_defaults"],
+    visibility: [
+        "//visibility:override",
+        "//visibility:private",
+    ],
+}
+
+// Produces an `api-versions.xml` file that includes up-to-date information
+// about all the module-lib APIs, both updatable and non-updatable and historic
+// information about all previous dessert and SDK extension releases.
+droidstubs {
+    name: "api_versions_module_lib_complete",
+    defaults: ["api_versions_complete_defaults"],
+    srcs: [":android_module_stubs_complete_current_with_test_libs{.jar}"],
+    api_levels_sdk_type: "module-lib",
+}
+
 // Produces an `api-versions.xml` file that includes up-to-date information
 // about only the non-updatable system-server APIs and historic information
 // about all previous dessert and SDK extension releases. That historic
@@ -1226,6 +1252,36 @@
     api_levels_sdk_type: "system-server",
 }
 
+// Create a single jar containing the whole system-server API surface.
+// This is needed because Metalava only consumes the first jar file it is given
+// and ignores the rest.
+java_library {
+    name: "android_system_server_stubs_complete_current_with_test_libs",
+    static_libs: [
+        "android_system_server_stubs_current_with_test_libs",
+        // system-server extends module-lib but libraries which only service-*
+        // libraries provided system-server APIs, so include module-lib APIs for
+        // the others, e.g. framework-* libraries.
+        "framework-updatable-stubs-module_libs_api-exportable",
+        "framework-updatable-stubs-system_server_api-exportable",
+    ],
+    defaults: ["android.jar_defaults"],
+    visibility: [
+        "//visibility:override",
+        "//visibility:private",
+    ],
+}
+
+// Produces an `api-versions.xml` file that includes up-to-date information
+// about all the system-server APIs, both updatable and non-updatable and
+// historic information about all previous dessert and SDK extension releases.
+droidstubs {
+    name: "api_versions_system_server_complete",
+    defaults: ["api_versions_complete_defaults"],
+    srcs: [":android_system_server_stubs_complete_current_with_test_libs{.jar}"],
+    api_levels_sdk_type: "system-server",
+}
+
 /////////////////////////////////////////////////////////////////////
 // hwbinder.stubs provides APIs required for building HIDL Java
 // libraries.