summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kevin Jeon <kevinjeon@google.com> 2021-08-24 16:39:11 +0000
committer Kevin Jeon <kevinjeon@google.com> 2021-08-24 16:39:11 +0000
commit88dd20e6d4b1e5ebde4c106bd8075ea583bf4d1a (patch)
treed99ac55d0ecd623c708b6e53ac200b39fe3aff15
parentddea459a65fa27cfd5715680729746b54bfb1159 (diff)
Revert "[lint] treat non-user getter calls as lint errors with baselines to exempt existing failures"
This reverts commit ddea459a65fa27cfd5715680729746b54bfb1159. Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=git_master&target=errorprone&lkgb=7670042&lkbb=7670063&fkbb=7670063, bug 197639027 Change-Id: Ic45c5a1a5415570000c1c1de7868f005613281c2
-rw-r--r--services/backup/lint-baseline.xml15
-rw-r--r--services/companion/lint-baseline.xml15
-rw-r--r--services/usb/lint-baseline.xml15
-rw-r--r--tools/lint/checks/src/main/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsDetector.kt5
-rw-r--r--tools/lint/checks/src/test/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsIssueDetectorTest.kt28
5 files changed, 16 insertions, 62 deletions
diff --git a/services/backup/lint-baseline.xml b/services/backup/lint-baseline.xml
deleted file mode 100644
index 28bb937cfd9c..000000000000
--- a/services/backup/lint-baseline.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 7.1.0-dev" type="baseline" client="" dependencies="true" name="" variant="all" version="7.1.0-dev">
-
- <issue
- id="NonUserGetterCalled"
- message="`android.provider.Settings.Secure#getInt()` called from system process. Please call `android.provider.Settings.Secure#getIntForUser()` instead. "
- errorLine1=" return Settings.Secure.getInt(mContext.getContentResolver(), SKIP_USER_FACING_PACKAGES,"
- errorLine2=" ~~~~~~">
- <location
- file="frameworks/base/services/backup/java/com/android/server/backup/UserBackupManagerService.java"
- line="3702"
- column="16"/>
- </issue>
-
-</issues>
diff --git a/services/companion/lint-baseline.xml b/services/companion/lint-baseline.xml
deleted file mode 100644
index 03eae3901e51..000000000000
--- a/services/companion/lint-baseline.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 7.1.0-dev" type="baseline" client="" dependencies="true" name="" variant="all" version="7.1.0-dev">
-
- <issue
- id="NonUserGetterCalled"
- message="`android.provider.Settings.Secure#getString()` called from system process. Please call `android.provider.Settings.Secure#getStringForUser()` instead. "
- errorLine1=" String setting = Settings.Secure.getString(getContext().getContentResolver(),"
- errorLine2=" ~~~~~~~~~">
- <location
- file="frameworks/base/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java"
- line="590"
- column="14"/>
- </issue>
-
-</issues>
diff --git a/services/usb/lint-baseline.xml b/services/usb/lint-baseline.xml
deleted file mode 100644
index c2c0a350d5ad..000000000000
--- a/services/usb/lint-baseline.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 7.1.0-dev" type="baseline" client="" dependencies="true" name="" variant="all" version="7.1.0-dev">
-
- <issue
- id="NonUserGetterCalled"
- message="`android.provider.Settings.Secure#getInt()` called from system process. Please call `android.provider.Settings.Secure#getIntForUser()` instead. "
- errorLine1=" int isDisabled = Settings.Secure.getInt(mContext.getContentResolver(),"
- errorLine2=" ~~~~~~">
- <location
- file="frameworks/base/services/usb/java/com/android/server/usb/UsbAlsaManager.java"
- line="150"
- column="42"/>
- </issue>
-
-</issues>
diff --git a/tools/lint/checks/src/main/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsDetector.kt b/tools/lint/checks/src/main/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsDetector.kt
index fe567da7c017..641f337ab987 100644
--- a/tools/lint/checks/src/main/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsDetector.kt
+++ b/tools/lint/checks/src/main/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsDetector.kt
@@ -45,8 +45,7 @@ class CallingSettingsNonUserGetterMethodsDetector : Detector(), SourceCodeScanne
evaluator.isMemberInClass(method, "android.provider.Settings.System")
) {
val message = getIncidentMessageNonUserGetterMethods(getMethodSignature(method))
- context.report(ISSUE_NON_USER_GETTER_CALLED, node, context.getNameLocation(node),
- message)
+ context.report(ISSUE_NON_USER_GETTER_CALLED, node, context.getLocation(node), message)
}
}
@@ -69,7 +68,7 @@ class CallingSettingsNonUserGetterMethodsDetector : Detector(), SourceCodeScanne
""",
category = Category.CORRECTNESS,
priority = 6,
- severity = Severity.ERROR,
+ severity = Severity.WARNING,
implementation = Implementation(
CallingSettingsNonUserGetterMethodsDetector::class.java,
Scope.JAVA_FILE_SCOPE
diff --git a/tools/lint/checks/src/test/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsIssueDetectorTest.kt b/tools/lint/checks/src/test/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsIssueDetectorTest.kt
index e72f38416310..1034029f6e9d 100644
--- a/tools/lint/checks/src/test/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsIssueDetectorTest.kt
+++ b/tools/lint/checks/src/test/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsIssueDetectorTest.kt
@@ -71,13 +71,13 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest()
.run()
.expect(
"""
- src/test/pkg/TestClass1.java:5: Error: \
+ src/test/pkg/TestClass1.java:5: Warning: \
android.provider.Settings.Secure#getInt() called from system process. \
Please call android.provider.Settings.Secure#getIntForUser() instead. \
[NonUserGetterCalled]
final int value = Secure.getInt(context.getContentResolver(),
- ~~~~~~
- 1 errors, 0 warnings
+ ^
+ 0 errors, 1 warnings
""".addLineContinuation()
)
}
@@ -100,13 +100,13 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest()
.run()
.expect(
"""
- src/test/pkg/TestClass1.java:5: Error: \
+ src/test/pkg/TestClass1.java:5: Warning: \
android.provider.Settings.System#getFloat() called from system process. \
Please call android.provider.Settings.System#getFloatForUser() instead. \
[NonUserGetterCalled]
final float value = System.getFloat(context.getContentResolver(),
- ~~~~~~~~
- 1 errors, 0 warnings
+ ^
+ 0 errors, 1 warnings
""".addLineContinuation()
)
}
@@ -130,13 +130,13 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest()
.run()
.expect(
"""
- src/test/pkg/TestClass1.java:5: Error: \
+ src/test/pkg/TestClass1.java:5: Warning: \
android.provider.Settings.System#getFloat() called from system process. \
Please call android.provider.Settings.System#getFloatForUser() instead. \
[NonUserGetterCalled]
float value = Settings.System.getFloat(context.getContentResolver(),
- ~~~~~~~~
- 1 errors, 0 warnings
+ ^
+ 0 errors, 1 warnings
""".addLineContinuation()
)
}
@@ -163,19 +163,19 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest()
.run()
.expect(
"""
- src/test/pkg/TestClass1.java:6: Error: \
+ src/test/pkg/TestClass1.java:6: Warning: \
android.provider.Settings.Secure#getLong() called from system process. \
Please call android.provider.Settings.Secure#getLongForUser() instead. \
[NonUserGetterCalled]
final long value1 = Secure.getLong(context.getContentResolver(),
- ~~~~~~~
- src/test/pkg/TestClass1.java:8: Error: \
+ ^
+ src/test/pkg/TestClass1.java:8: Warning: \
android.provider.Settings.System#getString() called from system process. \
Please call android.provider.Settings.System#getStringForUser() instead. \
[NonUserGetterCalled]
final String value2 = System.getString(context.getContentResolver(),
- ~~~~~~~~~
- 2 errors, 0 warnings
+ ^
+ 0 errors, 2 warnings
""".addLineContinuation()
)
}