Add constant to disable non-exec() messages in Native->JS bridge.

This commit is contained in:
Andrew Grieve 2012-09-11 11:26:31 -04:00
parent 365edcad16
commit 4c9a571106

View File

@ -39,6 +39,10 @@ public class NativeToJsMessageQueue {
// 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 = 1; private static final int DEFAULT_BRIDGE_MODE = 1;
// Set this to true to force plugin results to be encoding as
// JS instead of the custom format (useful for benchmarking).
private static final boolean FORCE_ENCODE_USING_EVAL = false;
/** /**
* The index into registeredListeners to treat as active. * The index into registeredListeners to treat as active.
*/ */
@ -202,7 +206,14 @@ public class NativeToJsMessageQueue {
if (noResult && keepCallback) { if (noResult && keepCallback) {
return; return;
} }
enqueueMessage(new JsMessage(result, callbackId)); JsMessage message = new JsMessage(result, callbackId);
if (FORCE_ENCODE_USING_EVAL) {
StringBuilder sb = new StringBuilder(message.calculateEncodedLength() + 50);
message.encodeAsJsMessage(sb);
message = new JsMessage(sb.toString());
}
enqueueMessage(message);
} }
private void enqueueMessage(JsMessage message) { private void enqueueMessage(JsMessage message) {