diff options
| author | Jonathan Dixon <joth@google.com> | 2013-09-15 20:34:31 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2013-09-15 20:34:31 -0700 |
| commit | a25f350add985422e04c38e74d00ff91f5f555de (patch) | |
| tree | 782defba9e1c2c166f8556a6f4d8680076f09d9c | |
| parent | 1dd56b656b86667a294c0d6c51fd39acf236d036 (diff) | |
| parent | 7c0e2122c0e9bcb83c082156d5f5300b7f62169b (diff) | |
| download | frameworks_base-a25f350add985422e04c38e74d00ff91f5f555de.zip frameworks_base-a25f350add985422e04c38e74d00ff91f5f555de.tar.gz frameworks_base-a25f350add985422e04c38e74d00ff91f5f555de.tar.bz2 | |
am 7c0e2122: Merge "Revert "Hide Experimental WebView from dev settings" DO NOT MERGE" into klp-dev
* commit '7c0e2122c0e9bcb83c082156d5f5300b7f62169b':
Revert "Hide Experimental WebView from dev settings" DO NOT MERGE
| -rw-r--r-- | core/java/android/webkit/WebViewFactory.java | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java index 16daba0..0fd4e33 100644 --- a/core/java/android/webkit/WebViewFactory.java +++ b/core/java/android/webkit/WebViewFactory.java @@ -28,6 +28,19 @@ import android.util.Log; * @hide */ public final class WebViewFactory { + private static final boolean DEFAULT_TO_EXPERIMENTAL_WEBVIEW = true; + // REMEMBER: property names must be <= 31 chars total. + private static final String EXPERIMENTAL_PROPERTY_DEFAULT_OFF = "persist.sys.webview.exp"; + private static final String EXPERIMENTAL_PROPERTY_DEFAULT_ON = + "persist.sys.webview." + Build.ID; + + // Modify the persisted property name when the new webview is on-by-default, so that any user + // setting override only lives as long as that build. + private static final String LONG_PROPERTY_NAME = DEFAULT_TO_EXPERIMENTAL_WEBVIEW ? + EXPERIMENTAL_PROPERTY_DEFAULT_ON : EXPERIMENTAL_PROPERTY_DEFAULT_OFF; + private static final String WEBVIEW_EXPERIMENTAL_PROPERTY = + LONG_PROPERTY_NAME.length() > SystemProperties.PROP_NAME_MAX ? + LONG_PROPERTY_NAME.substring(0, SystemProperties.PROP_NAME_MAX) : LONG_PROPERTY_NAME; private static final String FORCE_PROVIDER_PROPERTY = "webview.force_provider"; private static final String FORCE_PROVIDER_PROPERTY_VALUE_CHROMIUM = "chromium"; @@ -60,25 +73,32 @@ public final class WebViewFactory { private static final Object sProviderLock = new Object(); public static boolean isExperimentalWebViewAvailable() { - // TODO: Remove callers of this method then remove it. - return false; // Hide the toggle in Developer Settings. + try { + // Pass false so we don't initialize the class at this point, as this will be wasted if + // it's not enabled. + Class.forName(CHROMIUM_WEBVIEW_FACTORY, false, WebViewFactory.class.getClassLoader()); + return true; + } catch (ClassNotFoundException e) { + return false; + } } /** @hide */ public static void setUseExperimentalWebView(boolean enable) { - // TODO: Remove callers of this method then remove it. + SystemProperties.set(WEBVIEW_EXPERIMENTAL_PROPERTY, enable ? "true" : "false"); + Log.i(LOGTAG, "Use Experimental WebView changed: " + + SystemProperties.get(WebViewFactory.WEBVIEW_EXPERIMENTAL_PROPERTY, "")); } /** @hide */ public static boolean useExperimentalWebView() { - // TODO: Remove callers of this method then remove it. - return isChromiumWebViewEnabled(); + return SystemProperties.getBoolean(WEBVIEW_EXPERIMENTAL_PROPERTY, + DEFAULT_TO_EXPERIMENTAL_WEBVIEW); } /** @hide */ public static boolean isUseExperimentalWebViewSet() { - // TODO: Remove callers of this method then remove it. - return false; // User has not modifed Developer Settings + return !SystemProperties.get(WEBVIEW_EXPERIMENTAL_PROPERTY).isEmpty(); } static WebViewFactoryProvider getProvider() { @@ -120,20 +140,21 @@ public final class WebViewFactory { // We allow a system property to specify that we should use the experimental Chromium powered // WebView. This enables us to switch between implementations at runtime. - private static boolean isChromiumWebViewEnabled() { + private static boolean isExperimentalWebViewEnabled() { + if (!isExperimentalWebViewAvailable()) return false; String forceProviderName = SystemProperties.get(FORCE_PROVIDER_PROPERTY); - if (forceProviderName.isEmpty()) return true; + if (forceProviderName.isEmpty()) return useExperimentalWebView(); Log.i(LOGTAG, String.format("Provider overridden by property: %s=%s", FORCE_PROVIDER_PROPERTY, forceProviderName)); if (forceProviderName.equals(FORCE_PROVIDER_PROPERTY_VALUE_CHROMIUM)) return true; if (forceProviderName.equals(FORCE_PROVIDER_PROPERTY_VALUE_CLASSIC)) return false; Log.e(LOGTAG, String.format("Unrecognized provider: %s", forceProviderName)); - return true; + return useExperimentalWebView(); } private static Class<WebViewFactoryProvider> getFactoryClass() throws ClassNotFoundException { - if (isChromiumWebViewEnabled()) { + if (isExperimentalWebViewEnabled()) { return (Class<WebViewFactoryProvider>) Class.forName(CHROMIUM_WEBVIEW_FACTORY); } else { return (Class<WebViewFactoryProvider>) Class.forName(DEFAULT_WEBVIEW_FACTORY); |
