mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
Add @JavascriptInterface annotations to ExposedJsApi.
And re-enable the JS bridge on 4.2. https://issues.apache.org/jira/browse/CB-1879
This commit is contained in:
parent
2ee4326a4d
commit
11e0ffa90a
@ -302,10 +302,6 @@ public class CordovaWebView extends WebView {
|
||||
Log.i(TAG, "Disabled addJavascriptInterface() bridge callback due to a bug on the 2.3 emulator");
|
||||
return;
|
||||
}
|
||||
else if (SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
Log.i(TAG, "Disabled addJavascriptInterface() bridge callback for 4.2. Symbols are broken, and we can't compile the annotation needed to expose the exec.");
|
||||
return;
|
||||
}
|
||||
this.addJavascriptInterface(exposedJsApi, "_cordovaNative");
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.cordova;
|
||||
|
||||
import android.webkit.JavascriptInterface;
|
||||
import org.apache.cordova.api.PluginManager;
|
||||
import org.apache.cordova.api.PluginResult;
|
||||
import org.json.JSONException;
|
||||
@ -37,6 +38,7 @@ import org.json.JSONException;
|
||||
this.jsMessageQueue = jsMessageQueue;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String exec(String service, String action, String callbackId, String arguments) throws JSONException {
|
||||
jsMessageQueue.setPaused(true);
|
||||
try {
|
||||
@ -51,10 +53,12 @@ import org.json.JSONException;
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void setNativeToJsBridgeMode(int value) {
|
||||
jsMessageQueue.setBridgeMode(value);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String retrieveJsMessages() {
|
||||
return jsMessageQueue.popAndEncode();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user