Commit 409db70f authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

Ignore known strict mode violations in WebLayer shell

This CL makes
//weblayer/shell/android:weblayer_shell_java ignore unavoidable known
strict mode violations. The KnownViolations.java list is taken matches
the list used for other Google apps.

BUG=1134600

Change-Id: Ie3de4e820798659a5f0e5500329004c657a573fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2445854
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814817}
parent 53ca78bb
......@@ -26,6 +26,18 @@ public interface ThreadStrictModeInterceptor {
*/
void install(ThreadPolicy detectors);
/**
* Builds ThreadStrictModeInterceptor with the death penalty and with
* {@link KnownViolations} exempted.
*/
public static ThreadStrictModeInterceptor buildWithDeathPenaltyAndKnownViolationExemptions() {
ThreadStrictModeInterceptor.Builder threadInterceptor =
new ThreadStrictModeInterceptor.Builder();
threadInterceptor.replaceAllPenaltiesWithDeathPenalty();
KnownViolations.addExemptions(threadInterceptor);
return threadInterceptor.build();
}
/**
* Builds a configuration for StrictMode enforcement.
*
......
......@@ -42,6 +42,7 @@ android_library("weblayer_shell_java") {
":weblayer_shell_resources",
"$google_play_services_package:google_play_services_base_java",
"//base:base_java",
"//components/strictmode/android:java",
"//third_party/android_deps:android_support_v4_java",
"//third_party/android_deps:android_support_v7_appcompat_java",
"//third_party/android_deps:androidx_annotation_annotation_java",
......
noparent = True
include_rules = [
"+base/android/java",
"+components/strictmode/android/java",
"+weblayer/public/java",
]
......@@ -24,6 +24,7 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import org.chromium.base.ContextUtils;
import org.chromium.components.strictmode.ThreadStrictModeInterceptor;
import org.chromium.weblayer.Browser;
import org.chromium.weblayer.FullscreenCallback;
import org.chromium.weblayer.NewTabCallback;
......@@ -178,8 +179,8 @@ public class InstrumentationActivity extends FragmentActivity {
protected void onCreate(final Bundle savedInstanceState) {
// JaCoCo injects code that does file access, which doesn't work well with strict mode.
if (!isJaCoCoEnabled()) {
StrictMode.setThreadPolicy(
new ThreadPolicy.Builder().detectAll().penaltyLog().penaltyDeath().build());
ThreadStrictModeInterceptor.buildWithDeathPenaltyAndKnownViolationExemptions().install(
new ThreadPolicy.Builder().detectAll().build());
// This doesn't use detectAll() as the untagged sockets policy is encountered in tests
// using TestServer.
StrictMode.setVmPolicy(new VmPolicy.Builder()
......
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