From d9730182212b157083321ea4e2209182f1fbb72f Mon Sep 17 00:00:00 2001 From: Gustav Sennton Date: Thu, 18 Jun 2015 16:56:26 +0100 Subject: Revert "Load WebView from one out of a list of packages." This was not a clean revert! This reverts commit 2ed6fee15c85ff991f64ecfa8c1c4738e0fdf9b6. We essentially only revert the functionality for going through a list of WebView package names and picking the first compatible one. Except for that functionality we also fetched the name of the shared library from a flag in WebView and made some minor refactoring in the initial commit, these changes have been left alone in this revert. Bug: 21893371 Change-Id: Idb2539dc33cc5f9e2894ecd665c23573c6cba9f3 --- core/java/android/webkit/WebViewFactory.java | 54 +++++++--------------- core/res/res/values/config.xml | 6 +-- core/res/res/values/symbols.xml | 2 +- .../server/webkit/WebViewUpdateService.java | 21 ++------- 4 files changed, 22 insertions(+), 61 deletions(-) diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java index b4ef58a..3b9aca8 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 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(); diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 7272ae3..424a0b7 100755 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2031,10 +2031,8 @@ string that's stored in 8-bit unpacked format) characters.--> false - - - com.android.webview - + + com.android.webview diff --git a/services/core/java/com/android/server/webkit/WebViewUpdateService.java b/services/core/java/com/android/server/webkit/WebViewUpdateService.java index ac79b36..d4c5f87 100644 --- a/services/core/java/com/android/server/webkit/WebViewUpdateService.java +++ b/services/core/java/com/android/server/webkit/WebViewUpdateService.java @@ -40,8 +40,6 @@ public class WebViewUpdateService extends SystemService { private boolean mRelroReady32Bit = false; private boolean mRelroReady64Bit = false; - private String oldWebViewPackageName = null; - private BroadcastReceiver mWebViewUpdatedReceiver; public WebViewUpdateService(Context context) { @@ -53,22 +51,9 @@ public class WebViewUpdateService extends SystemService { mWebViewUpdatedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - - for (String packageName : WebViewFactory.getWebViewPackageNames()) { - String webviewPackage = "package:" + packageName; - - if (webviewPackage.equals(intent.getDataString())) { - String usedPackageName = - WebViewFactory.findPreferredWebViewPackage().packageName; - // Only trigger update actions if the updated package is the one that - // will be used, or the one that was in use before the update. - if (packageName.equals(usedPackageName) || - packageName.equals(oldWebViewPackageName)) { - onWebViewUpdateInstalled(); - oldWebViewPackageName = usedPackageName; - } - return; - } + String webviewPackage = "package:" + WebViewFactory.getWebViewPackageName(); + if (webviewPackage.equals(intent.getDataString())) { + onWebViewUpdateInstalled(); } } }; -- cgit v1.1