summaryrefslogtreecommitdiff
path: root/java/base.go
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2022-07-01 22:48:49 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-07-01 22:48:49 +0000
commit100c7ad7f28c44ca9110f73b9886c22d00a005d1 (patch)
treec65fbfd1022bfec3bfdbd18c818a16f45249763d /java/base.go
parent4b1fe58b7deca2e581b9e2df1a706f687006b4f8 (diff)
parente5bf3fb4c2ef475051ef74b29ef732118b8766bf (diff)
Merge "Revert^2 "Fix erroneous "Field requires API level 33 (current min is 32)" warnings""
Diffstat (limited to 'java/base.go')
-rw-r--r--java/base.go25
1 files changed, 22 insertions, 3 deletions
diff --git a/java/base.go b/java/base.go
index db1041116..c399c4063 100644
--- a/java/base.go
+++ b/java/base.go
@@ -1485,11 +1485,30 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
}
if ctx.Device() {
- lintSDKVersion := func(sdkSpec android.SdkSpec) android.ApiLevel {
+ lintSDKVersion := func(sdkSpec android.SdkSpec) int {
if v := sdkSpec.ApiLevel; !v.IsPreview() {
- return v
+ return v.FinalInt()
} else {
- return ctx.Config().DefaultAppTargetSdk(ctx)
+ // When running metalava, we pass --version-codename. When that value
+ // is not REL, metalava will add 1 to the --current-version argument.
+ // On old branches, PLATFORM_SDK_VERSION is the latest version (for that
+ // branch) and the codename is REL, except potentially on the most
+ // recent non-master branch. On that branch, it goes through two other
+ // phases before it gets to the phase previously described:
+ // - PLATFORM_SDK_VERSION has not been updated yet, and the codename
+ // is not rel. This happens for most of the internal branch's life
+ // while the branch has been cut but is still under active development.
+ // - PLATFORM_SDK_VERSION has been set, but the codename is still not
+ // REL. This happens briefly during the release process. During this
+ // state the code to add --current-version is commented out, and then
+ // that commenting out is reverted after the codename is set to REL.
+ // On the master branch, the PLATFORM_SDK_VERSION always represents a
+ // prior version and the codename is always non-REL.
+ //
+ // We need to add one here to match metalava adding 1. Technically
+ // this means that in the state described in the second bullet point
+ // above, this number is 1 higher than it should be.
+ return ctx.Config().PlatformSdkVersion().FinalInt() + 1
}
}