Fix erroneous "Field requires API level 33 (current min is 32)" warnings

Bug: 215567981
Bug: 204776549
Test: m out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/lint/lint-report.xml, then check that that file doesn't have any of these warnings
Change-Id: I39aa2228474630c93250bf5833ac6bd9bbadcc7f
This commit is contained in:
Cole Faust
2022-04-20 18:02:42 -07:00
parent a59059f3a1
commit 8b7f627f30
3 changed files with 38 additions and 10 deletions

View File

@@ -17,6 +17,7 @@ package java
import (
"fmt"
"sort"
"strconv"
"strings"
"github.com/google/blueprint/proptools"
@@ -75,9 +76,9 @@ type linter struct {
extraLintCheckJars android.Paths
test bool
library bool
minSdkVersion android.ApiLevel
targetSdkVersion android.ApiLevel
compileSdkVersion android.ApiLevel
minSdkVersion int
targetSdkVersion int
compileSdkVersion int
compileSdkKind android.SdkKind
javaLanguageLevel string
kotlinLanguageLevel string
@@ -299,8 +300,8 @@ func (l *linter) generateManifest(ctx android.ModuleContext, rule *android.RuleB
Text(`echo "<?xml version='1.0' encoding='utf-8'?>" &&`).
Text(`echo "<manifest xmlns:android='http://schemas.android.com/apk/res/android'" &&`).
Text(`echo " android:versionCode='1' android:versionName='1' >" &&`).
Textf(`echo " <uses-sdk android:minSdkVersion='%s' android:targetSdkVersion='%s'/>" &&`,
l.minSdkVersion.String(), l.targetSdkVersion.String()).
Textf(`echo " <uses-sdk android:minSdkVersion='%d' android:targetSdkVersion='%d'/>" &&`,
l.minSdkVersion, l.targetSdkVersion).
Text(`echo "</manifest>"`).
Text(") >").Output(manifestPath)
@@ -325,7 +326,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
return
}
if l.minSdkVersion.CompareTo(l.compileSdkVersion) == -1 {
if l.minSdkVersion != l.compileSdkVersion {
l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, updatabilityChecks...)
_, filtered := android.FilterList(l.properties.Lint.Warning_checks, updatabilityChecks)
if len(filtered) != 0 {
@@ -427,7 +428,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
FlagWithOutput("--html ", html).
FlagWithOutput("--text ", text).
FlagWithOutput("--xml ", xml).
FlagWithArg("--compile-sdk-version ", l.compileSdkVersion.String()).
FlagWithArg("--compile-sdk-version ", strconv.Itoa(l.compileSdkVersion)).
FlagWithArg("--java-language-level ", l.javaLanguageLevel).
FlagWithArg("--kotlin-language-level ", l.kotlinLanguageLevel).
FlagWithArg("--url ", fmt.Sprintf(".=.,%s=out", android.PathForOutput(ctx).String())).