Skip to content

Commit

Permalink
Android: Remove 15 lint suppressions
Browse files Browse the repository at this point in the history
- CustomViewStyleable
- DefaultLocale
- DrawAllocation
- EllipsizeMaxLines
- ExportedContentProvider
- ExportedService
- HandlerLeak
- IconColors
- IconLauncherFormat
- IconLauncherShape
- Instantiatable
- InconsistentLayout
- InflateParams (Permanently skipped)
- InlinedApi (Permanently skipped)
- JobSchedulerService

Bug: 1116130,1081240
Fixed: 1081240
Change-Id: I37dfb048198cbbed198408f74ecce1d0876d6dfc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429808
Commit-Queue: Peter Wen <[email protected]>
Reviewed-by: Rouslan Solomakhin <[email protected]>
Reviewed-by: Andrew Grieve <[email protected]>
Reviewed-by: Natalie Chouinard <[email protected]>
Reviewed-by: Eric Orth <[email protected]>
Reviewed-by: Theresa  <[email protected]>
Reviewed-by: Richard Coles <[email protected]>
Reviewed-by: Matthew Jones <[email protected]>
Reviewed-by: Mohamed Heikal <[email protected]>
Auto-Submit: Peter Wen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#818559}
  • Loading branch information
Peter Wen authored and Commit Bot committed Oct 19, 2020
1 parent f477954 commit 9bf6c50
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@
android:exported="true"
android:grantUriPermissions="true"
android:name="org.chromium.android_webview.nonembedded.LicenseContentProvider"
android:process=":webview_apk">
android:process=":webview_apk"
tools:ignore="ExportedContentProvider">
</provider> # DIFF-ANCHOR: a5e78e63
<provider # DIFF-ANCHOR: bfe37944
android:authorities="$PACKAGE.DeveloperModeContentProvider"
android:exported="true"
android:name="org.chromium.android_webview.services.DeveloperModeContentProvider"
android:process=":webview_service"
android:visibleToInstantApps="true">
android:visibleToInstantApps="true"
tools:ignore="ExportedContentProvider">
</provider> # DIFF-ANCHOR: bfe37944
<receiver # DIFF-ANCHOR: 1091f66b
android:exported="false"
Expand Down Expand Up @@ -103,7 +105,8 @@
<service # DIFF-ANCHOR: 5cda9608
android:exported="true"
android:name="org.chromium.android_webview.services.CrashReceiverService"
android:process=":webview_service">
android:process=":webview_service"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: 5cda9608
<service # DIFF-ANCHOR: adce9ea1
android:exported="false"
Expand All @@ -114,12 +117,14 @@
android:exported="true"
android:name="org.chromium.android_webview.services.MetricsBridgeService"
android:process=":webview_service"
android:visibleToInstantApps="true">
android:visibleToInstantApps="true"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: eecf2fee
<service # DIFF-ANCHOR: dc926e35
android:exported="true"
android:name="org.chromium.android_webview.services.VariationsSeedServer"
android:process=":webview_service">
android:process=":webview_service"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: dc926e35
<service # DIFF-ANCHOR: b1e3e8bd
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@
android:exported="true"
android:grantUriPermissions="true"
android:name="org.chromium.android_webview.nonembedded.LicenseContentProvider"
android:process=":webview_apk">
android:process=":webview_apk"
tools:ignore="ExportedContentProvider">
</provider> # DIFF-ANCHOR: a5e78e63
<provider # DIFF-ANCHOR: bfe37944
android:authorities="$PACKAGE.DeveloperModeContentProvider"
android:exported="true"
android:name="org.chromium.android_webview.services.DeveloperModeContentProvider"
android:process=":webview_service"
android:visibleToInstantApps="true">
android:visibleToInstantApps="true"
tools:ignore="ExportedContentProvider">
</provider> # DIFF-ANCHOR: bfe37944
<receiver # DIFF-ANCHOR: 1091f66b
android:exported="false"
Expand Down Expand Up @@ -103,7 +105,8 @@
<service # DIFF-ANCHOR: 5cda9608
android:exported="true"
android:name="org.chromium.android_webview.services.CrashReceiverService"
android:process=":webview_service">
android:process=":webview_service"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: 5cda9608
<service # DIFF-ANCHOR: adce9ea1
android:exported="false"
Expand All @@ -114,12 +117,14 @@
android:exported="true"
android:name="org.chromium.android_webview.services.MetricsBridgeService"
android:process=":webview_service"
android:visibleToInstantApps="true">
android:visibleToInstantApps="true"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: eecf2fee
<service # DIFF-ANCHOR: dc926e35
android:exported="true"
android:name="org.chromium.android_webview.services.VariationsSeedServer"
android:process=":webview_service">
android:process=":webview_service"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: dc926e35
<service # DIFF-ANCHOR: b1e3e8bd
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ class WebViewContentsClientAdapter extends SharedWebViewContentsClientAdapter {
*
* @param webView the {@link WebView} instance that this adapter is serving.
*/
WebViewContentsClientAdapter(WebView webView, Context context,
WebViewDelegate webViewDelegate) {
@SuppressWarnings("HandlerLeak")
WebViewContentsClientAdapter(
WebView webView, Context context, WebViewDelegate webViewDelegate) {
super(webView, webViewDelegate, context);
try (ScopedSysTraceEvent event =
ScopedSysTraceEvent.scoped("WebViewContentsClientAdapter.constructor")) {
Expand Down Expand Up @@ -746,6 +747,7 @@ public void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String host, St
}

@Override
@SuppressWarnings("HandlerLeak")
public void onReceivedSslError(final Callback<Boolean> callback, SslError error) {
try {
TraceEvent.begin("WebViewContentsClientAdapter.onReceivedSslError");
Expand Down
15 changes: 10 additions & 5 deletions android_webview/nonembedded/java/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@
android:exported="true"
android:authorities="{{ manifest_package }}.LicenseContentProvider"
android:grantUriPermissions="true"
android:process=":webview_apk" /> {# Explicit process required for monochrome compatibility. #}
android:process=":webview_apk" {# Explicit process required for monochrome compatibility. #}
tools:ignore="ExportedContentProvider"/>
<!-- Disabled by default, enabled at runtime by Developer UI. -->
<provider android:name="org.chromium.android_webview.services.DeveloperModeContentProvider"
android:visibleToInstantApps="true"
android:exported="true"
android:authorities="{{ manifest_package }}.DeveloperModeContentProvider"
android:process=":webview_service" /> {# Explicit process required for monochrome compatibility. #}
android:process=":webview_service" {# Explicit process required for monochrome compatibility. #}
tools:ignore="ExportedContentProvider" />
{% if donor_package is not defined %}
<!-- If you change the variations services, also see
android_webview/test/shell/AndroidManifest.xml. -->
Expand All @@ -91,14 +93,16 @@
PathUtils.getDataDirectory() from Chrome. -->
<service android:name="org.chromium.android_webview.services.VariationsSeedServer"
android:exported="true"
android:process=":webview_service" /> {# Explicit process required for monochrome compatibility. #}
android:process=":webview_service" {# Explicit process required for monochrome compatibility. #}
tools:ignore="ExportedService" />
<service android:name="org.chromium.android_webview.services.AwVariationsSeedFetcher"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false"
android:process=":webview_service" /> {# Explicit process required for monochrome compatibility. #}
<service android:name="org.chromium.android_webview.services.CrashReceiverService"
android:exported="true"
android:process=":webview_service" /> {# Explicit process required for monochrome compatibility. #}
android:process=":webview_service" {# Explicit process required for monochrome compatibility. #}
tools:ignore="ExportedService" />
<service android:name="org.chromium.android_webview.services.AwMinidumpUploadJobService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true"
Expand All @@ -109,7 +113,8 @@
<service android:name="org.chromium.android_webview.services.MetricsBridgeService"
android:exported="true"
android:visibleToInstantApps="true"
android:process=":webview_service" /> {# Explicit process required for monochrome compatibility. #}
android:process=":webview_service" {# Explicit process required for monochrome compatibility. #}
tools:ignore="ExportedService" />
{% endif %}
{% endmacro %}
{{ common(manifest_package|default('com.android.webview'), library|default('libwebviewchromium.so')) }}
Expand Down
2 changes: 1 addition & 1 deletion build/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (enable_java_templates) {
}

android_lint("android_lint_test") {
lint_expected_warnings = "InlinedApi,NewApi"
lint_expected_warnings = "DefaultLocale,NewApi"
_test_apk_target = ":lint_test_apk"
deps = [ "${_test_apk_target}__java" ]
build_config_dep = "$_test_apk_target$build_config_target_suffix"
Expand Down
2 changes: 2 additions & 0 deletions build/android/gyp/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
_DISABLED_ALWAYS = [
"AppCompatResource", # Lint does not correctly detect our appcompat lib.
"Assert", # R8 --force-enable-assertions is used to enable java asserts.
"InflateParams", # Null is ok when inflating views for dialogs.
"InlinedApi", # Constants are copied so they are always available.
"LintBaseline", # Don't warn about using baseline.xml files.
"MissingApplicationIcon", # False positive for non-production targets.
"SwitchIntDef", # Many C++ enums are not used at all in java.
Expand Down
12 changes: 8 additions & 4 deletions build/android/java/test/LintTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
package test;

import android.app.Application;
import android.content.Context;

/**
* A class with methods that are meant to trigger lint warnings. If it does not trigger these
* expected warnings, then the build will fail. This prevents lint regressions where lint warnings
* are accidentally disabled.
*/
public class LintTest extends Application {
public static String testTriggerInlinedApiCheck() {
// This was added in API level 30.
return Context.CONNECTIVITY_DIAGNOSTICS_SERVICE;
public String testTriggerDefaultLocaleCheck(int any) {
// String format with an integer requires a Locale since it may be formatted differently.
return String.format("Test %d", any);
}

public String testTriggerNewApiCheck() {
Expand Down
41 changes: 2 additions & 39 deletions chrome/android/expectations/lint-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,10 @@ Still reading?
<issue id="AcceptsUserCertificates">
<!-- See https://crbug.com/827265 and comment in the file for context. -->
<ignore regexp="chrome/android/java/res_base/xml/network_security_config.xml"/>
<ignore regexp="android_webview/tools/system_webview_shell/apk/res/xml/network_security_config.xml"/>
</issue>
<issue id="CustomViewStyleable">
<!-- TODO(crbug.com/1077861): Old code, good to fix. -->
<ignore regexp="components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/BoundedLinearLayout.java"/>
</issue>
<issue id="DefaultLocale">
<ignore regexp="clank"/>
<ignore regexp="com/android/tv"/>
<!-- TODO(crbug.com/1081240): Fix -->
<ignore regexp="chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedSurfaceMediator.java"/>
<!-- TODO(crbug.com/1082222): Fix -->
<ignore regexp="chrome/android/java/src/org/chromium/chrome/browser/omnibox/suggestions/header/HeaderProcessor.java"/>
</issue>
<issue id="DrawAllocation">
<ignore regexp="content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java"/>
<ignore regexp="content/public/android/java/src/org/chromium/content/browser/PopupZoomer.java"/>
</issue>
<!-- TODO(crbug.com/804432): Remove this and fix the offending xml files. -->
<issue id="EllipsizeMaxLines" severity="ignore"/>
<issue id="ExifInterface">
<!-- TODO(crbug.com/804438): Cannot update until android.media.ExifInterface supports file descriptors -->
<ignore regexp="components/browser_ui/photo_picker/android/java/src/org/chromium/components/browser_ui/photo_picker/BitmapUtils.java"/>
</issue>
<issue id="ExportedContentProvider" severity="ignore"/>
<issue id="ExportedService" severity="ignore"/>
<issue id="HandlerLeak">
<ignore regexp="android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java"/>
</issue>
<issue id="IconColors">
<ignore regexp="tools/android/audio_focus_grabber/java/res/drawable-.*/notification_icon.png"/>
<!-- TODO(crbug.com/804438): Update to androidx ExifInterface. -->
<ignore regexp="components/browser_ui/photo_picker/android/java/src/org/chromium/components/browser_ui/photo_picker/BitmapUtils.java"/>
</issue>
<issue id="IconDensities">
<!-- This is intentional to reduce APK size. See: http://crrev/c/1352161 -->
Expand All @@ -69,10 +42,6 @@ Still reading?
<!-- Filed https://crbug.com/1073963 -->
<ignore regexp="clank/java/res_default/mipmap-.*/app_shortcut_icon.png"/>
</issue>
<issue id="IconLauncherFormat" severity="ignore"/>
<issue id="IconLauncherShape">
<ignore regexp="chrome/android/webapk/shell_apk/res/mipmap-mdpi/ic_launcher_background.png"/>
</issue>
<issue id="IconLocation">
<!-- It is OK for content_shell_apk to have missing assets. -->
<ignore regexp="content/shell/android/java/res/"/>
Expand All @@ -99,22 +68,16 @@ Still reading?
<issue id="InsecureBaseConfiguration">
<!-- See https://crbug.com/827265 and comment in the file for context. -->
<ignore regexp="chrome/android/java/res_base/xml/network_security_config.xml"/>
<ignore regexp="android_webview/tools/system_webview_shell/apk/res/xml/network_security_config.xml"/>
</issue>
<issue id="Instantiatable" severity="ignore"/>
<issue id="InconsistentArrays">
<ignore regexp="android_webview/locale_paks.resources.zip/values/locale-paks.xml"/>
<ignore regexp="chrome/android/chrome_locale_paks.resources.zip/values/locale-paks.xml"/>
<ignore regexp="preloaded_fonts.xml"/>
</issue>
<issue id="InconsistentLayout" severity="ignore"/>
<issue id="InefficientWeight">
<ignore regexp="android_webview/tools/system_webview_shell/apk/res/layout/activity_webview_browser.xml"/>
</issue>
<issue id="InflateParams" severity="ignore"/>
<issue id="InlinedApi" severity="ignore"/>
<issue id="InvalidVectorPath" severity="ignore"/>
<issue id="JobSchedulerService" severity="ignore"/>
<issue id="LabelFor">
<ignore regexp="android_webview/tools/system_webview_shell/apk/res/layout/activity_webview_browser.xml"/>
</issue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,14 +844,16 @@
android:exported="true"
android:grantUriPermissions="true"
android:name="org.chromium.android_webview.nonembedded.LicenseContentProvider"
android:process=":webview_apk">
android:process=":webview_apk"
tools:ignore="ExportedContentProvider">
</provider> # DIFF-ANCHOR: a5e78e63
<provider # DIFF-ANCHOR: bfe37944
android:authorities="$PACKAGE.DeveloperModeContentProvider"
android:exported="true"
android:name="org.chromium.android_webview.services.DeveloperModeContentProvider"
android:process=":webview_service"
android:visibleToInstantApps="true">
android:visibleToInstantApps="true"
tools:ignore="ExportedContentProvider">
</provider> # DIFF-ANCHOR: bfe37944
<provider # DIFF-ANCHOR: 97e158a1
android:authorities="$PACKAGE.DownloadFileProvider"
Expand Down Expand Up @@ -1056,7 +1058,8 @@
<service # DIFF-ANCHOR: 5cda9608
android:exported="true"
android:name="org.chromium.android_webview.services.CrashReceiverService"
android:process=":webview_service">
android:process=":webview_service"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: 5cda9608
<service # DIFF-ANCHOR: adce9ea1
android:exported="false"
Expand All @@ -1067,12 +1070,14 @@
android:exported="true"
android:name="org.chromium.android_webview.services.MetricsBridgeService"
android:process=":webview_service"
android:visibleToInstantApps="true">
android:visibleToInstantApps="true"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: eecf2fee
<service # DIFF-ANCHOR: dc926e35
android:exported="true"
android:name="org.chromium.android_webview.services.VariationsSeedServer"
android:process=":webview_service">
android:process=":webview_service"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: dc926e35
<service # DIFF-ANCHOR: c34d99ad
android:exported="true"
Expand Down Expand Up @@ -1210,10 +1215,11 @@
android:name="org.chromium.components.background_task_scheduler.internal.BackgroundTaskJobService"
android:permission="android.permission.BIND_JOB_SERVICE">
</service> # DIFF-ANCHOR: a550decc
<service # DIFF-ANCHOR: 2ce68981
<service # DIFF-ANCHOR: 2a1cd701
android:exported="true"
android:name="org.chromium.components.payments.PaymentDetailsUpdateService">
</service> # DIFF-ANCHOR: 2ce68981
android:name="org.chromium.components.payments.PaymentDetailsUpdateService"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: 2a1cd701
<service # DIFF-ANCHOR: 0c6c4fd9
android:exported="false"
android:isolatedProcess="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1117,10 +1117,11 @@
android:name="org.chromium.components.background_task_scheduler.internal.BackgroundTaskJobService"
android:permission="android.permission.BIND_JOB_SERVICE">
</service> # DIFF-ANCHOR: a550decc
<service # DIFF-ANCHOR: 2ce68981
<service # DIFF-ANCHOR: 2a1cd701
android:exported="true"
android:name="org.chromium.components.payments.PaymentDetailsUpdateService">
</service> # DIFF-ANCHOR: 2ce68981
android:name="org.chromium.components.payments.PaymentDetailsUpdateService"
tools:ignore="ExportedService">
</service> # DIFF-ANCHOR: 2a1cd701
<service # DIFF-ANCHOR: 0c6c4fd9
android:exported="false"
android:isolatedProcess="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.mojom.WindowOpenDisposition;

import java.util.Locale;

/**
* A mediator for the {@link FeedSurfaceCoordinator} responsible for interacting with the
* native library and handling business logic.
Expand Down Expand Up @@ -615,8 +617,8 @@ public void onItemSelected(PropertyModel item) {
FeedUma.recordFeedControlsAction(FeedUma.CONTROLS_ACTION_TOGGLED_FEED);
SuggestionsMetrics.recordArticlesListVisible();
} else {
assert false
: String.format("Cannot handle action for item in the menu with id %d", itemId);
assert false : String.format(Locale.ENGLISH,
"Cannot handle action for item in the menu with id %d", itemId);
}
}

Expand Down
3 changes: 2 additions & 1 deletion chrome/android/java/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,8 @@ by a child template that "extends" this file.
payment method, shipping address, or shipping option -->
<service
android:name="org.chromium.components.payments.PaymentDetailsUpdateService"
android:exported="true"/>
android:exported="true"
tools:ignore="ExportedService"/>

<receiver android:name="org.chromium.chrome.browser.announcement.AnnouncementNotificationManager$Receiver"
android:exported="false"/>
Expand Down
6 changes: 4 additions & 2 deletions chrome/android/java/res/layout-sw600dp/location_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<!-- The location bar also know as URL bar -->
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<include layout="@layout/location_status" />

Expand All @@ -20,7 +21,8 @@
android:layout_marginEnd="80dp"
android:layout_gravity="center_vertical"
android:nextFocusForward="@+id/menu_button"
layout="@layout/url_bar" />
tools:ignore="InconsistentLayout"
layout="@layout/url_bar"/>

<include layout="@layout/url_action_container" />

Expand Down
Loading

0 comments on commit 9bf6c50

Please sign in to comment.