diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 212 |
1 files changed, 211 insertions, 1 deletions
diff --git a/java/java.go b/java/java.go index d7d271cca..af4c3be3b 100644 --- a/java/java.go +++ b/java/java.go @@ -87,6 +87,14 @@ func RegisterJavaSdkMemberTypes() { android.RegisterSdkMemberType(javaTestSdkMemberType) } +type StubsLinkType int + +const ( + Unknown StubsLinkType = iota + Stubs + Implementation +) + var ( // Supports adding java header libraries to module_exports and sdk. javaHeaderLibsSdkMemberType = &librarySdkMemberType{ @@ -296,6 +304,11 @@ type JavaInfo struct { // JacocoReportClassesFile is the path to a jar containing uninstrumented classes that will be // instrumented by jacoco. JacocoReportClassesFile android.Path + + // StubsLinkType provides information about whether the provided jars are stub jars or + // implementation jars. If the provider is set by java_sdk_library, the link type is "unknown" + // and selection between the stub jar vs implementation jar is deferred to SdkLibrary.sdkJars(...) + StubsLinkType StubsLinkType } var JavaInfoProvider = blueprint.NewProvider[JavaInfo]() @@ -686,14 +699,195 @@ func setUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter, dexer } } -func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { +// list of java_library modules that set platform_apis: true +// this property is a no-op for java_library +// TODO (b/215379393): Remove this allowlist +var ( + aospPlatformApiAllowlist = map[string]bool{ + "adservices-test-scenarios": true, + "aidl-cpp-java-test-interface-java": true, + "aidl-test-extras-java": true, + "aidl-test-interface-java": true, + "aidl-test-interface-permission-java": true, + "aidl_test_java_client_permission": true, + "aidl_test_java_client_sdk1": true, + "aidl_test_java_client_sdk29": true, + "aidl_test_java_client": true, + "aidl_test_java_service_permission": true, + "aidl_test_java_service_sdk1": true, + "aidl_test_java_service_sdk29": true, + "aidl_test_java_service": true, + "aidl_test_loggable_interface-java": true, + "aidl_test_nonvintf_parcelable-V1-java": true, + "aidl_test_nonvintf_parcelable-V2-java": true, + "aidl_test_unstable_parcelable-java": true, + "aidl_test_vintf_parcelable-V1-java": true, + "aidl_test_vintf_parcelable-V2-java": true, + "android.aidl.test.trunk-V1-java": true, + "android.aidl.test.trunk-V2-java": true, + "android.frameworks.location.altitude-V1-java": true, + "android.frameworks.location.altitude-V2-java": true, + "android.frameworks.stats-V1-java": true, + "android.frameworks.stats-V2-java": true, + "android.frameworks.stats-V3-java": true, + "android.hardware.authsecret-V1-java": true, + "android.hardware.authsecret-V2-java": true, + "android.hardware.biometrics.common-V1-java": true, + "android.hardware.biometrics.common-V2-java": true, + "android.hardware.biometrics.common-V3-java": true, + "android.hardware.biometrics.common-V4-java": true, + "android.hardware.biometrics.face-V1-java": true, + "android.hardware.biometrics.face-V2-java": true, + "android.hardware.biometrics.face-V3-java": true, + "android.hardware.biometrics.face-V4-java": true, + "android.hardware.biometrics.fingerprint-V1-java": true, + "android.hardware.biometrics.fingerprint-V2-java": true, + "android.hardware.biometrics.fingerprint-V3-java": true, + "android.hardware.biometrics.fingerprint-V4-java": true, + "android.hardware.bluetooth.lmp_event-V1-java": true, + "android.hardware.confirmationui-V1-java": true, + "android.hardware.confirmationui-V2-java": true, + "android.hardware.gatekeeper-V1-java": true, + "android.hardware.gatekeeper-V2-java": true, + "android.hardware.gnss-V1-java": true, + "android.hardware.gnss-V2-java": true, + "android.hardware.gnss-V3-java": true, + "android.hardware.gnss-V4-java": true, + "android.hardware.graphics.common-V1-java": true, + "android.hardware.graphics.common-V2-java": true, + "android.hardware.graphics.common-V3-java": true, + "android.hardware.graphics.common-V4-java": true, + "android.hardware.graphics.common-V5-java": true, + "android.hardware.identity-V1-java": true, + "android.hardware.identity-V2-java": true, + "android.hardware.identity-V3-java": true, + "android.hardware.identity-V4-java": true, + "android.hardware.identity-V5-java": true, + "android.hardware.identity-V6-java": true, + "android.hardware.keymaster-V1-java": true, + "android.hardware.keymaster-V2-java": true, + "android.hardware.keymaster-V3-java": true, + "android.hardware.keymaster-V4-java": true, + "android.hardware.keymaster-V5-java": true, + "android.hardware.oemlock-V1-java": true, + "android.hardware.oemlock-V2-java": true, + "android.hardware.power.stats-V1-java": true, + "android.hardware.power.stats-V2-java": true, + "android.hardware.power.stats-V3-java": true, + "android.hardware.power-V1-java": true, + "android.hardware.power-V2-java": true, + "android.hardware.power-V3-java": true, + "android.hardware.power-V4-java": true, + "android.hardware.power-V5-java": true, + "android.hardware.rebootescrow-V1-java": true, + "android.hardware.rebootescrow-V2-java": true, + "android.hardware.security.authgraph-V1-java": true, + "android.hardware.security.keymint-V1-java": true, + "android.hardware.security.keymint-V2-java": true, + "android.hardware.security.keymint-V3-java": true, + "android.hardware.security.keymint-V4-java": true, + "android.hardware.security.secureclock-V1-java": true, + "android.hardware.security.secureclock-V2-java": true, + "android.hardware.thermal-V1-java": true, + "android.hardware.thermal-V2-java": true, + "android.hardware.threadnetwork-V1-java": true, + "android.hardware.weaver-V1-java": true, + "android.hardware.weaver-V2-java": true, + "android.hardware.weaver-V3-java": true, + "android.security.attestationmanager-java": true, + "android.security.authorization-java": true, + "android.security.compat-java": true, + "android.security.legacykeystore-java": true, + "android.security.maintenance-java": true, + "android.security.metrics-java": true, + "android.system.keystore2-V1-java": true, + "android.system.keystore2-V2-java": true, + "android.system.keystore2-V3-java": true, + "android.system.keystore2-V4-java": true, + "binderReadParcelIface-java": true, + "binderRecordReplayTestIface-java": true, + "car-experimental-api-static-lib": true, + "collector-device-lib-platform": true, + "com.android.car.oem": true, + "com.google.hardware.pixel.display-V10-java": true, + "com.google.hardware.pixel.display-V1-java": true, + "com.google.hardware.pixel.display-V2-java": true, + "com.google.hardware.pixel.display-V3-java": true, + "com.google.hardware.pixel.display-V4-java": true, + "com.google.hardware.pixel.display-V5-java": true, + "com.google.hardware.pixel.display-V6-java": true, + "com.google.hardware.pixel.display-V7-java": true, + "com.google.hardware.pixel.display-V8-java": true, + "com.google.hardware.pixel.display-V9-java": true, + "conscrypt-support": true, + "cts-keystore-test-util": true, + "cts-keystore-user-auth-helper-library": true, + "ctsmediautil": true, + "CtsNetTestsNonUpdatableLib": true, + "DpmWrapper": true, + "flickerlib-apphelpers": true, + "flickerlib-helpers": true, + "flickerlib-parsers": true, + "flickerlib": true, + "hardware.google.bluetooth.ccc-V1-java": true, + "hardware.google.bluetooth.sar-V1-java": true, + "monet": true, + "pixel-power-ext-V1-java": true, + "pixel-power-ext-V2-java": true, + "pixel_stateresidency_provider_aidl_interface-java": true, + "pixel-thermal-ext-V1-java": true, + "protolog-lib": true, + "RkpRegistrationCheck": true, + "rotary-service-javastream-protos": true, + "service_based_camera_extensions": true, + "statsd-helper-test": true, + "statsd-helper": true, + "test-piece-2-V1-java": true, + "test-piece-2-V2-java": true, + "test-piece-3-V1-java": true, + "test-piece-3-V2-java": true, + "test-piece-3-V3-java": true, + "test-piece-4-V1-java": true, + "test-piece-4-V2-java": true, + "test-root-package-V1-java": true, + "test-root-package-V2-java": true, + "test-root-package-V3-java": true, + "test-root-package-V4-java": true, + "testServiceIface-java": true, + "wm-flicker-common-app-helpers": true, + "wm-flicker-common-assertions": true, + "wm-shell-flicker-utils": true, + "wycheproof-keystore": true, + } + + // Union of aosp and internal allowlists + PlatformApiAllowlist = map[string]bool{} +) + +func init() { + for k, v := range aospPlatformApiAllowlist { + PlatformApiAllowlist[k] = v + } +} +func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.provideHiddenAPIPropertyInfo(ctx) j.sdkVersion = j.SdkVersion(ctx) j.minSdkVersion = j.MinSdkVersion(ctx) j.maxSdkVersion = j.MaxSdkVersion(ctx) + // SdkLibrary.GenerateAndroidBuildActions(ctx) sets the stubsLinkType to Unknown. + // If the stubsLinkType has already been set to Unknown, the stubsLinkType should + // not be overridden. + if j.stubsLinkType != Unknown { + if proptools.Bool(j.properties.Is_stubs_module) { + j.stubsLinkType = Stubs + } else { + j.stubsLinkType = Implementation + } + } + j.stem = proptools.StringDefault(j.overridableDeviceProperties.Stem, ctx.ModuleName()) proguardSpecInfo := j.collectProguardSpecInfo(ctx) @@ -719,6 +913,9 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { setUncompressDex(ctx, &j.dexpreopter, &j.dexer) j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex j.classLoaderContexts = j.usesLibrary.classLoaderContextForUsesLibDeps(ctx) + if j.usesLibrary.shouldDisableDexpreopt { + j.dexpreopter.disableDexpreopt() + } } j.compile(ctx, nil, nil, nil) @@ -2018,6 +2215,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { ImplementationAndResourcesJars: android.PathsIfNonNil(al.stubsJar), ImplementationJars: android.PathsIfNonNil(al.stubsJar), AidlIncludeDirs: android.Paths{}, + StubsLinkType: Stubs, // No aconfig libraries on api libraries }) } @@ -2102,6 +2300,9 @@ type ImportProperties struct { // The name is the undecorated name of the java_sdk_library as it appears in the blueprint file // (without any prebuilt_ prefix) Created_by_java_sdk_library_name *string `blueprint:"mutated"` + + // Property signifying whether the module provides stubs jar or not. + Is_stubs_module *bool } type Import struct { @@ -2132,6 +2333,8 @@ type Import struct { sdkVersion android.SdkSpec minSdkVersion android.ApiLevel + + stubsLinkType StubsLinkType } var _ PermittedPackagesForUpdatableBootJars = (*Import)(nil) @@ -2226,6 +2429,12 @@ func (j *Import) commonBuildActions(ctx android.ModuleContext) { if ctx.Windows() { j.HideFromMake() } + + if proptools.Bool(j.properties.Is_stubs_module) { + j.stubsLinkType = Stubs + } else { + j.stubsLinkType = Implementation + } } func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -2359,6 +2568,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { ImplementationAndResourcesJars: android.PathsIfNonNil(j.combinedClasspathFile), ImplementationJars: android.PathsIfNonNil(j.combinedClasspathFile), AidlIncludeDirs: j.exportAidlIncludeDirs, + StubsLinkType: j.stubsLinkType, // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts }) } |