Automatically export bootclasspath_fragment stubs from sdk
This change makes the tag that is used to add dependencies onto stubs
from the bootclaspath_fragment module cause the dependency to be
automatically exported from the sdk. If the dependency is a
java_sdk_library then it will be as if it was added to the
java_sdk_libs property, otherwise it will be as if it was added to the
java_header_libs property instead.
Bug: 177892522
Test: m nothing
Change-Id: I97010c4342dd39415dba81a4395db7831410436e
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index 8cc6f8f..793d63a 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -33,6 +33,21 @@
return false
}
+func (b hiddenAPIStubsDependencyTag) SdkMemberType(child android.Module) android.SdkMemberType {
+ // If the module is a java_sdk_library then treat it as if it was specific in the java_sdk_libs
+ // property, otherwise treat if it was specified in the java_header_libs property.
+ if javaSdkLibrarySdkMemberType.IsInstance(child) {
+ return javaSdkLibrarySdkMemberType
+ }
+
+ return javaHeaderLibsSdkMemberType
+}
+
+func (b hiddenAPIStubsDependencyTag) ExportMember() bool {
+ // Export the module added via this dependency tag from the sdk.
+ return true
+}
+
// Avoid having to make stubs content explicitly visible to dependent modules.
//
// This is a temporary workaround to make it easier to migrate to bootclasspath_fragment modules
@@ -44,6 +59,7 @@
var _ android.ExcludeFromVisibilityEnforcementTag = hiddenAPIStubsDependencyTag{}
var _ android.ReplaceSourceWithPrebuilt = hiddenAPIStubsDependencyTag{}
var _ android.ExcludeFromApexContentsTag = hiddenAPIStubsDependencyTag{}
+var _ android.SdkMemberTypeDependencyTag = hiddenAPIStubsDependencyTag{}
// hiddenAPIRelevantSdkKinds lists all the android.SdkKind instances that are needed by the hidden
// API processing.
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 05ce97a..fcc105d 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -339,12 +339,7 @@
})
// Register sdk member types.
- android.RegisterSdkMemberType(&sdkLibrarySdkMemberType{
- android.SdkMemberTypeBase{
- PropertyName: "java_sdk_libs",
- SupportsSdk: true,
- },
- })
+ android.RegisterSdkMemberType(javaSdkLibrarySdkMemberType)
}
func RegisterSdkLibraryBuildComponents(ctx android.RegistrationContext) {
@@ -2377,6 +2372,13 @@
return &sdkLibrarySdkMemberProperties{}
}
+var javaSdkLibrarySdkMemberType = &sdkLibrarySdkMemberType{
+ android.SdkMemberTypeBase{
+ PropertyName: "java_sdk_libs",
+ SupportsSdk: true,
+ },
+}
+
type sdkLibrarySdkMemberProperties struct {
android.SdkMemberPropertiesBase