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

Commit 87a167d8 authored by Azhara Assanova's avatar Azhara Assanova Committed by Tudor Magirescu
Browse files

Migrate PermissionAnnotationDetector to global lint checks

Cherry-picked from internal branch. Originally authored by
tmagirescu@google.com.

PermissionAnnotationDetector will no longer be a local lint check which
could optionally be added to build targets, but instead a global lint
check ran on every build. New AIDL Interfaces part of the system_server
process will need to use @EnforcePermission annotations. The detector
does not enforce old AIDL Interfaces to use the annotations. These are
included in the exemptAidlInterfaces set generated by
ExemptAidlInterfacesGenerator.

The CL removes the reference to the PermissionAnnotationDetector from
the Accessibility Service build targets. Instead the already-annotated
AIDL Interfaces are removed from exemptAidlInterfaces, achieving the
same effect.

Bug: 363248121
Test: PermissionAnnotationDetectorTest
Flag: EXEMPT lint check
Merged-In: I2cad77cbc7883087dd95b9558d3543fcb321bbc8
Change-Id: I47873ec83d8f26a97f1f6ff70a056899dd9c5f45
parent 97c492bd
Loading
Loading
Loading
Loading
+0 −5
Original line number Original line Diff line number Diff line
@@ -19,11 +19,6 @@ java_library_static {
    defaults: [
    defaults: [
        "platform_service_defaults",
        "platform_service_defaults",
    ],
    ],
    lint: {
        error_checks: ["MissingPermissionAnnotation"],
        baseline_filename: "lint-baseline.xml",

    },
    srcs: [
    srcs: [
        ":services.accessibility-sources",
        ":services.accessibility-sources",
        "//frameworks/base/packages/SettingsLib/RestrictedLockUtils:SettingsLibRestrictedLockUtilsSrc",
        "//frameworks/base/packages/SettingsLib/RestrictedLockUtils:SettingsLibRestrictedLockUtilsSrc",
+0 −1
Original line number Original line Diff line number Diff line
@@ -62,7 +62,6 @@ import java.util.StringJoiner;
 *
 *
 * NOTE: This class has to be created and poked only from the main thread.
 * NOTE: This class has to be created and poked only from the main thread.
 */
 */
@SuppressWarnings("MissingPermissionAnnotation")
class AccessibilityInputFilter extends InputFilter implements EventStreamTransformation {
class AccessibilityInputFilter extends InputFilter implements EventStreamTransformation {


    private static final String TAG = AccessibilityInputFilter.class.getSimpleName();
    private static final String TAG = AccessibilityInputFilter.class.getSimpleName();
+0 −1
Original line number Original line Diff line number Diff line
@@ -33,7 +33,6 @@ import java.util.List;
/**
/**
 * Encapsulate fingerprint gesture logic
 * Encapsulate fingerprint gesture logic
 */
 */
@SuppressWarnings("MissingPermissionAnnotation")
public class FingerprintGestureDispatcher extends IFingerprintClientActiveCallback.Stub
public class FingerprintGestureDispatcher extends IFingerprintClientActiveCallback.Stub
        implements Handler.Callback{
        implements Handler.Callback{
    private static final int MSG_REGISTER = 1;
    private static final int MSG_REGISTER = 1;
+23 −0
Original line number Original line Diff line number Diff line
@@ -103,3 +103,26 @@ fun getHelperMethodFix(


    return fix.build()
    return fix.build()
}
}

/**
 * PermissionAnnotationDetector uses this method to determine whether a specific file should be
 * checked for unannotated methods. Only files located in directories whose paths begin with one
 * of these prefixes will be considered.
 */
fun isSystemServicePath(context: JavaContext): Boolean {
    val systemServicePathPrefixes = setOf(
        "frameworks/base/services",
        "frameworks/base/apex",
        "frameworks/opt/wear",
        "packages/modules"
    )

    val filePath = context.file.path

    // We perform `filePath.contains` instead of `filePath.startsWith` since getting the
    // relative path of a source file is non-trivial. That is because `context.file.path`
    // returns the path to where soong builds the file (i.e. /out/soong/...). Moreover, the
    // logic to extract the relative path would need to consider several /out/soong/...
    // locations patterns.
    return systemServicePathPrefixes.any { filePath.contains(it) }
}
+0 −2
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ import com.android.tools.lint.client.api.IssueRegistry
import com.android.tools.lint.client.api.Vendor
import com.android.tools.lint.client.api.Vendor
import com.android.tools.lint.detector.api.CURRENT_API
import com.android.tools.lint.detector.api.CURRENT_API
import com.google.android.lint.parcel.SaferParcelChecker
import com.google.android.lint.parcel.SaferParcelChecker
import com.google.android.lint.aidl.PermissionAnnotationDetector
import com.google.auto.service.AutoService
import com.google.auto.service.AutoService


@AutoService(IssueRegistry::class)
@AutoService(IssueRegistry::class)
@@ -38,7 +37,6 @@ class AndroidFrameworkIssueRegistry : IssueRegistry() {
        SaferParcelChecker.ISSUE_UNSAFE_API_USAGE,
        SaferParcelChecker.ISSUE_UNSAFE_API_USAGE,
        // TODO: Currently crashes due to OOM issue
        // TODO: Currently crashes due to OOM issue
        // PackageVisibilityDetector.ISSUE_PACKAGE_NAME_NO_PACKAGE_VISIBILITY_FILTERS,
        // PackageVisibilityDetector.ISSUE_PACKAGE_NAME_NO_PACKAGE_VISIBILITY_FILTERS,
        PermissionAnnotationDetector.ISSUE_MISSING_PERMISSION_ANNOTATION,
        PermissionMethodDetector.ISSUE_PERMISSION_METHOD_USAGE,
        PermissionMethodDetector.ISSUE_PERMISSION_METHOD_USAGE,
        PermissionMethodDetector.ISSUE_CAN_BE_PERMISSION_METHOD,
        PermissionMethodDetector.ISSUE_CAN_BE_PERMISSION_METHOD,
        FeatureAutomotiveDetector.ISSUE,
        FeatureAutomotiveDetector.ISSUE,
Loading