summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-21 21:22:07 +0000
committerjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-21 21:22:07 +0000
commitb24fe8a4c38700788978affe1f68b3c47d707aa5 (patch)
treec93bf57374e223cf58b7094cb871e513786de99d
parent35dd15b237819aaf8b959561ba4324526620a8fe (diff)
downloadchromium_src-b24fe8a4c38700788978affe1f68b3c47d707aa5.zip
chromium_src-b24fe8a4c38700788978affe1f68b3c47d707aa5.tar.gz
chromium_src-b24fe8a4c38700788978affe1f68b3c47d707aa5.tar.bz2
Merge 264878 "[Android] Catch NotFoundExceptions when querying g..."
> [Android] Catch NotFoundExceptions when querying gesture constants > > Certain Sony/Japanese devices are throwing Resources.NotFoundExceptions when > looking up scale-related gesture constants. It's not yet clear why the lookup > is failing, but in any case such lookup failure should not crash the app. Use > a constant fallback in these cases, scaled to the current display configuration. > > BUG=363484 > > Review URL: https://codereview.chromium.org/243503003 TBR=jdduke@chromium.org Review URL: https://codereview.chromium.org/245843002 git-svn-id: svn://svn.chromium.org/chrome/branches/1916/src@265075 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java b/ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java
index ae007b4..e8fc5b9 100644
--- a/ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java
+++ b/ui/android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java
@@ -8,6 +8,7 @@ import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.util.TypedValue;
import android.view.ViewConfiguration;
import org.chromium.base.CalledByNative;
@@ -21,6 +22,12 @@ import org.chromium.ui.R;
*/
@JNINamespace("gfx")
public class ViewConfigurationHelper {
+
+ // Fallback constants when resource lookup fails, see
+ // ui/android/java/res/values/dimens.xml.
+ private static final float MIN_SCALING_SPAN_MM = 27.0f;
+ private static final float MIN_SCALING_TOUCH_MAJOR_DIP = 48.0f;
+
private final Context mAppContext;
private ViewConfiguration mViewConfiguration;
@@ -104,8 +111,13 @@ public class ViewConfigurationHelper {
int id = res.getIdentifier("config_minScalingSpan", "dimen", "android");
// Fall back to a sensible default if the internal identifier does not exist.
if (id == 0) id = R.dimen.config_min_scaling_span;
- return res.getDimensionPixelSize(id);
-
+ try {
+ return res.getDimensionPixelSize(id);
+ } catch (Resources.NotFoundException e) {
+ assert false : "MinScalingSpan resource lookup failed.";
+ return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, MIN_SCALING_SPAN_MM,
+ res.getDisplayMetrics());
+ }
}
@CalledByNative
@@ -114,7 +126,13 @@ public class ViewConfigurationHelper {
int id = res.getIdentifier("config_minScalingTouchMajor", "dimen", "android");
// Fall back to a sensible default if the internal identifier does not exist.
if (id == 0) id = R.dimen.config_min_scaling_touch_major;
- return res.getDimensionPixelSize(id);
+ try {
+ return res.getDimensionPixelSize(id);
+ } catch (Resources.NotFoundException e) {
+ assert false : "MinScalingTouchMajor resource lookup failed.";
+ return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
+ MIN_SCALING_TOUCH_MAJOR_DIP, res.getDisplayMetrics());
+ }
}
@CalledByNative