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

Commit e2916513 authored by Thiébaud Weksteen's avatar Thiébaud Weksteen
Browse files

Add utility lint for metrics on @EnforcePermission

Bug: 298285238
Test: lint_fix --print --no-fix --check AnnotatedAidlCounter --lint-module AndroidUtilsLintChecker services.autofill
Test: atest --host AndroidUtilsLintCheckerTest
Change-Id: I7876e44cabc006de9b996f84477e15071cb95203
parent 96431b11
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -27,3 +27,30 @@ java_library_host {
    libs: ["lint_api"],
    kotlincflags: ["-Xjvm-default=all"],
}

java_defaults {
    name: "AndroidLintCheckerTestDefaults",
    srcs: ["checks/src/test/java/**/*.kt"],
    static_libs: [
        "junit",
        "lint",
        "lint_tests",
    ],
    test_options: {
        unit_test: true,
        tradefed_options: [
            {
                // lint bundles in some classes that were built with older versions
                // of libraries, and no longer load. Since tradefed tries to load
                // all classes in the jar to look for tests, it crashes loading them.
                // Exclude these classes from tradefed's search.
                name: "exclude-paths",
                value: "org/apache",
            },
            {
                name: "exclude-paths",
                value: "META-INF",
            },
        ],
    },
}
+1 −20
Original line number Diff line number Diff line
@@ -37,28 +37,9 @@ java_library_host {

java_test_host {
    name: "AndroidFrameworkLintCheckerTest",
    defaults: ["AndroidLintCheckerTestDefaults"],
    srcs: ["checks/src/test/java/**/*.kt"],
    static_libs: [
        "AndroidFrameworkLintChecker",
        "junit",
        "lint",
        "lint_tests",
    ],
    test_options: {
        unit_test: true,
        tradefed_options: [
            {
                // lint bundles in some classes that were built with older versions
                // of libraries, and no longer load. Since tradefed tries to load
                // all classes in the jar to look for tests, it crashes loading them.
                // Exclude these classes from tradefed's search.
                name: "exclude-paths",
                value: "org/apache",
            },
            {
                name: "exclude-paths",
                value: "META-INF",
            },
        ],
    },
}
+1 −20
Original line number Diff line number Diff line
@@ -38,28 +38,9 @@ java_library_host {

java_test_host {
    name: "AndroidGlobalLintCheckerTest",
    defaults: ["AndroidLintCheckerTestDefaults"],
    srcs: ["checks/src/test/java/**/*.kt"],
    static_libs: [
        "AndroidGlobalLintChecker",
        "junit",
        "lint",
        "lint_tests",
    ],
    test_options: {
        unit_test: true,
        tradefed_options: [
            {
                // lint bundles in some classes that were built with older versions
                // of libraries, and no longer load. Since tradefed tries to load
                // all classes in the jar to look for tests, it crashes loading them.
                // Exclude these classes from tradefed's search.
                name: "exclude-paths",
                value: "org/apache",
            },
            {
                name: "exclude-paths",
                value: "META-INF",
            },
        ],
    },
}
+45 −0
Original line number Diff line number Diff line
// Copyright (C) 2023 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_base_license"],
}

java_library_host {
    name: "AndroidUtilsLintChecker",
    srcs: ["checks/src/main/java/**/*.kt"],
    plugins: ["auto_service_plugin"],
    libs: [
        "auto_service_annotations",
        "lint_api",
    ],
    static_libs: [
        "AndroidCommonLint",
    ],
    kotlincflags: ["-Xjvm-default=all"],
}

java_test_host {
    name: "AndroidUtilsLintCheckerTest",
    defaults: ["AndroidLintCheckerTestDefaults"],
    srcs: ["checks/src/test/java/**/*.kt"],
    static_libs: [
        "AndroidUtilsLintChecker",
    ],
}
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.lint

import com.android.tools.lint.client.api.IssueRegistry
import com.android.tools.lint.client.api.Vendor
import com.android.tools.lint.detector.api.CURRENT_API
import com.google.android.lint.aidl.AnnotatedAidlCounter
import com.google.auto.service.AutoService

@AutoService(IssueRegistry::class)
@Suppress("UnstableApiUsage")
class AndroidUtilsIssueRegistry : IssueRegistry() {
    override val issues = listOf(
        AnnotatedAidlCounter.ISSUE_ANNOTATED_AIDL_COUNTER,
    )

    override val api: Int
        get() = CURRENT_API

    override val minApi: Int
        get() = 8

    override val vendor: Vendor = Vendor(
        vendorName = "Android",
        feedbackUrl = "http://b/issues/new?component=315013",
        contact = "tweek@google.com"
    )
}
Loading