summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2022-06-29 18:12:27 -0700
committer Cole Faust <colefaust@google.com> 2022-06-30 10:29:57 -0700
commit3f8e223f76ae9a2311486b4577cf836f4f83a6d9 (patch)
treeef5e8507fd88b55a3030062c01c93c328b176548
parentcded73aec1ab94d974b4a99e9afb0a576f0ec9f9 (diff)
Don't check project codename
project.minSdkVersion.codename is annotated @Nullable in java, but here in kotlin code it's passed to a non-null String. Soong is making a change that will no longer pass the codename to android lint, and cause it to have a null codename, and then this checker would crash. Checking the codename doesn't appear to be necessary in this case, checking the featureLevel should be enough. The difference between featureLevel and apiLevel is that featureLevel will be apiLevel+1 if a codename is set, so it should already have the codename logic built in. Bug: 215567981 Test: m lint-check with aosp/2072628 Change-Id: I003390021f0badfea3a79c8cf87d089d65a58e34
-rw-r--r--tools/lint/checks/src/main/java/com/google/android/lint/parcel/SaferParcelChecker.kt11
-rw-r--r--tools/lint/checks/src/test/java/com/google/android/lint/parcel/SaferParcelCheckerTest.kt2
2 files changed, 2 insertions, 11 deletions
diff --git a/tools/lint/checks/src/main/java/com/google/android/lint/parcel/SaferParcelChecker.kt b/tools/lint/checks/src/main/java/com/google/android/lint/parcel/SaferParcelChecker.kt
index bf99e8e669fc..f92826316be4 100644
--- a/tools/lint/checks/src/main/java/com/google/android/lint/parcel/SaferParcelChecker.kt
+++ b/tools/lint/checks/src/main/java/com/google/android/lint/parcel/SaferParcelChecker.kt
@@ -48,18 +48,9 @@ class SaferParcelChecker : Detector(), SourceCodeScanner {
return "$prefix$name($parameters)"
}
- /** Taken from androidx-main:core/core/src/main/java/androidx/core/os/BuildCompat.java */
private fun isAtLeastT(context: Context): Boolean {
val project = if (context.isGlobalAnalysis()) context.mainProject else context.project
- return project.isAndroidProject
- && project.minSdkVersion.featureLevel >= 32
- && isAtLeastPreReleaseCodename("Tiramisu", project.minSdkVersion.codename)
- }
-
- /** Taken from androidx-main:core/core/src/main/java/androidx/core/os/BuildCompat.java */
- private fun isAtLeastPreReleaseCodename(min: String, actual: String): Boolean {
- if (actual == "REL") return false
- return actual.uppercase(Locale.ROOT) >= min.uppercase(Locale.ROOT)
+ return project.isAndroidProject && project.minSdkVersion.featureLevel >= 33
}
companion object {
diff --git a/tools/lint/checks/src/test/java/com/google/android/lint/parcel/SaferParcelCheckerTest.kt b/tools/lint/checks/src/test/java/com/google/android/lint/parcel/SaferParcelCheckerTest.kt
index 1286e519aae6..e686695ca804 100644
--- a/tools/lint/checks/src/test/java/com/google/android/lint/parcel/SaferParcelCheckerTest.kt
+++ b/tools/lint/checks/src/test/java/com/google/android/lint/parcel/SaferParcelCheckerTest.kt
@@ -729,7 +729,7 @@ class SaferParcelCheckerTest : LintDetectorTest() {
private val includes =
arrayOf(
- manifest().minSdk("Tiramisu"),
+ manifest().minSdk("33"),
java(
"""
package android.os;