Detect method calls like Settings.Secure.getInt(). System server code should always use get*ForUser() instead of get*() methods. BUG: 166312046 Test: atest com.google.android.lint.CallingSettingsNonUserGetterMethodsIssueDetectorTest Change-Id: If54c867f58ffd92a1dd1759f806a280e5b5c04c6
Android Framework Lint Checker
Custom lint checks written here are going to be executed for modules that opt in to those (e.g. any
services.XXX module) and results will be automatically reported on CLs on gerrit.
How to add new lint checks
- Write your detector with its issues and put it into
checks/src/main/java/com/google/android/lint. - Add your detector's issues into
AndroidFrameworkIssueRegistry'sissuesfield. - Write unit tests for your detector in one file and put it into
checks/test/java/com/google/android/lint. - Done! Your lint checks should be applied in lint report builds for modules that include
AndroidFrameworkLintChecker.
How to run lint against your module
- Add the following
lintattribute to the module definition, e.g.services.autofill:
java_library_static {
name: "services.autofill",
...
lint: {
extra_check_modules: ["AndroidFrameworkLintChecker"],
},
}
- Run the following command to verify that the report is being correctly built:
m out/soong/.intermediates/frameworks/base/services/autofill/services.autofill/android_common/lint/lint-report.html
(Lint report can be found in the same path, i.e. out/../lint-report.html)
3. Now lint issues should appear on gerrit!
Notes:
- Lint report will not be produced if you just build the module, i.e.
m services.autofillwill not build the lint report. - If you want to build lint reports for more than 1 module and they depend on a common module, e.g.
platform_service_defaults, you can add thelintproperty to that common module instead of adding it in every module.
Documentation
- go/android-security-lint-checks - presentation about this module
- Android Lint Docs
- Android Lint source files
- PSI source files
- UAST source files
- IntelliJ plugin for viewing PSI tree of files