cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [1/2] android commit: Fix default bridge mode being PRIVATE_API (should be ONLINE_EVENTS).
Date Tue, 02 Oct 2012 14:02:54 GMT
Updated Branches:
  refs/heads/master 467cbe972 -> 5289d569b


Fix default bridge mode being PRIVATE_API (should be ONLINE_EVENTS).

This was broken when HANGING_GET mode was removed.


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

Branch: refs/heads/master
Commit: 6f873ff6b53a3b85d81183c5e1c9e8c82803242c
Parents: 467cbe9
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue Oct 2 09:40:16 2012 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Oct 2 10:02:42 2012 -0400

----------------------------------------------------------------------
 framework/assets/js/cordova.android.js             |   42 +++++++++------
 .../org/apache/cordova/NativeToJsMessageQueue.java |    8 +++-
 2 files changed, 33 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/6f873ff6/framework/assets/js/cordova.android.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/cordova.android.js b/framework/assets/js/cordova.android.js
index e2e5bfd..213bd7d 100644
--- a/framework/assets/js/cordova.android.js
+++ b/framework/assets/js/cordova.android.js
@@ -1,6 +1,6 @@
-// commit 968764b2f67ff2ed755eace083b83f395cf0e9c2
+// commit e799aef6a4e24e95b341798e19ffeb39b43ce2c1
 
-// File generated at :: Fri Sep 28 2012 14:33:38 GMT-0400 (EDT)
+// File generated at :: Tue Oct 02 2012 09:37:50 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -922,19 +922,20 @@ var cordova = require('cordova'),
         POLLING: 0,
         // For LOAD_URL to be viable, it would need to have a work-around for
         // the bug where the soft-keyboard gets dismissed when a message is sent.
-        LOAD_URL: 2,
+        LOAD_URL: 1,
         // For the ONLINE_EVENT to be viable, it would need to intercept all event
         // listeners (both through addEventListener and window.ononline) as well
         // as set the navigator property itself.
-        ONLINE_EVENT: 3,
+        ONLINE_EVENT: 2,
         // Uses reflection to access private APIs of the WebView that can send JS
         // to be executed.
         // Requires Android 3.2.4 or above.
-        PRIVATE_API: 4
+        PRIVATE_API: 3
     },
     jsToNativeBridgeMode,  // Set lazily.
-    nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT
-    pollEnabled = false;
+    nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
+    pollEnabled = false,
+    messagesFromNative = [];
 
 function androidExec(success, fail, service, action, args) {
     // Set default bridge modes if they have not already been set.
@@ -1060,16 +1061,25 @@ function processMessage(message) {
 
 // This is called from the NativeToJsMessageQueue.java.
 androidExec.processMessages = function(messages) {
-    while (messages) {
-        if (messages == '*') {
-            window.setTimeout(pollOnce, 0);
-            break;
+    messagesFromNative.push(messages);
+    // Check for the reentrant case, and enqueue the message if that's the case.
+    if (messagesFromNative.length > 1) {
+        return;
+    }
+    while (messagesFromNative.length) {
+        messages = messagesFromNative[0];
+        while (messages) {
+            if (messages == '*') {
+                window.setTimeout(pollOnce, 0);
+                break;
+            }
+            var spaceIdx = messages.indexOf(' ');
+            var msgLen = +messages.slice(0, spaceIdx);
+            var message = messages.substr(spaceIdx + 1, msgLen);
+            messages = messages.slice(spaceIdx + msgLen + 1);
+            processMessage(message);
         }
-        var spaceIdx = messages.indexOf(' ');
-        var msgLen = +messages.slice(0, spaceIdx);
-        var message = messages.substr(spaceIdx + 1, msgLen);
-        messages = messages.slice(spaceIdx + msgLen + 1);
-        processMessage(message);
+        messagesFromNative.shift();
     }
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/6f873ff6/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
index e129199..934088a 100755
--- a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
+++ b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
@@ -36,7 +36,7 @@ public class NativeToJsMessageQueue {
     private static final String LOG_TAG = "JsMessageQueue";
 
     // This must match the default value in incubator-cordova-js/lib/android/exec.js
-    private static final int DEFAULT_BRIDGE_MODE = 3;
+    private static final int DEFAULT_BRIDGE_MODE = 2;
     
     // Set this to true to force plugin results to be encoding as
     // JS instead of the custom format (useful for benchmarking).
@@ -367,10 +367,16 @@ public class NativeToJsMessageQueue {
         final String jsPayloadOrCallbackId;
         final PluginResult pluginResult;
         JsMessage(String js) {
+            if (js == null) {
+                throw new NullPointerException();
+            }
             jsPayloadOrCallbackId = js;
             pluginResult = null;
         }
         JsMessage(PluginResult pluginResult, String callbackId) {
+            if (callbackId == null || pluginResult == null) {
+                throw new NullPointerException();
+            }
             jsPayloadOrCallbackId = callbackId;
             this.pluginResult = pluginResult;
         }


Mime
View raw message