mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
Log friendlier messages when bridge calls are recieved from previous page
This commit is contained in:
parent
4b4b71ff32
commit
fc2a202afa
@ -41,7 +41,22 @@ public class CordovaBridge {
|
||||
this.jsMessageQueue = jsMessageQueue;
|
||||
}
|
||||
|
||||
private final boolean checkBridgeEnabled(String action) {
|
||||
if (!jsMessageQueue.isBridgeEnabled()) {
|
||||
if (bridgeSecret == -1) {
|
||||
Log.d(LOG_TAG, action + " call made before bridge was enabled.");
|
||||
} else {
|
||||
Log.d(LOG_TAG, "Ignoring " + action + " from previous page load.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String jsExec(int bridgeSecret, String service, String action, String callbackId, String arguments) throws JSONException, IllegalAccessException {
|
||||
if (!checkBridgeEnabled("exec()")) {
|
||||
return "";
|
||||
}
|
||||
verifySecret(bridgeSecret);
|
||||
// If the arguments weren't received, send a message back to JS. It will switch bridge modes and try again. See CB-2666.
|
||||
// We send a message meant specifically for this case. It starts with "@" so no other message can be encoded into the same string.
|
||||
@ -74,6 +89,9 @@ public class CordovaBridge {
|
||||
}
|
||||
|
||||
public String jsRetrieveJsMessages(int bridgeSecret, boolean fromOnlineEvent) throws IllegalAccessException {
|
||||
if (!checkBridgeEnabled("retrieveJsMessages()")) {
|
||||
return "";
|
||||
}
|
||||
verifySecret(bridgeSecret);
|
||||
return jsMessageQueue.popAndEncode(fromOnlineEvent);
|
||||
}
|
||||
|
@ -85,6 +85,10 @@ public class NativeToJsMessageQueue {
|
||||
reset();
|
||||
}
|
||||
|
||||
public boolean isBridgeEnabled() {
|
||||
return activeBridgeMode != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the bridge mode.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user