diff options
| -rw-r--r-- | core/java/android/app/ResourcesManager.java | 24 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewDelegate.java | 24 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewFactory.java | 3 |
3 files changed, 28 insertions, 23 deletions
diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java index 2d9fbf974397..35658fbcb989 100644 --- a/core/java/android/app/ResourcesManager.java +++ b/core/java/android/app/ResourcesManager.java @@ -1091,6 +1091,16 @@ public class ResourcesManager { */ @UnsupportedAppUsage public void appendLibAssetForMainAssetPath(String assetPath, String libAsset) { + appendLibAssetsForMainAssetPath(assetPath, new String[] { libAsset }); + } + + /** + * Appends the library asset paths to any ResourcesImpl object that contains the main + * assetPath. + * @param assetPath The main asset path for which to add the library asset path. + * @param libAssets The library asset paths to add. + */ + public void appendLibAssetsForMainAssetPath(String assetPath, String[] libAssets) { synchronized (this) { // Record which ResourcesImpl need updating // (and what ResourcesKey they should update to). @@ -1102,15 +1112,13 @@ public class ResourcesManager { final WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i); final ResourcesImpl impl = weakImplRef != null ? weakImplRef.get() : null; if (impl != null && Objects.equals(key.mResDir, assetPath)) { - if (!ArrayUtils.contains(key.mLibDirs, libAsset)) { - final int newLibAssetCount = 1 + - (key.mLibDirs != null ? key.mLibDirs.length : 0); - final String[] newLibAssets = new String[newLibAssetCount]; - if (key.mLibDirs != null) { - System.arraycopy(key.mLibDirs, 0, newLibAssets, 0, key.mLibDirs.length); - } - newLibAssets[newLibAssetCount - 1] = libAsset; + String[] newLibAssets = key.mLibDirs; + for (String libAsset : libAssets) { + newLibAssets = + ArrayUtils.appendElement(String.class, newLibAssets, libAsset); + } + if (newLibAssets != key.mLibDirs) { updatedResourceKeys.put(impl, new ResourcesKey( key.mResDir, key.mSplitResDirs, diff --git a/core/java/android/webkit/WebViewDelegate.java b/core/java/android/webkit/WebViewDelegate.java index 3d3d94198448..f5657dff538f 100644 --- a/core/java/android/webkit/WebViewDelegate.java +++ b/core/java/android/webkit/WebViewDelegate.java @@ -209,19 +209,17 @@ public final class WebViewDelegate { * Adds the WebView asset path to {@link android.content.res.AssetManager}. */ public void addWebViewAssetPath(Context context) { - final String newAssetPath = WebViewFactory.getLoadedPackageInfo().applicationInfo.sourceDir; - + final String[] newAssetPaths = + WebViewFactory.getLoadedPackageInfo().applicationInfo.getAllApkPaths(); final ApplicationInfo appInfo = context.getApplicationInfo(); - final String[] libs = appInfo.sharedLibraryFiles; - if (!ArrayUtils.contains(libs, newAssetPath)) { - // Build the new library asset path list. - final int newLibAssetsCount = 1 + (libs != null ? libs.length : 0); - final String[] newLibAssets = new String[newLibAssetsCount]; - if (libs != null) { - System.arraycopy(libs, 0, newLibAssets, 0, libs.length); - } - newLibAssets[newLibAssetsCount - 1] = newAssetPath; + // Build the new library asset path list. + String[] newLibAssets = appInfo.sharedLibraryFiles; + for (String newAssetPath : newAssetPaths) { + newLibAssets = ArrayUtils.appendElement(String.class, newLibAssets, newAssetPath); + } + + if (newLibAssets != appInfo.sharedLibraryFiles) { // Update the ApplicationInfo object with the new list. // We know this will persist and future Resources created via ResourcesManager // will include the shared library because this ApplicationInfo comes from the @@ -230,8 +228,8 @@ public final class WebViewDelegate { appInfo.sharedLibraryFiles = newLibAssets; // Update existing Resources with the WebView library. - ResourcesManager.getInstance().appendLibAssetForMainAssetPath( - appInfo.getBaseResourcePath(), newAssetPath); + ResourcesManager.getInstance().appendLibAssetsForMainAssetPath( + appInfo.getBaseResourcePath(), newAssetPaths); } } diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java index 6d88530f29d9..528a6a84c630 100644 --- a/core/java/android/webkit/WebViewFactory.java +++ b/core/java/android/webkit/WebViewFactory.java @@ -448,8 +448,7 @@ public final class WebViewFactory { Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getChromiumProviderClass()"); try { - initialApplication.getAssets().addAssetPathAsSharedLibrary( - webViewContext.getApplicationInfo().sourceDir); + new WebViewDelegate().addWebViewAssetPath(initialApplication); ClassLoader clazzLoader = webViewContext.getClassLoader(); Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.loadNativeLibrary()"); |