Commit 45a32111 authored by Peter Wen's avatar Peter Wen Committed by Commit Bot

Android: Allow targets to specify baseline.xml

Rather than use one universal baseline.xml for lint, allow each target
that wants to use lint baselines to specify its own via the gn variable
lint_baseline. This also allows better co-location of baseline.xml and
the code that it refers to.

Also fixes the existing lint issues for cast apk.

Bug: 1108791
Change-Id: I982cd35636ce9e08817be6cf8b6cccd18455d8ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2327834
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: default avatarMatt Reynolds <mattreynolds@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796418}
parent 9a553d37
......@@ -201,9 +201,6 @@ Still reading?
<!-- We no longer supply class files to lint. -->
<ignore regexp="No `.class` files were found in project"/>
</issue>
<!-- We use the same baseline for all our targets. Since some targets run less
code than other targets, there will always be unused suppressions. -->
<issue id="LintBaseline" severity="ignore"/>
<issue id="LogConditional" severity="ignore"/>
<issue id="LongLogTag" severity="ignore"/>
<issue id="MergeRootFrame" severity="Error">
......
......@@ -1044,14 +1044,13 @@ if (enable_java_templates) {
args += [ "--warnings-as-errors" ]
}
_stamp_path = "$target_out_dir/$target_name/build.lint.stamp"
if (defined(invoker.create_cache) && invoker.create_cache) {
args += [ "--silent" ]
# Putting the stamp file in the cache dir allows us to depend on ninja
# to create the cache dir for us.
_stamp_path = "$_cache_dir/build.lint.stamp"
args += [ "--silent" ]
} else {
_stamp_path = "$target_out_dir/$target_name/build.lint.stamp"
deps += [
"//build/android:prepare_android_lint_cache",
invoker.build_config_dep,
......@@ -1060,17 +1059,6 @@ if (enable_java_templates) {
_rebased_build_config =
rebase_path(invoker.build_config, root_build_dir)
# TODO(wnwen): Remove this baseline once it is empty.
_baseline = "//build/android/lint/baseline.xml"
_rebased_baseline = rebase_path(_baseline, root_build_dir)
if (compute_inputs_for_analyze) {
# The baseline file is included in lint.py as a depfile dep. Since
# removing it regenerates the file, it is useful to not have this as
# a gn input during local development. Add it only for bots' analyze.
inputs += [ _baseline ]
}
args += [
"--manifest-path=@FileArg($_rebased_build_config:deps_info:lint_android_manifest)",
......@@ -1081,14 +1069,25 @@ if (enable_java_templates) {
"--resource-sources=@FileArg($_rebased_build_config:deps_info:lint_resource_sources)",
"--resource-zips=@FileArg($_rebased_build_config:deps_info:lint_resource_zips)",
# Baseline allows us to turn on lint warnings without fixing all the
# pre-existing issues. This stops the flood of new issues while the
# existing ones are being fixed.
"--baseline=$_rebased_baseline",
# The full classpath is required for annotation checks like @IntDef.
"--classpath=@FileArg($_rebased_build_config:deps_info:javac_full_interface_classpath)",
]
if (defined(invoker.lint_baseline_file)) {
if (compute_inputs_for_analyze) {
# The baseline file is included in lint.py as a depfile dep. Since
# removing it regenerates the file, it is useful to not have this as
# a gn input during local development. Add it only for bots' analyze.
inputs += [ invoker.lint_baseline_file ]
}
args += [
# Baseline allows us to turn on lint warnings without fixing all the
# pre-existing issues. This stops the flood of new issues while the
# existing ones are being fixed.
"--baseline",
rebase_path(invoker.lint_baseline_file, root_build_dir),
]
}
}
outputs = [ _stamp_path ]
......
......@@ -3330,6 +3330,7 @@ if (enable_java_templates) {
android_lint("${target_name}__lint") {
forward_variables_from(invoker,
[
"lint_baseline_file",
"lint_suppressions_dep",
"lint_suppressions_file",
"manifest_package",
......@@ -3347,6 +3348,7 @@ if (enable_java_templates) {
not_needed(invoker,
[
"manifest_package",
"lint_baseline_file",
"lint_min_sdk_version",
])
}
......@@ -3456,6 +3458,7 @@ if (enable_java_templates) {
"keystore_name",
"keystore_password",
"keystore_path",
"lint_baseline_file",
"lint_min_sdk_version",
"lint_suppressions_dep",
"lint_suppressions_file",
......@@ -4996,6 +4999,7 @@ if (enable_java_templates) {
android_lint("${target_name}__lint") {
forward_variables_from(invoker,
[
"lint_baseline_file",
"lint_suppressions_dep",
"lint_suppressions_file",
"manifest_package",
......@@ -5013,6 +5017,7 @@ if (enable_java_templates) {
not_needed(invoker,
[
"manifest_package",
"lint_baseline_file",
"lint_min_sdk_version",
])
}
......
......@@ -1939,7 +1939,6 @@ template("chrome_public_apk_or_module_tmpl") {
"jni_registration_header",
"target_type",
"enable_multidex",
"lint_min_sdk_version",
"lint_suppressions_dep",
"lint_suppressions_file",
])
......
......@@ -859,7 +859,6 @@ public class VrShellDelegate
ContextUtils.getApplicationContext(), GVR_KEYBOARD_PACKAGE_ID);
}
@VisibleForTesting
protected boolean isVrBrowsingEnabled() {
return isVrBrowsingEnabled(mActivity, VrCoreInstallUtils.getVrSupportLevel());
}
......
......@@ -103,6 +103,12 @@ template("chrome_bundle") {
system_image_locale_allowlist = android_apk_locales
is_multi_abi = _is_multi_abi
# Use a consistent baseline so that it is easy to regenerate by deleting the
# file and re-building the "android_lint" target.
if (defined(invoker.enable_lint) && invoker.enable_lint) {
lint_baseline_file = "//chrome/android/expectations/lint-baseline.xml"
}
# List of DFMs that are installed by default by wrapper scripts, to make
# testing easier. This removes the need to manually specify, e.g.,
# "-m dev_ui" on every install or run.
......
......@@ -97,7 +97,6 @@ final class CursorAnchorInfoController {
});
}
@VisibleForTesting
public void setInputMethodManagerWrapper(InputMethodManagerWrapper inputMethodManagerWrapper) {
mInputMethodManagerWrapper = inputMethodManagerWrapper;
}
......
......@@ -835,7 +835,6 @@ public class ImeAdapterImpl
return true;
}
@VisibleForTesting
boolean finishComposingText() {
if (!isValid()) return false;
ImeAdapterImplJni.get().finishComposingText(mNativeImeAdapterAndroid, ImeAdapterImpl.this);
......
......@@ -99,7 +99,6 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti
containerView.getContext(), handler, containerView, this);
}
@VisibleForTesting
@Override
public void setTriggerDelayedOnCreateInputConnection(boolean trigger) {
mTriggerDelayedOnCreateInputConnection = trigger;
......
......@@ -19,7 +19,6 @@ import org.chromium.ui.base.WindowAndroid;
*/
public interface ImeAdapter {
/** Composition key code sent when user either hit a key or hit a selection. */
@VisibleForTesting
static final int COMPOSITION_KEY_CODE = 229;
/**
......
......@@ -553,7 +553,7 @@ class MediaCodecUtil {
case HWEncoder.MediatekH264:
return BitrateAdjuster.Type.FRAMERATE_ADJUSTMENT;
}
return -1;
throw new IllegalArgumentException("Invalid HWEncoder decoder parameter.");
}
/**
......
......@@ -6,8 +6,6 @@ package org.chromium.device.geolocation;
import android.location.Location;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
......@@ -23,7 +21,6 @@ import java.util.concurrent.FutureTask;
* content/browser/geolocation/location_api_adapter_android.h.
* Based on android.webkit.GeolocationService.java
*/
@VisibleForTesting
public class LocationProviderAdapter {
private static final String TAG = "LocationProvider";
......
......@@ -10,12 +10,9 @@ import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
import androidx.annotation.VisibleForTesting;
/**
* The interface for dropdown popup window.
*/
@VisibleForTesting
public interface DropdownPopupWindowInterface {
/**
* Sets the adapter that provides the data and the views to represent the data
......
......@@ -258,7 +258,6 @@ public class WindowAndroid implements AndroidPermissionDelegate, DisplayAndroidO
/**
* Set the delegate that will handle android permissions requests.
*/
@VisibleForTesting
public void setAndroidPermissionDelegate(AndroidPermissionDelegate delegate) {
mPermissionDelegate = delegate;
}
......@@ -731,7 +730,6 @@ public class WindowAndroid implements AndroidPermissionDelegate, DisplayAndroidO
return mApplicationBottomInsetProvider;
}
@VisibleForTesting
public void setKeyboardDelegate(KeyboardVisibilityDelegate keyboardDelegate) {
mKeyboardVisibilityDelegate = keyboardDelegate;
// TODO(fhorschig): Remove - every caller should use the window to get the delegate.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment