Skip to content

Commit

Permalink
Android: Roll android_tools and fix lint errors
Browse files Browse the repository at this point in the history
Update lint to version 26.4.0-alpha03+.

This is the first lint update since 2017 September, thus a long list of
TODOs is expected.

TBR for mechanical fixes to existing lint errors that are only exposed
due to update.

TBR=mheikal@chromium.org

Bug: 900912
Change-Id: I3335834ae308a3411ced51bb2c913b76a8f8d8c3
Reviewed-on: https://chromium-review.googlesource.com/c/1327157
Reviewed-by: Peter Wen <wnwen@chromium.org>
Reviewed-by: Mohamed Heikal <mheikal@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606631}
  • Loading branch information
Peter Wen authored and Commit Bot committed Nov 8, 2018
1 parent 6507d19 commit a9531c4
Show file tree
Hide file tree
Showing 28 changed files with 87 additions and 38 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ deps = {
},

'src/third_party/android_tools': {
'url': Var('chromium_git') + '/android_tools.git' + '@' + '130499e25286f4d56acafa252fee09f3cc595c49',
'url': Var('chromium_git') + '/android_tools.git' + '@' + '6fecaa542f73dd5aeed170d9a4cf340159b42976',
'condition': 'checkout_android_native_support',
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package org.chromium.android_webview;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
Expand Down Expand Up @@ -166,6 +167,7 @@ private class EventHandler {
EventHandler() {
}

@SuppressLint("HandlerLeak")
void bindUiThread() {
if (mHandler != null) return;
mHandler = new Handler(ThreadUtils.getUiThreadLooper()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public void closeContents() {
}

@Override
@SuppressLint("HandlerLeak")
public void showRepostFormWarningDialog() {
// TODO(mkosiba) We should be using something akin to the JsResultReceiver as the
// callback parameter (instead of WebContents) and implement a way of converting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package org.chromium.android_webview;

import android.annotation.SuppressLint;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
Expand Down Expand Up @@ -81,6 +82,7 @@ public void run() {
* This is lazily initialized as ThreadUtils.getUiThreadLooper() may not be
* set yet early in startup.
*/
@SuppressLint("HandlerLeak")
private static class LazyHolder {
static final Handler sHandler = new Handler(ThreadUtils.getUiThreadLooper()) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package org.chromium.support_lib_glue;

import android.annotation.SuppressLint;
import android.webkit.SafeBrowsingResponse;
import android.webkit.ServiceWorkerWebSettings;
import android.webkit.WebMessagePort;
Expand Down Expand Up @@ -48,6 +49,7 @@ public InvocationHandler convertWebResourceRequest(WebResourceRequest request) {
}

// ServiceWorkerWebSettingsBoundaryInterface
@SuppressLint("NewApi")
@Override
public InvocationHandler convertServiceWorkerSettings(
/* ServiceWorkerWebSettings */ Object serviceWorkerWebSettings) {
Expand All @@ -66,6 +68,7 @@ public InvocationHandler convertServiceWorkerSettings(
return new ServiceWorkerSettingsAdapter(supportLibWebSettings.getAwServiceWorkerSettings());
}

@SuppressLint("NewApi")
@Override
public /* SupportLibWebResourceError */ InvocationHandler convertWebResourceError(
/* WebResourceError */ Object webResourceError) {
Expand All @@ -83,6 +86,7 @@ public InvocationHandler convertServiceWorkerSettings(
return new WebResourceErrorAdapter(supportLibError.getAwWebResourceError());
}

@SuppressLint("NewApi")
@Override
public /* SupportLibSafeBrowsingResponse */ InvocationHandler convertSafeBrowsingResponse(
/* SafeBrowsingResponse */ Object safeBrowsingResponse) {
Expand All @@ -102,6 +106,7 @@ public InvocationHandler convertServiceWorkerSettings(
supportLibResponse.getAwSafeBrowsingResponseCallback());
}

@SuppressLint("NewApi")
@Override
public /* SupportLibWebMessagePort */ InvocationHandler convertWebMessagePort(
/* WebMessagePort */ Object webMessagePort) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
android:layout_width="match_parent"
android:layout_height="280dp" />
<EditText
tools:ignore="LabelFor"
android:id="@+id/edittext"
android:inputType="text"
android:layout_below="@+id/webview"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<EditText
tools:ignore="Autofill"
android:id="@+id/url_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
20 changes: 5 additions & 15 deletions build/android/gyp/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,23 +226,13 @@ def fail_func(returncode, stderr):
print 'File contents:'
with open(result_path) as f:
print f.read()
if not can_fail_build:
if can_fail_build:
traceback.print_exc()
if can_fail_build:
raise
else:
return

if can_fail_build and not silent:
traceback.print_exc()

# There are actual lint issues
try:
num_issues = _ParseAndShowResultFile()
except Exception: # pylint: disable=broad-except
if not silent:
print 'Lint created unparseable xml file...'
print 'File contents:'
with open(result_path) as f:
print f.read()
raise

_ProcessResultFile()
if num_issues == 0 and include_unexpected:
msg = 'Please refer to output above for unexpected lint failures.\n'
Expand Down
17 changes: 17 additions & 0 deletions build/android/lint/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Still reading?
<issue id="AuthLeak" severity="Error">
<ignore regexp="chrome/android/javatests"/>
</issue>
<issue id="Autofill">
<!-- Please do not add any additional suppressions here with the exception of the 1 file below -->
<!-- These should be added as tools:ignore="Autofill" in individual files with a bug to fix -->
<ignore regexp="chrome/android/java/res/layout/autofill_card_unmask_prompt.xml"/>
</issue>
<issue id="BadHostnameVerifier" severity="Error">
</issue>
<issue id="ButtonOrder" severity="Error">
Expand Down Expand Up @@ -185,6 +190,12 @@ Still reading?
<issue id="LogConditional" severity="ignore"/>
<issue id="LongLogTag" severity="ignore"/>
<issue id="MissingApplicationIcon" severity="ignore"/>
<issue id="MissingDefaultResource">
<!-- Only used by ToolbarControlContainer guarded by tablet form-factor. -->
<ignore regexp="toolbar_background.9.png"/>
<!-- Only used by FirstRunFlowSequencer guarded by tablet form-factor. -->
<ignore regexp="window_background.xml"/>
</issue>
<issue id="MissingPermission" severity="ignore"/>
<!-- TODO(yolandyan) remove this once all tests are converted to junit4 -->
<issue id="MissingPrefix" severity="ignore"/>
Expand Down Expand Up @@ -254,12 +265,18 @@ Still reading?
<ignore regexp="chrome/android/chrome_strings_grd.resources.zip/values/android_chrome_strings.xml"/>
</issue>
<issue id="PrivateApi" severity="ignore"/>
<!-- Chrome is a system app. -->
<issue id="ProtectedPermissions" severity="ignore"/>
<issue id="Recycle" severity="ignore"/>
<issue id="Registered" severity="ignore"/>
<issue id="ResourceAsColor" severity="ignore"/>
<issue id="ResourceType" severity="Error">
<ignore regexp="/javatests/"/>
</issue>
<issue id="RedundantNamespace">
<!-- Please do not add any additional suppressions here with the exception of the 1 file below -->
<ignore regexp="chrome/android/java/res_autofill_assistant/layout/init_screen.xml"/>
</issue>
<!-- TODO(crbug.com/831774): Play Services starts complaining about RestrictedApi. Needs investigation -->
<issue id="RestrictedApi" severity="ignore"/>
<issue id="RtlCompat" severity="ignore"/>
Expand Down
2 changes: 1 addition & 1 deletion build/config/android/internal_rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ if (enable_java_templates) {
lint_suppressions_file = "//build/android/lint/suppressions.xml"
}

_lint_path = "$lint_android_sdk_root/tools/bin/lint"
_lint_path = "$lint_android_sdk_root/tools-lint/bin/lint"
_cache_dir = "$root_build_dir/android_lint_cache"
_result_path = "$target_gen_dir/$target_name/result.xml"
_config_path = "$target_gen_dir/$target_name/config.xml"
Expand Down
5 changes: 2 additions & 3 deletions chrome/android/java/res/drawable/download_home_tabs_bg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
<solid android:color="@color/modern_grey_200" />
</shape>
</item>
<item xmlns:android="http://schemas.android.com/apk/res/android"
android:bottom="1dp">
<item android:bottom="1dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
</shape>
</item>
</layer-list>
</layer-list>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

<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">

<!-- Name -->
<org.chromium.chrome.browser.widget.CompatibilityTextInputLayout
Expand All @@ -16,7 +17,9 @@
android:layout_marginTop="@dimen/pref_autofill_field_large_top_margin"
android:layout_marginBottom="@dimen/pref_autofill_field_bottom_margin">

<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<EditText
tools:ignore="Autofill"
android:id="@+id/credit_card_name_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -35,7 +38,9 @@
android:layout_marginTop="@dimen/pref_autofill_field_top_margin"
android:layout_marginBottom="@dimen/pref_autofill_field_bottom_margin">

<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<EditText
tools:ignore="Autofill"
android:id="@+id/credit_card_number_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
2 changes: 2 additions & 0 deletions chrome/android/java/res/layout/autofill_name_fixflow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<EditText
tools:ignore="Autofill,LabelFor"
android:id="@+id/cc_name_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
3 changes: 3 additions & 0 deletions chrome/android/java/res/layout/homepage_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

Expand All @@ -26,7 +27,9 @@
style="@style/PreferenceScreenLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<EditText
tools:ignore="Autofill"
android:id="@+id/homepage_url_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
3 changes: 3 additions & 0 deletions chrome/android/java/res/layout/new_tab_page_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<org.chromium.chrome.browser.ntp.NewTabPageLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ntp_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -40,7 +41,9 @@
android:orientation="horizontal"
android:paddingStart="@dimen/location_bar_lateral_padding"
android:paddingEnd="@dimen/location_bar_lateral_padding" >
<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<EditText
tools:ignore="Autofill,LabelFor"
style="@style/TextAppearance.NewTabPageSearchBoxText"
android:id="@+id/search_box_text"
android:layout_width="0dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
android:layout_height="match_parent" >

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scroll_view"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<AutoCompleteTextView
tools:ignore="LabelFor"
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -50,4 +52,4 @@
tools:ignore="ContentDescription"
android:visibility="gone"/>
</LinearLayout>
</FrameLayout>
</FrameLayout>
3 changes: 3 additions & 0 deletions chrome/android/java/res/layout/search_toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:visibility="gone" >

<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<EditText
tools:ignore="Autofill,LabelFor"
android:id="@+id/search_text"
android:layout_width="0dp"
android:layout_height="match_parent"
Expand Down
4 changes: 2 additions & 2 deletions chrome/android/java/res/values-v19/values.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<resources>
<string name="manage_space_activity">org.chromium.chrome.browser.preferences.website.ManageSpaceActivity</string>
</resources>
<string translatable="false" name="manage_space_activity">org.chromium.chrome.browser.preferences.website.ManageSpaceActivity</string>
</resources>
19 changes: 11 additions & 8 deletions chrome/android/java/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->

<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Connection info popup dimensions -->
<dimen name="connection_info_padding_wide">24dp</dimen>
<dimen name="connection_info_padding_thin">16dp</dimen>
Expand Down Expand Up @@ -231,11 +231,12 @@
<!-- Find in Page dimensions -->
<dimen name="find_result_bar_touch_width">68dp</dimen>
<dimen name="find_result_bar_draw_width">46dp</dimen>
<dimen name="find_result_bar_result_min_height">8px</dimen>
<dimen name="find_result_bar_active_min_height">16px</dimen>
<dimen name="find_result_bar_vertical_padding">8px</dimen>
<dimen name="find_result_bar_min_gap_between_stacks">3px</dimen>
<dimen name="find_result_bar_stacked_result_height">3px</dimen>
<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<dimen tools:ignore="PxUsage" name="find_result_bar_result_min_height">8px</dimen>
<dimen tools:ignore="PxUsage" name="find_result_bar_active_min_height">16px</dimen>
<dimen tools:ignore="PxUsage" name="find_result_bar_vertical_padding">8px</dimen>
<dimen tools:ignore="PxUsage" name="find_result_bar_min_gap_between_stacks">3px</dimen>
<dimen tools:ignore="PxUsage" name="find_result_bar_stacked_result_height">3px</dimen>
<dimen name="find_in_page_separator_width">1dp</dimen>
<dimen name="find_in_page_popup_width">375dp</dimen>
<dimen name="find_in_page_popup_height">60dp</dimen>
Expand Down Expand Up @@ -315,7 +316,8 @@
<dimen name="tile_view_width_condensed">64dp</dimen>
<dimen name="tile_view_icon_size">48dp</dimen>
<dimen name="tile_view_icon_size_modern">24dp</dimen>
<dimen name="tile_view_icon_min_size">24px</dimen>
<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<dimen tools:ignore="PxUsage" name="tile_view_icon_min_size">24px</dimen>
<dimen name="tile_view_icon_corner_radius">4dp</dimen>
<dimen name="tile_view_icon_text_size">20dp</dimen>
<dimen name="tile_view_monogram_size_modern">26dp</dimen>
Expand Down Expand Up @@ -409,7 +411,8 @@
<dimen name="default_favicon_size">16dp</dimen>
<dimen name="default_favicon_corner_radius">3dp</dimen>
<dimen name="default_favicon_icon_text_size">10dp</dimen>
<dimen name="default_favicon_min_size">16px</dimen>
<!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<dimen tools:ignore="PxUsage" name="default_favicon_min_size">16px</dimen>
<dimen name="circular_monogram_size">20dp</dimen>
<dimen name="circular_monogram_text_size">14dp</dimen>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
android:layout_height="wrap_content">
<View
android:id="@+id/divider"
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/HorizontalDivider" />

<Space
Expand Down
Loading

0 comments on commit a9531c4

Please sign in to comment.