diff options
| author | Gustav Sennton <gsennton@google.com> | 2016-02-24 19:00:35 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-02-24 19:00:36 +0000 |
| commit | 074d630f9e7a4dfd8acf3fa4fa1dfcb500184156 (patch) | |
| tree | 62c1e5383defc504c139ba1887abb00f94843084 /core/java/android | |
| parent | c87e2b46fb949f1ba5d72b842bad443b36fd9abc (diff) | |
| parent | c83e3fa35a5736a1778d241abd18dffa5953f416 (diff) | |
Merge "Add fallback packages to be enabled iff no webview packages are valid" into nyc-dev
Diffstat (limited to 'core/java/android')
| -rwxr-xr-x | core/java/android/provider/Settings.java | 8 | ||||
| -rw-r--r-- | core/java/android/webkit/IWebViewUpdateService.aidl | 21 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewFactory.java | 35 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewProviderInfo.java | 12 |
4 files changed, 64 insertions, 12 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 921e18f18dff..f524be37bff5 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -7048,6 +7048,14 @@ public final class Settings { "webview_data_reduction_proxy_key"; /** + * Whether or not the WebView fallback mechanism should be enabled. + * 0=disabled, 1=enabled. + * @hide + */ + public static final String WEBVIEW_FALLBACK_LOGIC_ENABLED = + "webview_fallback_logic_enabled"; + + /** * Name of the package used as WebView provider (if unset the provider is instead determined * by the system). * @hide diff --git a/core/java/android/webkit/IWebViewUpdateService.aidl b/core/java/android/webkit/IWebViewUpdateService.aidl index 89d5d69de392..5697dfc0188c 100644 --- a/core/java/android/webkit/IWebViewUpdateService.aidl +++ b/core/java/android/webkit/IWebViewUpdateService.aidl @@ -38,10 +38,14 @@ interface IWebViewUpdateService { WebViewProviderResponse waitForAndGetProvider(); /** - * DevelopmentSettings uses this to notify WebViewUpdateService that a - * new provider has been selected by the user. + * DevelopmentSettings uses this to notify WebViewUpdateService that a new provider has been + * selected by the user. Returns the provider we end up switching to, this could be different to + * the one passed as argument to this method since the Dev Setting calling this method could be + * stale. I.e. the Dev setting could be letting the user choose uninstalled/disabled packages, + * it would then try to update the provider to such a package while in reality the update + * service would switch to another one. */ - void changeProviderAndSetting(String newProvider); + String changeProviderAndSetting(String newProvider); /** * DevelopmentSettings uses this to get the current available WebView @@ -53,4 +57,15 @@ interface IWebViewUpdateService { * Used by DevelopmentSetting to get the name of the WebView provider currently in use. */ String getCurrentWebViewPackageName(); + + /** + * Used by Settings to determine whether a certain package can be enabled/disabled by the user - + * the package should not be modifiable in this way if it is a fallback package. + */ + boolean isFallbackPackage(String packageName); + + /** + * Enable or disable the WebView package fallback mechanism. + */ + void enableFallbackLogic(boolean enable); } diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java index b04b4c0e3b11..ad50ff60780e 100644 --- a/core/java/android/webkit/WebViewFactory.java +++ b/core/java/android/webkit/WebViewFactory.java @@ -21,6 +21,7 @@ import android.app.ActivityManagerInternal; import android.app.AppGlobals; import android.app.Application; import android.content.Context; +import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -134,6 +135,7 @@ public final class WebViewFactory { // Whether or not the provider must be explicitly chosen by the user to be used. private static String TAG_AVAILABILITY = "availableByDefault"; private static String TAG_SIGNATURE = "signature"; + private static String TAG_FALLBACK = "isFallback"; /** * Reads all signatures at the current depth (within the current provider) from the XML parser. @@ -159,6 +161,7 @@ public final class WebViewFactory { * @hide * */ public static WebViewProviderInfo[] getWebViewPackages() { + int numFallbackPackages = 0; XmlResourceParser parser = null; List<WebViewProviderInfo> webViewProviders = new ArrayList<WebViewProviderInfo>(); try { @@ -182,13 +185,21 @@ public final class WebViewFactory { throw new MissingWebViewPackageException( "WebView provider in framework resources missing description"); } - String availableByDefault = parser.getAttributeValue(null, TAG_AVAILABILITY); - if (availableByDefault == null) { - availableByDefault = "false"; - } - webViewProviders.add( + boolean availableByDefault = "true".equals( + parser.getAttributeValue(null, TAG_AVAILABILITY)); + boolean isFallback = "true".equals( + parser.getAttributeValue(null, TAG_FALLBACK)); + WebViewProviderInfo currentProvider = new WebViewProviderInfo(packageName, description, availableByDefault, - readSignatures(parser))); + isFallback, readSignatures(parser)); + if (currentProvider.isFallbackPackage()) { + numFallbackPackages++; + if (numFallbackPackages > 1) { + throw new AndroidRuntimeException( + "There can be at most one webview fallback package."); + } + } + webViewProviders.add(currentProvider); } else { Log.e(LOGTAG, "Found an element that is not a webview provider"); @@ -641,6 +652,18 @@ public final class WebViewFactory { return result; } + /** + * Returns whether the entire package from an ACTION_PACKAGE_CHANGED intent was changed (rather + * than just one of its components). + * @hide + */ + public static boolean entirePackageChanged(Intent intent) { + String[] componentList = + intent.getStringArrayExtra(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST); + return Arrays.asList(componentList).contains( + intent.getDataString().substring("package:".length())); + } + private static IWebViewUpdateService getUpdateService() { return IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate")); } diff --git a/core/java/android/webkit/WebViewProviderInfo.java b/core/java/android/webkit/WebViewProviderInfo.java index 94e8b70ce38c..64c2caa58fd5 100644 --- a/core/java/android/webkit/WebViewProviderInfo.java +++ b/core/java/android/webkit/WebViewProviderInfo.java @@ -40,11 +40,12 @@ public class WebViewProviderInfo implements Parcelable { public WebViewPackageNotFoundException(Exception e) { super(e); } } - public WebViewProviderInfo(String packageName, String description, String availableByDefault, - String[] signatures) { + public WebViewProviderInfo(String packageName, String description, boolean availableByDefault, + boolean isFallback, String[] signatures) { this.packageName = packageName; this.description = description; - this.availableByDefault = availableByDefault.equals("true"); + this.availableByDefault = availableByDefault; + this.isFallback = isFallback; this.signatures = signatures; } @@ -114,6 +115,10 @@ public class WebViewProviderInfo implements Parcelable { return availableByDefault; } + public boolean isFallbackPackage() { + return isFallback; + } + private void updatePackageInfo() { try { PackageManager pm = AppGlobals.getInitialApplication().getPackageManager(); @@ -165,6 +170,7 @@ public class WebViewProviderInfo implements Parcelable { public String packageName; public String description; private boolean availableByDefault; + private boolean isFallback; private String[] signatures; |
