You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2016/09/09 19:05:25 UTC

[1/2] android commit: CB-11828: Adding dirty userAgent checking to see if we're running Jellybean or not for bridge modes

Repository: cordova-android
Updated Branches:
  refs/heads/master 3a33f4c0a -> dc0bfeb0c


CB-11828: Adding dirty userAgent checking to see if we're running Jellybean or not for bridge modes


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/dc0bfeb0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/dc0bfeb0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/dc0bfeb0

Branch: refs/heads/master
Commit: dc0bfeb0cc8228f755da8c60c80241fce745b7e5
Parents: deea0f7
Author: Joe Bowser <bo...@apache.org>
Authored: Fri Sep 9 10:01:04 2016 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Fri Sep 9 12:05:19 2016 -0700

----------------------------------------------------------------------
 bin/templates/project/assets/www/cordova.js | 20 +++++++++++++++-----
 cordova-js-src/exec.js                      | 14 ++++++++++++--
 2 files changed, 27 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dc0bfeb0/bin/templates/project/assets/www/cordova.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/assets/www/cordova.js b/bin/templates/project/assets/www/cordova.js
index 700c667..1f06fae 100644
--- a/bin/templates/project/assets/www/cordova.js
+++ b/bin/templates/project/assets/www/cordova.js
@@ -1,5 +1,5 @@
 // Platform: android
-// d403ce434788ffe1937711d6ebcbcc837fcbcb14
+// 2fd4bcb84048415922d13d80d35b8d1668e8e150
 /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
@@ -901,7 +901,7 @@ var cordova = require('cordova'),
         EVAL_BRIDGE: 3
     },
     jsToNativeBridgeMode,  // Set lazily.
-    nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
+    nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE,
     pollEnabled = false,
     bridgeSecret = -1;
 
@@ -933,7 +933,6 @@ function androidExec(success, fail, service, action, args) {
 
     var callbackId = service + cordova.callbackId++,
         argsJson = JSON.stringify(args);
-
     if (success || fail) {
         cordova.callbacks[callbackId] = {success:success, fail:fail};
     }
@@ -953,6 +952,17 @@ function androidExec(success, fail, service, action, args) {
 }
 
 androidExec.init = function() {
+    //CB-11828
+    //This failsafe checks the version of Android and if it's Jellybean, it switches it to
+    //using the Online Event bridge for communicating from Native to JS
+    //
+    //It's ugly, but it's necessary.
+    var check = navigator.userAgent.toLowerCase().match(/android\s[0-9].[0-9]/);
+    var version_code = check[0].match(/4.[0-3].*/);
+    if (version_code != null && nativeToJsBridgeMode == nativeToJsModes.EVAL_BRIDGE) {
+      nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT;
+    }
+
     bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
     channel.onNativeReady.fire();
 };
@@ -2084,7 +2094,7 @@ utils.clone = function(obj) {
 
     retVal = {};
     for(i in obj){
-        if((!(i in retVal) || retVal[i] != obj[i]) && typeof obj[i] != 'undefined') {
+        if(!(i in retVal) || retVal[i] != obj[i]) {
             retVal[i] = utils.clone(obj[i]);
         }
     }
@@ -2165,4 +2175,4 @@ window.cordova = require('cordova');
 
 require('cordova/init');
 
-})();
+})();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dc0bfeb0/cordova-js-src/exec.js
----------------------------------------------------------------------
diff --git a/cordova-js-src/exec.js b/cordova-js-src/exec.js
index 197fb5d..36298ce 100644
--- a/cordova-js-src/exec.js
+++ b/cordova-js-src/exec.js
@@ -55,7 +55,7 @@ var cordova = require('cordova'),
         EVAL_BRIDGE: 3
     },
     jsToNativeBridgeMode,  // Set lazily.
-    nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
+    nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE,
     pollEnabled = false,
     bridgeSecret = -1;
 
@@ -87,7 +87,6 @@ function androidExec(success, fail, service, action, args) {
 
     var callbackId = service + cordova.callbackId++,
         argsJson = JSON.stringify(args);
-
     if (success || fail) {
         cordova.callbacks[callbackId] = {success:success, fail:fail};
     }
@@ -107,6 +106,17 @@ function androidExec(success, fail, service, action, args) {
 }
 
 androidExec.init = function() {
+    //CB-11828
+    //This failsafe checks the version of Android and if it's Jellybean, it switches it to
+    //using the Online Event bridge for communicating from Native to JS
+    //
+    //It's ugly, but it's necessary.
+    var check = navigator.userAgent.toLowerCase().match(/android\s[0-9].[0-9]/);
+    var version_code = check[0].match(/4.[0-3].*/);
+    if (version_code != null && nativeToJsBridgeMode == nativeToJsModes.EVAL_BRIDGE) {
+      nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT;
+    }
+
     bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
     channel.onNativeReady.fire();
 };


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[2/2] android commit: CB-11828: Switching default bridge back to ONLINE_BRIDGE

Posted by bo...@apache.org.
CB-11828: Switching default bridge back to ONLINE_BRIDGE


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/deea0f7e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/deea0f7e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/deea0f7e

Branch: refs/heads/master
Commit: deea0f7e4f0d7baeabab14e0b057d24b97bbf893
Parents: 3a33f4c
Author: Joe Bowser <bo...@apache.org>
Authored: Thu Sep 8 15:29:00 2016 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Fri Sep 9 12:05:19 2016 -0700

----------------------------------------------------------------------
 bin/templates/project/assets/www/cordova.js              |  2 +-
 cordova-js-src/exec.js                                   |  2 +-
 .../org/apache/cordova/engine/SystemWebViewEngine.java   | 11 +++++++++--
 3 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/deea0f7e/bin/templates/project/assets/www/cordova.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/assets/www/cordova.js b/bin/templates/project/assets/www/cordova.js
index a7a9c0a..700c667 100644
--- a/bin/templates/project/assets/www/cordova.js
+++ b/bin/templates/project/assets/www/cordova.js
@@ -901,7 +901,7 @@ var cordova = require('cordova'),
         EVAL_BRIDGE: 3
     },
     jsToNativeBridgeMode,  // Set lazily.
-    nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE,
+    nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
     pollEnabled = false,
     bridgeSecret = -1;
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/deea0f7e/cordova-js-src/exec.js
----------------------------------------------------------------------
diff --git a/cordova-js-src/exec.js b/cordova-js-src/exec.js
index eab81c0..197fb5d 100644
--- a/cordova-js-src/exec.js
+++ b/cordova-js-src/exec.js
@@ -55,7 +55,7 @@ var cordova = require('cordova'),
         EVAL_BRIDGE: 3
     },
     jsToNativeBridgeMode,  // Set lazily.
-    nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE,
+    nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
     pollEnabled = false,
     bridgeSecret = -1;
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/deea0f7e/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java b/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java
index c0ea94a..84cb05a 100755
--- a/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java
+++ b/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java
@@ -117,7 +117,8 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
                 SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r);
             }
         }));
-        nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova));
+        if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2)
+            nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova));
 	bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue);
         exposeJsInterface(webView, bridge);
     }
@@ -336,6 +337,12 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
 
     @Override
     public void evaluateJavascript(String js, ValueCallback<String> callback) {
-        webView.evaluateJavascript(js, callback);
+        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+            webView.evaluateJavascript(js, callback);
+        }
+        else
+        {
+            LOG.d(TAG, "This webview is using the old bridge");
+        }
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org