Add hidden API properties to java_sdk_library modules
Previously, hidden API properties were only allowed on
bootclasspath_fragment and platform_bootclasspath module types. This
change allows them to be specified on java_sdk_library modules too. It
involves the following changes:
1. Add the properties to the java.Module.
2. Populate and provide a HiddenAPIPropertyInfo struct from
java_sdk_library modules.
3. Modify bootclasspath_fragment to merge information gathered from its
content libraries as if it was specified on the fragment itself.
Bug: 240406019
Test: m nothing
packages/modules/common/build/mainline_modules_sdks.sh
# Ran the previous command with and without this change to make
# sure that this change does not change the sdk snapshot
# contents.
Change-Id: I64eb71c2039ddc14cf380689d0cec7ec221f5b88
(cherry picked from commit 3f1ae0b55acd7e727c6227c3ab3e4f34e885e478)
Merged-In: I64eb71c2039ddc14cf380689d0cec7ec221f5b88
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index 13ddbe7..c93055a 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -675,8 +675,8 @@
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
java.PrepareForTestWithJavaSdkLibraryFiles,
- java.FixtureWithLastReleaseApis("mysdklibrary"),
- java.FixtureConfigureApexBootJars("myapex:mybootlib"),
+ java.FixtureWithLastReleaseApis("mysdklibrary", "mynewlibrary"),
+ java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:mynewlibrary"),
prepareForSdkTestWithApex,
// Add a platform_bootclasspath that depends on the fragment.
@@ -691,6 +691,7 @@
"my-removed.txt": nil,
"my-unsupported-packages.txt": nil,
"my-unsupported.txt": nil,
+ "my-new-max-target-q.txt": nil,
}.AddToFixture(),
android.FixtureWithRootAndroidBp(`
sdk {
@@ -708,7 +709,7 @@
bootclasspath_fragment {
name: "mybootclasspathfragment",
apex_available: ["myapex"],
- contents: ["mybootlib"],
+ contents: ["mybootlib", "mynewlibrary"],
api: {
stub_libs: ["mysdklibrary"],
},
@@ -737,7 +738,9 @@
unsupported_packages: [
"my-unsupported-packages.txt",
],
- split_packages: ["*"],
+ split_packages: ["sdklibrary"],
+ package_prefixes: ["sdklibrary.all.mine"],
+ single_packages: ["sdklibrary.mine"],
},
}
@@ -759,6 +762,24 @@
public: {enabled: true},
permitted_packages: ["mysdklibrary"],
}
+
+ java_sdk_library {
+ name: "mynewlibrary",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ min_sdk_version: "10",
+ compile_dex: true,
+ public: {enabled: true},
+ permitted_packages: ["mysdklibrary"],
+ hidden_api: {
+ max_target_q: [
+ "my-new-max-target-q.txt",
+ ],
+ split_packages: ["sdklibrary", "newlibrary"],
+ package_prefixes: ["newlibrary.all.mine"],
+ single_packages: ["newlibrary.mine"],
+ },
+ }
`),
).RunTest(t)
@@ -774,7 +795,10 @@
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["myapex"],
- contents: ["mybootlib"],
+ contents: [
+ "mybootlib",
+ "mynewlibrary",
+ ],
api: {
stub_libs: ["mysdklibrary"],
},
@@ -782,7 +806,10 @@
unsupported: ["hiddenapi/my-unsupported.txt"],
removed: ["hiddenapi/my-removed.txt"],
max_target_r_low_priority: ["hiddenapi/my-max-target-r-low-priority.txt"],
- max_target_q: ["hiddenapi/my-max-target-q.txt"],
+ max_target_q: [
+ "hiddenapi/my-max-target-q.txt",
+ "hiddenapi/my-new-max-target-q.txt",
+ ],
max_target_p: ["hiddenapi/my-max-target-p.txt"],
max_target_o_low_priority: ["hiddenapi/my-max-target-o-low-priority.txt"],
blocked: ["hiddenapi/my-blocked.txt"],
@@ -806,6 +833,23 @@
}
java_sdk_library_import {
+ name: "mynewlibrary",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["myapex"],
+ shared_library: true,
+ compile_dex: true,
+ permitted_packages: ["mysdklibrary"],
+ public: {
+ jars: ["sdk_library/public/mynewlibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/public/mynewlibrary_stub_sources"],
+ current_api: "sdk_library/public/mynewlibrary.txt",
+ removed_api: "sdk_library/public/mynewlibrary-removed.txt",
+ sdk_version: "current",
+ },
+}
+
+java_sdk_library_import {
name: "mysdklibrary",
prefer: false,
visibility: ["//visibility:public"],
@@ -827,6 +871,7 @@
my-removed.txt -> hiddenapi/my-removed.txt
my-max-target-r-low-priority.txt -> hiddenapi/my-max-target-r-low-priority.txt
my-max-target-q.txt -> hiddenapi/my-max-target-q.txt
+my-new-max-target-q.txt -> hiddenapi/my-new-max-target-q.txt
my-max-target-p.txt -> hiddenapi/my-max-target-p.txt
my-max-target-o-low-priority.txt -> hiddenapi/my-max-target-o-low-priority.txt
my-blocked.txt -> hiddenapi/my-blocked.txt
@@ -838,6 +883,9 @@
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
+.intermediates/mynewlibrary.stubs/android_common/javac/mynewlibrary.stubs.jar -> sdk_library/public/mynewlibrary-stubs.jar
+.intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt
+.intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt