Commit d89b9494 authored by Thomas Guilbert's avatar Thomas Guilbert Committed by Commit Bot

Fix MediaRouter.getInstance StrictMode error

Some manufacturers have a native MediaRouter implementations that causes
a StrictModeDiskReadViolation when trying to acquire a MediaRouter
instance.

This CL temporarily changes the StrictMode policy to allow disk reads
when we acquire the native MediaRouter.

Bug: 818325
Change-Id: I2b1452c03ef6767d17c243ce5e9c4964cb95c75d
Reviewed-on: https://chromium-review.googlesource.com/947542Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541262}
parent afa66b7b
......@@ -8,6 +8,7 @@ import android.support.v7.media.MediaRouter;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.StrictModeContext;
import org.chromium.base.SysUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
......@@ -98,7 +99,10 @@ public class ChromeMediaRouter implements MediaRouteManager {
@Nullable
public static MediaRouter getAndroidMediaRouter() {
if (sAndroidMediaRouterSetForTest) return sAndroidMediaRouterForTest;
try {
// Some manufacturers have an implementation that causes StrictMode
// violations. See https://crbug.com/818325.
try (StrictModeContext unused = StrictModeContext.allowDiskReads()) {
// Pre-MR1 versions of JB do not have the complete MediaRouter APIs,
// so getting the MediaRouter instance will throw an exception.
return MediaRouter.getInstance(ContextUtils.getApplicationContext());
......
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