diff --git a/apex/builder.go b/apex/builder.go index 2701a3606..65bae159a 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -442,21 +442,18 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { targetSdkVersion := ctx.Config().DefaultAppTargetSdk() minSdkVersion := ctx.Config().DefaultAppTargetSdk() + // TODO: this should be based on min_sdk_version property of an APEX. if proptools.Bool(a.properties.Legacy_android10_support) { - if !java.UseApiFingerprint(ctx, targetSdkVersion) { - targetSdkVersion = "29" - } - if !java.UseApiFingerprint(ctx, minSdkVersion) { - minSdkVersion = "29" - } + targetSdkVersion = "29" + minSdkVersion = "29" } - if java.UseApiFingerprint(ctx, targetSdkVersion) { - targetSdkVersion += fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String()) + if java.UseApiFingerprint(ctx) { + targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String()) implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx)) } - if java.UseApiFingerprint(ctx, minSdkVersion) { - minSdkVersion += fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String()) + if java.UseApiFingerprint(ctx) { + minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String()) implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx)) } optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion) diff --git a/java/android_manifest.go b/java/android_manifest.go index 9a71be28a..8280cb1b1 100644 --- a/java/android_manifest.go +++ b/java/android_manifest.go @@ -99,8 +99,8 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext if err != nil { ctx.ModuleErrorf("invalid targetSdkVersion: %s", err) } - if UseApiFingerprint(ctx, targetSdkVersion) { - targetSdkVersion += fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String()) + if UseApiFingerprint(ctx) { + targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String()) deps = append(deps, ApiFingerprintPath(ctx)) } @@ -108,8 +108,8 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext if err != nil { ctx.ModuleErrorf("invalid minSdkVersion: %s", err) } - if UseApiFingerprint(ctx, minSdkVersion) { - minSdkVersion += fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String()) + if UseApiFingerprint(ctx) { + minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String()) deps = append(deps, ApiFingerprintPath(ctx)) } diff --git a/java/sdk.go b/java/sdk.go index 1e60d6774..20a077230 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -50,9 +50,8 @@ type sdkContext interface { targetSdkVersion() sdkSpec } -func UseApiFingerprint(ctx android.BaseModuleContext, v string) bool { - if v == ctx.Config().PlatformSdkCodename() && - ctx.Config().UnbundledBuild() && +func UseApiFingerprint(ctx android.BaseModuleContext) bool { + if ctx.Config().UnbundledBuild() && !ctx.Config().UnbundledBuildUsePrebuiltSdks() && ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") { return true