Commit 542cb9cf authored by Shimi Zhang's avatar Shimi Zhang Committed by Commit Bot

Android: Disable StrictMode for setPrimaryClipNoException() on OEM devices.

In some OEM Android framework clipboard service code, there are strict
mode violations, which makes the calling thread/process to crash. We
need to suppress the crash by disabling strict mode.

Bug: 1123727, 1113428
Change-Id: Iee30100c0ae41fee1856a7b5d8c43e1a28132959
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386662Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Shimi Zhang <ctzsm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803340}
parent 9dade7b1
...@@ -29,6 +29,7 @@ import org.chromium.base.ApiCompatibilityUtils; ...@@ -29,6 +29,7 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.BuildInfo; import org.chromium.base.BuildInfo;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.StrictModeContext;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
...@@ -41,6 +42,7 @@ import org.chromium.ui.widget.Toast; ...@@ -41,6 +42,7 @@ import org.chromium.ui.widget.Toast;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Locale;
/** /**
* Simple proxy that provides C++ code with an access pathway to the Android clipboard. * Simple proxy that provides C++ code with an access pathway to the Android clipboard.
...@@ -328,7 +330,12 @@ public class Clipboard implements ClipboardManager.OnPrimaryClipChangedListener ...@@ -328,7 +330,12 @@ public class Clipboard implements ClipboardManager.OnPrimaryClipChangedListener
} }
private boolean setPrimaryClipNoException(ClipData clip) { private boolean setPrimaryClipNoException(ClipData clip) {
try { final String manufacturer = Build.MANUFACTURER.toLowerCase(Locale.US);
// See crbug.com/1123727, there are OEM devices having strict mode violations in their
// Android framework code. Disabling strict mode for non-google devices.
try (StrictModeContext ignored = manufacturer.equals("google")
? null
: StrictModeContext.allowAllThreadPolicies()) {
mClipboardManager.setPrimaryClip(clip); mClipboardManager.setPrimaryClip(clip);
return true; return true;
} catch (Exception ex) { } catch (Exception ex) {
......
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