Modify non updatable droidstubs dependency based on release flag

Currently, the api file generated by the non updatable droidstubs are
copied to the dist directory regardless of the value of the
RELEASE_HIDDEN_API_EXPORTABLE_STUBS release flag. However, to align with
the other artifacts in the dist directory that respects the value of the
flag, the artifact of the everything stubs should be copied to the dist
directory when the flag value is not true, instead of the artifact of
the exportable stubs.

Test: m sdk dist && inspect the ninja dependency of out/dist/apistubs/android/test/api/android.txt
Bug: 329683584
Change-Id: I58b69893cf5e006691bf98465514f2320a5f7f55
diff --git a/api/StubLibraries.bp b/api/StubLibraries.bp
index d94890e..65ec4d4 100644
--- a/api/StubLibraries.bp
+++ b/api/StubLibraries.bp
@@ -27,7 +27,12 @@
 // These modules provide source files for the stub libraries
 /////////////////////////////////////////////////////////////////////
 
-droidstubs {
+soong_config_module_type_import {
+    from: "frameworks/base/api/Android.bp",
+    module_types: ["non_updatable_exportable_droidstubs"],
+}
+
+non_updatable_exportable_droidstubs {
     name: "api-stubs-docs-non-updatable",
     defaults: [
         "android-non-updatable-stubs-defaults",
@@ -54,15 +59,35 @@
             targets: ["sdk"],
             dir: "apistubs/android/public/api",
             dest: "android-non-updatable.txt",
-            tag: ".api.txt",
         },
         {
             targets: ["sdk"],
             dir: "apistubs/android/public/api",
             dest: "android-non-updatable-removed.txt",
-            tag: ".removed-api.txt",
         },
     ],
+    soong_config_variables: {
+        release_hidden_api_exportable_stubs: {
+            dists: [
+                {
+                    tag: ".exportable.api.txt",
+                },
+                {
+                    tag: ".exportable.removed-api.txt",
+                },
+            ],
+            conditions_default: {
+                dists: [
+                    {
+                        tag: ".api.txt",
+                    },
+                    {
+                        tag: ".removed-api.txt",
+                    },
+                ],
+            },
+        },
+    },
     api_surface: "public",
 }
 
@@ -86,7 +111,7 @@
         "\\)",
 ]
 
-droidstubs {
+non_updatable_exportable_droidstubs {
     name: "system-api-stubs-docs-non-updatable",
     defaults: [
         "android-non-updatable-stubs-defaults",
@@ -114,19 +139,39 @@
             targets: ["sdk"],
             dir: "apistubs/android/system/api",
             dest: "android-non-updatable.txt",
-            tag: ".api.txt",
         },
         {
             targets: ["sdk"],
             dir: "apistubs/android/system/api",
             dest: "android-non-updatable-removed.txt",
-            tag: ".removed-api.txt",
         },
     ],
+    soong_config_variables: {
+        release_hidden_api_exportable_stubs: {
+            dists: [
+                {
+                    tag: ".exportable.api.txt",
+                },
+                {
+                    tag: ".exportable.removed-api.txt",
+                },
+            ],
+            conditions_default: {
+                dists: [
+                    {
+                        tag: ".api.txt",
+                    },
+                    {
+                        tag: ".removed-api.txt",
+                    },
+                ],
+            },
+        },
+    },
     api_surface: "system",
 }
 
-droidstubs {
+non_updatable_exportable_droidstubs {
     name: "test-api-stubs-docs-non-updatable",
     defaults: [
         "android-non-updatable-stubs-defaults",
@@ -149,31 +194,61 @@
             targets: ["sdk"],
             dir: "apistubs/android/test/api",
             dest: "android.txt",
-            tag: ".api.txt",
         },
         {
             targets: ["sdk"],
             dir: "apistubs/android/test/api",
             dest: "removed.txt",
-            tag: ".removed-api.txt",
         },
         {
             targets: ["sdk"],
             dir: "apistubs/android/test/api",
             dest: "android-non-updatable.txt",
-            tag: ".api.txt",
         },
         {
             targets: ["sdk"],
             dir: "apistubs/android/test/api",
             dest: "android-non-updatable-removed.txt",
-            tag: ".removed-api.txt",
         },
     ],
+    soong_config_variables: {
+        release_hidden_api_exportable_stubs: {
+            dists: [
+                {
+                    tag: ".exportable.api.txt",
+                },
+                {
+                    tag: ".exportable.removed-api.txt",
+                },
+                {
+                    tag: ".exportable.api.txt",
+                },
+                {
+                    tag: ".exportable.removed-api.txt",
+                },
+            ],
+            conditions_default: {
+                dists: [
+                    {
+                        tag: ".api.txt",
+                    },
+                    {
+                        tag: ".removed-api.txt",
+                    },
+                    {
+                        tag: ".api.txt",
+                    },
+                    {
+                        tag: ".removed-api.txt",
+                    },
+                ],
+            },
+        },
+    },
     api_surface: "test",
 }
 
-droidstubs {
+non_updatable_exportable_droidstubs {
     name: "module-lib-api-stubs-docs-non-updatable",
     defaults: [
         "android-non-updatable-stubs-defaults",
@@ -201,15 +276,35 @@
             targets: ["sdk"],
             dir: "apistubs/android/module-lib/api",
             dest: "android-non-updatable.txt",
-            tag: ".api.txt",
         },
         {
             targets: ["sdk"],
             dir: "apistubs/android/module-lib/api",
             dest: "android-non-updatable-removed.txt",
-            tag: ".removed-api.txt",
         },
     ],
+    soong_config_variables: {
+        release_hidden_api_exportable_stubs: {
+            dists: [
+                {
+                    tag: ".exportable.api.txt",
+                },
+                {
+                    tag: ".exportable.removed-api.txt",
+                },
+            ],
+            conditions_default: {
+                dists: [
+                    {
+                        tag: ".api.txt",
+                    },
+                    {
+                        tag: ".removed-api.txt",
+                    },
+                ],
+            },
+        },
+    },
     api_surface: "module-lib",
 }