Commit 1a2b208c authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

[WebLayer] Allow disk reads when creating PathClassLoader

PathClassLoader may call stat on the library paths, which causes a
strict mode violation. We may want to try to move this to a background
thread eventually.

Bug: 1071119
Change-Id: I51df3ee7bcd3a4bb94d4c0a56a21d97dc9406548
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2150886Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759398}
parent 13509c1f
......@@ -9,6 +9,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.StrictMode;
import android.text.TextUtils;
import android.util.Pair;
......@@ -43,9 +44,18 @@ final class WebViewCompatibilityHelper {
libraryPaths[i] = "/." + libraryPaths[i];
}
}
ClassLoader classLoader = new PathClassLoader(getAllApkPaths(info.applicationInfo),
TextUtils.join(File.pathSeparator, libraryPaths),
ClassLoader.getSystemClassLoader());
// TODO(cduvall): PathClassLoader may call stat on the library paths, consider moving this
// to a background thread.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
ClassLoader classLoader;
try {
classLoader = new PathClassLoader(getAllApkPaths(info.applicationInfo),
TextUtils.join(File.pathSeparator, libraryPaths),
ClassLoader.getSystemClassLoader());
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
return Pair.create(classLoader, WebLayer.WebViewCompatibilityResult.SUCCESS);
}
......
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