Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f8e223f authored by Cole Faust's avatar Cole Faust
Browse files

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
parent cded73ae
Loading
Loading
Loading
Loading
+1 −10
Original line number Original line Diff line number Diff line
@@ -48,18 +48,9 @@ class SaferParcelChecker : Detector(), SourceCodeScanner {
        return "$prefix$name($parameters)"
        return "$prefix$name($parameters)"
    }
    }


    /** Taken from androidx-main:core/core/src/main/java/androidx/core/os/BuildCompat.java */
    private fun isAtLeastT(context: Context): Boolean {
    private fun isAtLeastT(context: Context): Boolean {
        val project = if (context.isGlobalAnalysis()) context.mainProject else context.project
        val project = if (context.isGlobalAnalysis()) context.mainProject else context.project
        return project.isAndroidProject
        return project.isAndroidProject && project.minSdkVersion.featureLevel >= 33
                && 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)
    }
    }


    companion object {
    companion object {
+1 −1
Original line number Original line Diff line number Diff line
@@ -729,7 +729,7 @@ class SaferParcelCheckerTest : LintDetectorTest() {


    private val includes =
    private val includes =
        arrayOf(
        arrayOf(
            manifest().minSdk("Tiramisu"),
            manifest().minSdk("33"),
            java(
            java(
                """
                """
                        package android.os;
                        package android.os;