diff options
Diffstat (limited to 'core/java/android/webkit/WebViewZygote.java')
| -rw-r--r-- | core/java/android/webkit/WebViewZygote.java | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/core/java/android/webkit/WebViewZygote.java b/core/java/android/webkit/WebViewZygote.java index 3a1c4576ab3e..de1f3df61462 100644 --- a/core/java/android/webkit/WebViewZygote.java +++ b/core/java/android/webkit/WebViewZygote.java @@ -150,6 +150,7 @@ public class WebViewZygote { } try { + String abi = sPackage.applicationInfo.primaryCpuAbi; sZygote = Process.ZYGOTE_PROCESS.startChildZygote( "com.android.internal.os.WebViewZygoteInit", "webview_zygote", @@ -158,39 +159,40 @@ public class WebViewZygote { null, // gids 0, // runtimeFlags "webview_zygote", // seInfo - sPackage.applicationInfo.primaryCpuAbi, // abi + abi, // abi TextUtils.join(",", Build.SUPPORTED_ABIS), null, // instructionSet Process.FIRST_ISOLATED_UID, Process.LAST_ISOLATED_UID); - - // All the work below is usually done by LoadedApk, but the zygote can't talk to - // PackageManager or construct a LoadedApk since it's single-threaded pre-fork, so - // doesn't have an ActivityThread and can't use Binder. - // Instead, figure out the paths here, in the system server where we have access to - // the package manager. Reuse the logic from LoadedApk to determine the correct - // paths and pass them to the zygote as strings. - final List<String> zipPaths = new ArrayList<>(10); - final List<String> libPaths = new ArrayList<>(10); - LoadedApk.makePaths(null, false, sPackage.applicationInfo, zipPaths, libPaths); - final String librarySearchPath = TextUtils.join(File.pathSeparator, libPaths); - final String zip = (zipPaths.size() == 1) ? zipPaths.get(0) : - TextUtils.join(File.pathSeparator, zipPaths); - - String libFileName = WebViewFactory.getWebViewLibrary(sPackage.applicationInfo); - - // In the case where the ApplicationInfo has been modified by the stub WebView, - // we need to use the original ApplicationInfo to determine what the original classpath - // would have been to use as a cache key. - LoadedApk.makePaths(null, false, sPackageOriginalAppInfo, zipPaths, null); - final String cacheKey = (zipPaths.size() == 1) ? zipPaths.get(0) : - TextUtils.join(File.pathSeparator, zipPaths); - ZygoteProcess.waitForConnectionToZygote(sZygote.getPrimarySocketAddress()); - Log.d(LOGTAG, "Preloading package " + zip + " " + librarySearchPath); - sZygote.preloadPackageForAbi(zip, librarySearchPath, libFileName, cacheKey, - Build.SUPPORTED_ABIS[0]); + if (sPackageOriginalAppInfo.sourceDir.equals(sPackage.applicationInfo.sourceDir)) { + // No stub WebView is involved here, so we can preload the package the "clean" way + // using the ApplicationInfo. + sZygote.preloadApp(sPackage.applicationInfo, abi); + } else { + // Legacy path to support the stub WebView. + // Reuse the logic from LoadedApk to determine the correct paths and pass them to + // the zygote as strings. + final List<String> zipPaths = new ArrayList<>(10); + final List<String> libPaths = new ArrayList<>(10); + LoadedApk.makePaths(null, false, sPackage.applicationInfo, zipPaths, libPaths); + final String librarySearchPath = TextUtils.join(File.pathSeparator, libPaths); + final String zip = (zipPaths.size() == 1) ? zipPaths.get(0) : + TextUtils.join(File.pathSeparator, zipPaths); + + String libFileName = WebViewFactory.getWebViewLibrary(sPackage.applicationInfo); + + // Use the original ApplicationInfo to determine what the original classpath would + // have been to use as a cache key. + LoadedApk.makePaths(null, false, sPackageOriginalAppInfo, zipPaths, null); + final String cacheKey = (zipPaths.size() == 1) ? zipPaths.get(0) : + TextUtils.join(File.pathSeparator, zipPaths); + + Log.d(LOGTAG, "Preloading package " + zip + " " + librarySearchPath); + sZygote.preloadPackageForAbi(zip, librarySearchPath, libFileName, cacheKey, + Build.SUPPORTED_ABIS[0]); + } } catch (Exception e) { Log.e(LOGTAG, "Error connecting to webview zygote", e); stopZygoteLocked(); |
