From aa2aad6d0fdf0487e93169fa8476f37bdd70d649 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 31 Jan 2023 23:13:45 +0000 Subject: [PATCH] Stop ignoring the targetSdkVersion when it includes the API fingerprint SHA Change https://r.android.com/1959021 introduced a regression in the handling of the `targetSdkVersion` when using the API fingerprint. Prior to that change, when `UseApiFingerprint(ctx)` returned true that would cause all APKs (apart from `framework-res`) that were built to use a `targetSdkVersion` that included the API fingerprint SHA. After that change the `UseApiFingerprint(ctx)` had no effect on the setting of `targetSdkVersion`. This change corrects that. Bug: 266899206 Test: UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true TARGET_BUILD_APPS="NetworkStack" m aapt2 dump badging out/target/product/generic/system/priv-app/NetworkStack/NetworkStack.apk # Run above before and after this change and see that the targetSdkVersion # has changed to `UpsideDownCake.`. Change-Id: Ic6e1da552c565cc4bd75cc734b3acb7faec67981 --- java/android_manifest.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/android_manifest.go b/java/android_manifest.go index c7853103f..f6457a096 100644 --- a/java/android_manifest.go +++ b/java/android_manifest.go @@ -149,13 +149,14 @@ func ManifestFixer(ctx android.ModuleContext, manifest android.Path, if params.SdkContext != nil { targetSdkVersion := targetSdkVersionForManifestFixer(ctx, params) - args = append(args, "--targetSdkVersion ", targetSdkVersion) if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" { targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String()) deps = append(deps, ApiFingerprintPath(ctx)) } + args = append(args, "--targetSdkVersion ", targetSdkVersion) + minSdkVersion, err := params.SdkContext.MinSdkVersion(ctx).EffectiveVersionString(ctx) if err != nil { ctx.ModuleErrorf("invalid minSdkVersion: %s", err)