Revert "Revert "[lint] treat non-user getter calls as lint errors with baselines to exempt existing failures""

This reverts commit 88dd20e6d4.

Reason for revert: Found the root cause, will fix it and try submit again

BUG: 195968932
Test: manual
Change-Id: I4a45ab4eb44756f4aec17fe938cfe53fc73c94cb
This commit is contained in:
Songchun Fan
2021-08-24 19:07:24 +00:00
parent a956351633
commit 3e5d384cd0
6 changed files with 220 additions and 16 deletions

View File

@@ -0,0 +1,15 @@
<?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>

View File

@@ -0,0 +1,15 @@
<?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>

View File

@@ -0,0 +1,158 @@
<?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(context.getContentResolver(),"
errorLine2=" ~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/biometrics/BiometricService.java"
line="1106"
column="20"/>
</issue>
<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(context.getContentResolver(),"
errorLine2=" ~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/biometrics/BiometricService.java"
line="1111"
column="20"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getString()` called from system process. Please call `android.provider.Settings.Secure#getStringForUser()` instead. "
errorLine1=" return Settings.Secure.getString(mContentResolver, mKey);"
errorLine2=" ~~~~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/CertBlacklister.java"
line="73"
column="36"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getInt()` called from system process. Please call `android.provider.Settings.Secure#getIntForUser()` instead. "
errorLine1=" }"
errorLine2=" ^">
<location
file="frameworks/base/services/core/java/com/android/server/clipboard/ClipboardService.java"
line="973"
column="7"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getInt()` called from system process. Please call `android.provider.Settings.Secure#getIntForUser()` instead. "
errorLine1=" boolean accessibilityEnabled = Settings.Secure.getInt(cr,"
errorLine2=" ~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/DockObserver.java"
line="176"
column="60"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getString()` called from system process. Please call `android.provider.Settings.Secure#getStringForUser()` instead. "
errorLine1=" String mediaButtonReceiverInfo = Settings.Secure.getString(mContentResolver,"
errorLine2=" ~~~~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/media/MediaSessionService.java"
line="928"
column="46"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getInt()` called from system process. Please call `android.provider.Settings.Secure#getIntForUser()` instead. "
errorLine1=" final boolean isSecureFrpEnabled ="
errorLine2=" ~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/pm/PackageInstallerSession.java"
line="1959"
column="36"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getInt()` called from system process. Please call `android.provider.Settings.Secure#getIntForUser()` instead. "
errorLine1=" private int getUnknownSourcesSettings() {"
errorLine2=" ~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java"
line="16741"
column="39"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getString()` called from system process. Please call `android.provider.Settings.Secure#getStringForUser()` instead. "
errorLine1=" String inputMethodComponent = Settings.Secure.getString(mContext.getContentResolver(),"
errorLine2=" ~~~~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/SensorPrivacyService.java"
line="489"
column="35"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getString()` called from system process. Please call `android.provider.Settings.Secure#getStringForUser()` instead. "
errorLine1=" return Settings.Secure.getString(getContentResolverAsUser(userId), key);"
errorLine2=" ~~~~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/connectivity/Vpn.java"
line="1994"
column="12"/>
</issue>
<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(getContentResolverAsUser(userId), key, def);"
errorLine2=" ~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/connectivity/Vpn.java"
line="2001"
column="12"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getInt()` called from system process. Please call `android.provider.Settings.Secure#getIntForUser()` instead. "
errorLine1=" if (Settings.Secure.getInt(mContext.getContentResolver(),"
errorLine2=" ~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/notification/ZenModeHelper.java"
line="980"
column="45"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getInt()` called from system process. Please call `android.provider.Settings.Secure#getIntForUser()` instead. "
errorLine1=" &amp;&amp; Settings.Secure.getInt(mContext.getContentResolver(),"
errorLine2=" ~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/notification/ZenModeHelper.java"
line="1442"
column="36"/>
</issue>
<issue
id="NonUserGetterCalled"
message="`android.provider.Settings.Secure#getInt()` called from system process. Please call `android.provider.Settings.Secure#getIntForUser()` instead. "
errorLine1=" &amp;&amp; Settings.Secure.getInt(mContext.getContentResolver(),"
errorLine2=" ~~~~~~">
<location
file="frameworks/base/services/core/java/com/android/server/notification/ZenModeHelper.java"
line="1444"
column="36"/>
</issue>
</issues>

View File

@@ -0,0 +1,15 @@
<?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>

View File

@@ -45,7 +45,8 @@ 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.getLocation(node), message)
context.report(ISSUE_NON_USER_GETTER_CALLED, node, context.getNameLocation(node),
message)
}
}
@@ -68,7 +69,7 @@ class CallingSettingsNonUserGetterMethodsDetector : Detector(), SourceCodeScanne
""",
category = Category.CORRECTNESS,
priority = 6,
severity = Severity.WARNING,
severity = Severity.ERROR,
implementation = Implementation(
CallingSettingsNonUserGetterMethodsDetector::class.java,
Scope.JAVA_FILE_SCOPE

View File

@@ -71,13 +71,13 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest()
.run()
.expect(
"""
src/test/pkg/TestClass1.java:5: Warning: \
src/test/pkg/TestClass1.java:5: Error: \
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(),
^
0 errors, 1 warnings
~~~~~~
1 errors, 0 warnings
""".addLineContinuation()
)
}
@@ -100,13 +100,13 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest()
.run()
.expect(
"""
src/test/pkg/TestClass1.java:5: Warning: \
src/test/pkg/TestClass1.java:5: Error: \
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(),
^
0 errors, 1 warnings
~~~~~~~~
1 errors, 0 warnings
""".addLineContinuation()
)
}
@@ -130,13 +130,13 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest()
.run()
.expect(
"""
src/test/pkg/TestClass1.java:5: Warning: \
src/test/pkg/TestClass1.java:5: Error: \
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(),
^
0 errors, 1 warnings
~~~~~~~~
1 errors, 0 warnings
""".addLineContinuation()
)
}
@@ -163,19 +163,19 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest()
.run()
.expect(
"""
src/test/pkg/TestClass1.java:6: Warning: \
src/test/pkg/TestClass1.java:6: Error: \
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: Warning: \
~~~~~~~
src/test/pkg/TestClass1.java:8: Error: \
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(),
^
0 errors, 2 warnings
~~~~~~~~~
2 errors, 0 warnings
""".addLineContinuation()
)
}