java_sdk_library_import: Propagate prefer to child modules
Bug: 155164730
Test: m nothing
Change-Id: Idb06d79baf346ac570beada79880814c5ef6bb50
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 2650ab3..10e7138 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1448,22 +1448,23 @@
} else if module.SystemExtSpecific() {
props.System_ext_specific = proptools.BoolPtr(true)
}
- // If the build should use prebuilt sdks then set prefer to true on the stubs library.
- // That will cause the prebuilt version of the stubs to override the source version.
- if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
- props.Prefer = proptools.BoolPtr(true)
- }
+ // The imports are preferred if the java_sdk_library_import is preferred.
+ props.Prefer = proptools.BoolPtr(module.prebuilt.Prefer())
mctx.CreateModule(ImportFactory, &props)
}
func (module *sdkLibraryImport) createPrebuiltStubsSources(mctx android.DefaultableHookContext, apiScope *apiScope, scopeProperties *sdkLibraryScopeProperties) {
props := struct {
- Name *string
- Srcs []string
+ Name *string
+ Srcs []string
+ Prefer *bool
}{}
props.Name = proptools.StringPtr(module.stubsSourceModuleName(apiScope))
props.Srcs = scopeProperties.Stub_srcs
mctx.CreateModule(PrebuiltStubsSourcesFactory, &props)
+
+ // The stubs source is preferred if the java_sdk_library_import is preferred.
+ props.Prefer = proptools.BoolPtr(module.prebuilt.Prefer())
}
func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {