Stop framework-media from being api_only

Removes the api_only: true property and adds the necessary properties
needed to compile the implementation library. It also stops
updatable-media from building from source and instead makes it
statically include framework-media.impl.

Bug: 190807367
Bug: 229932396
Test: m com.android.media media-module-sdk
      # Compare before and after this change.
Change-Id: Ic34b29399f20a04921f697f6a92cc6c82003bb10
diff --git a/apex/framework/Android.bp b/apex/framework/Android.bp
index f7e7e66..7bba456 100644
--- a/apex/framework/Android.bp
+++ b/apex/framework/Android.bp
@@ -17,17 +17,20 @@
     default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
+// The dex jar produced by this is used in the APEX but otherwise this is not
+// used.
 java_library {
     name: "updatable-media",
 
-    srcs: [
-        ":updatable-media-srcs",
+    static_libs: [
+        "framework-media.impl",
     ],
 
     permitted_packages: [
         "android.media",
     ],
 
+    // Optimize the dex jar for the APEX.
     optimize: {
         enabled: true,
         shrink: true,
@@ -37,19 +40,6 @@
     installable: true,
 
     sdk_version: "module_current",
-    libs: [
-        "androidx.annotation_annotation",
-        "framework-annotations-lib",
-    ],
-    static_libs: [
-        "exoplayer-media_apex",
-        "mediatranscoding_aidl_interface-java",
-        "modules-annotation-minsdk",
-        "modules-utils-build",
-    ],
-    jarjar_rules: "jarjar_rules.txt",
-
-    plugins: ["java_api_finder"],
 
     hostdex: true, // for hiddenapi check
     apex_available: [
@@ -57,14 +47,10 @@
         "test_com.android.media",
     ],
     min_sdk_version: "29",
-    lint: {
-        strict_updatability_linting: true,
-    },
     visibility: [
+        // This MUST not be used for compilation within the media module, use
+        // framework-media.impl instead.
         "//frameworks/av/apex:__subpackages__",
-        "//frameworks/base/apex/media/service",
-        "//frameworks/base/api", // For framework-all
-        "//packages/modules/Media/apex/service",
     ],
 }
 
@@ -129,14 +115,38 @@
     name: "framework-media",
     defaults: ["framework-module-defaults"],
 
-    // This is only used to define the APIs for updatable-media.
-    api_only: true,
-
     srcs: [
         ":updatable-media-srcs",
     ],
 
-    impl_library_visibility: ["//frameworks/av/apex:__subpackages__"],
+    impl_library_visibility: [
+        "//frameworks/base/api", // For framework-all
+        "//packages/modules/Media:__subpackages__",
+    ],
+
+    sdk_version: "module_current",
+    impl_only_libs: [
+        "androidx.annotation_annotation",
+        "framework-annotations-lib",
+    ],
+    impl_only_static_libs: [
+        "exoplayer-media_apex",
+        "mediatranscoding_aidl_interface-java",
+        "modules-annotation-minsdk",
+        "modules-utils-build",
+    ],
+    jarjar_rules: "jarjar_rules.txt",
+
+    plugins: ["java_api_finder"],
+
+    apex_available: [
+        "com.android.media",
+        "test_com.android.media",
+    ],
+    lint: {
+        strict_updatability_linting: true,
+    },
+    min_sdk_version: "29",
 }
 
 cc_library_shared {
diff --git a/apex/service/Android.bp b/apex/service/Android.bp
index 0e300bb..5f5eb54 100644
--- a/apex/service/Android.bp
+++ b/apex/service/Android.bp
@@ -36,7 +36,7 @@
     ],
     libs: [
         "androidx.annotation_annotation",
-        "updatable-media",
+        "framework-media.impl",
         "modules-annotation-minsdk",
         "modules-utils-build",
     ],