summaryrefslogtreecommitdiff
path: root/core/java/android/webkit/WebViewDelegate.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/webkit/WebViewDelegate.java')
-rw-r--r--core/java/android/webkit/WebViewDelegate.java30
1 files changed, 28 insertions, 2 deletions
diff --git a/core/java/android/webkit/WebViewDelegate.java b/core/java/android/webkit/WebViewDelegate.java
index 9e73af273c35..2cdff7906462 100644
--- a/core/java/android/webkit/WebViewDelegate.java
+++ b/core/java/android/webkit/WebViewDelegate.java
@@ -21,7 +21,9 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.ActivityThread;
import android.app.Application;
+import android.app.ResourcesManager;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.os.SystemProperties;
@@ -31,6 +33,8 @@ import android.view.DisplayListCanvas;
import android.view.View;
import android.view.ViewRootImpl;
+import com.android.internal.util.ArrayUtils;
+
/**
* Delegate used by the WebView provider implementation to access
* the required framework functionality needed to implement a {@link WebView}.
@@ -177,7 +181,29 @@ public final class WebViewDelegate {
* Adds the WebView asset path to {@link android.content.res.AssetManager}.
*/
public void addWebViewAssetPath(Context context) {
- context.getAssets().addAssetPathAsSharedLibrary(
- WebViewFactory.getLoadedPackageInfo().applicationInfo.sourceDir);
+ final String newAssetPath = WebViewFactory.getLoadedPackageInfo().applicationInfo.sourceDir;
+
+ 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;
+
+ // 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
+ // underlying LoadedApk in ContextImpl, which does not change during the life of the
+ // application.
+ appInfo.sharedLibraryFiles = newLibAssets;
+
+ // Update existing Resources with the WebView library.
+ ResourcesManager.getInstance().appendLibAssetForMainAssetPath(
+ appInfo.getBaseResourcePath(), newAssetPath);
+ }
}
}