summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorGustav Sennton <gsennton@google.com>2015-06-19 13:23:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-19 13:23:52 +0000
commit1b48a6430ae503ff2826657ef0d1d4a090f7aa37 (patch)
tree6276791cf238e35a5688f7f4643eb5f4be49dce6 /core/java
parent50057943fbf36c84c220d47115e7cdd13fa01a4c (diff)
parentd9730182212b157083321ea4e2209182f1fbb72f (diff)
Merge "Revert "Load WebView from one out of a list of packages."" into mnc-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/webkit/WebViewFactory.java54
1 files changed, 16 insertions, 38 deletions
diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java
index b4ef58afb94d..3b9aca8883e3 100644
--- a/core/java/android/webkit/WebViewFactory.java
+++ b/core/java/android/webkit/WebViewFactory.java
@@ -96,49 +96,27 @@ public final class WebViewFactory {
public MissingWebViewPackageException(Exception e) { super(e); }
}
- /** @hide */
- public static String[] getWebViewPackageNames() {
- return AppGlobals.getInitialApplication().getResources().getStringArray(
- com.android.internal.R.array.config_webViewPackageNames);
- }
-
- // TODO (gsennton) remove when committing webview xts test change
public static String getWebViewPackageName() {
- String[] webViewPackageNames = getWebViewPackageNames();
- return webViewPackageNames[webViewPackageNames.length-1];
+ return AppGlobals.getInitialApplication().getString(
+ com.android.internal.R.string.config_webViewPackageName);
}
- /**
- * Return the package info of the first package in the webview priority list that contains
- * webview.
- *
- * @hide
- */
- public static PackageInfo findPreferredWebViewPackage() {
+ private static PackageInfo fetchPackageInfo() {
PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
-
- for (String packageName : getWebViewPackageNames()) {
- try {
- PackageInfo packageInfo = pm.getPackageInfo(packageName,
- PackageManager.GET_META_DATA);
- ApplicationInfo applicationInfo = packageInfo.applicationInfo;
-
- // If the correct flag is set the package contains webview.
- if (getWebViewLibrary(applicationInfo) != null) {
- return packageInfo;
- }
- } catch (PackageManager.NameNotFoundException e) {
- }
+ try {
+ return pm.getPackageInfo(getWebViewPackageName(), PackageManager.GET_META_DATA);
+ } catch (PackageManager.NameNotFoundException e) {
+ throw new MissingWebViewPackageException(e);
}
- throw new MissingWebViewPackageException("Could not find a loadable WebView package");
}
// throws MissingWebViewPackageException
private static ApplicationInfo getWebViewApplicationInfo() {
- if (sPackageInfo == null)
- return findPreferredWebViewPackage().applicationInfo;
- else
+ if (sPackageInfo == null) {
+ return fetchPackageInfo().applicationInfo;
+ } else {
return sPackageInfo.applicationInfo;
+ }
}
private static String getWebViewLibrary(ApplicationInfo ai) {
@@ -153,10 +131,10 @@ public final class WebViewFactory {
/**
* Load the native library for the given package name iff that package
- * name is the same as the one providing the current webview.
+ * name is the same as the one providing the webview.
*/
public static int loadWebViewNativeLibraryFromPackage(String packageName) {
- sPackageInfo = findPreferredWebViewPackage();
+ sPackageInfo = fetchPackageInfo();
if (packageName != null && packageName.equals(sPackageInfo.packageName)) {
return loadNativeLibrary();
}
@@ -202,7 +180,7 @@ public final class WebViewFactory {
private static Class<WebViewFactoryProvider> getProviderClass() {
try {
// First fetch the package info so we can log the webview package version.
- sPackageInfo = findPreferredWebViewPackage();
+ sPackageInfo = fetchPackageInfo();
Log.i(LOGTAG, "Loading " + sPackageInfo.packageName + " version " +
sPackageInfo.versionName + " (code " + sPackageInfo.versionCode + ")");
@@ -241,8 +219,8 @@ public final class WebViewFactory {
try {
// Construct a package context to load the Java code into the current app.
Context webViewContext = initialApplication.createPackageContext(
- sPackageInfo.packageName,
- Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
+ sPackageInfo.packageName,
+ Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
initialApplication.getAssets().addAssetPath(
webViewContext.getApplicationInfo().sourceDir);
ClassLoader clazzLoader = webViewContext.getClassLoader();