From aa2d17e4895fc3c20e00c1c9cce5592376c64121 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Thu, 25 Oct 2012 15:00:21 -0400 Subject: [PATCH] Disable JS_OBJECT bridge on pre-gingerbread devices. It's the easiest way to avoid bugs with Java strings not being converted to JS Strings. --- framework/src/org/apache/cordova/CordovaWebView.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 3f64d536..6ca9df64 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -272,8 +272,14 @@ public class CordovaWebView extends WebView { } private void exposeJsInterface() { - // addJavascriptInterface crashes on the 2.3 emulator. - if (Build.VERSION.RELEASE.startsWith("2.3") && Build.MANUFACTURER.equals("unknown")) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { + Log.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old."); + // Bug being that Java Strings do not get converted to JS strings automatically. + // This isn't hard to work-around on the JS side, but it's easier to just + // use the prompt bridge instead. + return; + } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && Build.MANUFACTURER.equals("unknown")) { + // addJavascriptInterface crashes on the 2.3 emulator. Log.i(TAG, "Disabled addJavascriptInterface() bridge callback due to a bug on the 2.3 emulator"); return; }