mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
Fix default bridge mode being PRIVATE_API (should be ONLINE_EVENTS).
This was broken when HANGING_GET mode was removed.
This commit is contained in:
parent
467cbe972c
commit
6f873ff6b5
@ -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
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
@ -922,19 +922,20 @@ var cordova = require('cordova'),
|
|||||||
POLLING: 0,
|
POLLING: 0,
|
||||||
// For LOAD_URL to be viable, it would need to have a work-around for
|
// 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.
|
// 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
|
// For the ONLINE_EVENT to be viable, it would need to intercept all event
|
||||||
// listeners (both through addEventListener and window.ononline) as well
|
// listeners (both through addEventListener and window.ononline) as well
|
||||||
// as set the navigator property itself.
|
// 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
|
// Uses reflection to access private APIs of the WebView that can send JS
|
||||||
// to be executed.
|
// to be executed.
|
||||||
// Requires Android 3.2.4 or above.
|
// Requires Android 3.2.4 or above.
|
||||||
PRIVATE_API: 4
|
PRIVATE_API: 3
|
||||||
},
|
},
|
||||||
jsToNativeBridgeMode, // Set lazily.
|
jsToNativeBridgeMode, // Set lazily.
|
||||||
nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT
|
nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
|
||||||
pollEnabled = false;
|
pollEnabled = false,
|
||||||
|
messagesFromNative = [];
|
||||||
|
|
||||||
function androidExec(success, fail, service, action, args) {
|
function androidExec(success, fail, service, action, args) {
|
||||||
// Set default bridge modes if they have not already been set.
|
// 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.
|
// This is called from the NativeToJsMessageQueue.java.
|
||||||
androidExec.processMessages = function(messages) {
|
androidExec.processMessages = function(messages) {
|
||||||
while (messages) {
|
messagesFromNative.push(messages);
|
||||||
if (messages == '*') {
|
// Check for the reentrant case, and enqueue the message if that's the case.
|
||||||
window.setTimeout(pollOnce, 0);
|
if (messagesFromNative.length > 1) {
|
||||||
break;
|
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(' ');
|
messagesFromNative.shift();
|
||||||
var msgLen = +messages.slice(0, spaceIdx);
|
|
||||||
var message = messages.substr(spaceIdx + 1, msgLen);
|
|
||||||
messages = messages.slice(spaceIdx + msgLen + 1);
|
|
||||||
processMessage(message);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class NativeToJsMessageQueue {
|
|||||||
private static final String LOG_TAG = "JsMessageQueue";
|
private static final String LOG_TAG = "JsMessageQueue";
|
||||||
|
|
||||||
// This must match the default value in incubator-cordova-js/lib/android/exec.js
|
// 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
|
// Set this to true to force plugin results to be encoding as
|
||||||
// JS instead of the custom format (useful for benchmarking).
|
// JS instead of the custom format (useful for benchmarking).
|
||||||
@ -367,10 +367,16 @@ public class NativeToJsMessageQueue {
|
|||||||
final String jsPayloadOrCallbackId;
|
final String jsPayloadOrCallbackId;
|
||||||
final PluginResult pluginResult;
|
final PluginResult pluginResult;
|
||||||
JsMessage(String js) {
|
JsMessage(String js) {
|
||||||
|
if (js == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
jsPayloadOrCallbackId = js;
|
jsPayloadOrCallbackId = js;
|
||||||
pluginResult = null;
|
pluginResult = null;
|
||||||
}
|
}
|
||||||
JsMessage(PluginResult pluginResult, String callbackId) {
|
JsMessage(PluginResult pluginResult, String callbackId) {
|
||||||
|
if (callbackId == null || pluginResult == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
jsPayloadOrCallbackId = callbackId;
|
jsPayloadOrCallbackId = callbackId;
|
||||||
this.pluginResult = pluginResult;
|
this.pluginResult = pluginResult;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user