From a172e7d0d96e4a4db5e2b408e8ee3e96948df9a4 Mon Sep 17 00:00:00 2001 From: Michael Kolb Date: Wed, 30 Jun 2010 12:35:26 -0700 Subject: [PATCH] user agent string change: remove "Mobile" for large screen configuration bug: http://b/issue?id=2778676 Change-Id: I268d8c0f8834bdbd099d59fdbc462da26234241a --- core/java/android/webkit/WebSettings.java | 32 ++++++++++++++--------- core/res/res/values/strings.xml | 4 +-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java index d241bd8203aef..52e992b2bd8e9 100644 --- a/core/java/android/webkit/WebSettings.java +++ b/core/java/android/webkit/WebSettings.java @@ -19,6 +19,7 @@ package android.webkit; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.content.res.Configuration; import android.os.Build; import android.os.Handler; import android.os.Message; @@ -107,7 +108,7 @@ public class WebSettings { * Use with {@link #setCacheMode}. */ public static final int LOAD_NO_CACHE = 2; - + /** * Don't use the network, load from cache only. * Use with {@link #setCacheMode}. @@ -432,11 +433,14 @@ public class WebSettings { buffer.append(" Build/"); buffer.append(id); } + String mobile = ((mContext.getResources().getConfiguration().screenLayout + & Configuration.SCREENLAYOUT_SIZE_MASK) + == Configuration.SCREENLAYOUT_SIZE_XLARGE) ? "" : "Mobile "; final String base = mContext.getResources().getText( com.android.internal.R.string.web_user_agent).toString(); - return String.format(base, buffer); + return String.format(base, buffer, mobile); } - + /** * Enables dumping the pages navigation cache to a text file. */ @@ -488,14 +492,14 @@ public class WebSettings { mBuiltInZoomControls = enabled; mWebView.updateMultiTouchSupport(mContext); } - + /** * Returns true if the zoom mechanism built into WebView is being used. */ public boolean getBuiltInZoomControls() { return mBuiltInZoomControls; } - + /** * Enable or disable file access within WebView. File access is enabled by * default. @@ -1044,8 +1048,8 @@ public class WebSettings { private void verifyNetworkAccess() { if (!mBlockNetworkLoads) { - if (mContext.checkPermission("android.permission.INTERNET", - android.os.Process.myPid(), android.os.Process.myUid()) != + if (mContext.checkPermission("android.permission.INTERNET", + android.os.Process.myPid(), android.os.Process.myUid()) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException ("Permission denied - " + @@ -1071,6 +1075,7 @@ public class WebSettings { * @deprecated This method has been deprecated in favor of * {@link #setPluginState} */ + @Deprecated public synchronized void setPluginsEnabled(boolean flag) { setPluginState(PluginState.ON); } @@ -1260,6 +1265,7 @@ public class WebSettings { * @return True if plugins are enabled. * @deprecated This method has been replaced by {@link #getPluginState} */ + @Deprecated public synchronized boolean getPluginsEnabled() { return mPluginState == PluginState.ON; } @@ -1328,7 +1334,7 @@ public class WebSettings { public synchronized void setUserAgentString(String ua) { if (ua == null || ua.length() == 0) { synchronized(sLockForLocaleSettings) { - Locale currentLocale = Locale.getDefault(); + Locale currentLocale = Locale.getDefault(); if (!sLocale.equals(currentLocale)) { sLocale = currentLocale; mAcceptLanguage = getCurrentAcceptLanguage(); @@ -1383,11 +1389,11 @@ public class WebSettings { } return mAcceptLanguage; } - + /** * Tell the WebView whether it needs to set a node to have focus when * {@link WebView#requestFocus(int, android.graphics.Rect)} is called. - * + * * @param flag */ public void setNeedInitialFocus(boolean flag) { @@ -1414,7 +1420,7 @@ public class WebSettings { EventHandler.PRIORITY)); } } - + /** * Override the way the cache is used. The way the cache is used is based * on the navigation option. For a normal page load, the cache is checked @@ -1428,7 +1434,7 @@ public class WebSettings { mOverrideCacheMode = mode; } } - + /** * Return the current setting for overriding the cache mode. For a full * description, see the {@link #setCacheMode(int)} function. @@ -1436,7 +1442,7 @@ public class WebSettings { public int getCacheMode() { return mOverrideCacheMode; } - + /** * If set, webkit alternately shrinks and expands images viewed outside * of an HTML page to fit the screen. This conflicts with attempts by diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index de1ea68a71e59..fb82b937519e8 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1604,8 +1604,8 @@ Reboot - Mozilla/5.0 (Linux; U; Android %s) - AppleWebKit/534.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.1 + Mozilla/5.0 (Linux; U; Android %s) + AppleWebKit/534.1 (KHTML, like Gecko) Version/4.0 %sSafari/534.1 The page at \'%s\' says: