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:
Andrew Grieve 2012-11-22 12:39:18 -05:00 committed by Simon MacDonald
parent 2ee4326a4d
commit 11e0ffa90a
2 changed files with 4 additions and 4 deletions

View File

@ -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"); Log.i(TAG, "Disabled addJavascriptInterface() bridge callback due to a bug on the 2.3 emulator");
return; 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"); this.addJavascriptInterface(exposedJsApi, "_cordovaNative");
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.apache.cordova; package org.apache.cordova;
import android.webkit.JavascriptInterface;
import org.apache.cordova.api.PluginManager; import org.apache.cordova.api.PluginManager;
import org.apache.cordova.api.PluginResult; import org.apache.cordova.api.PluginResult;
import org.json.JSONException; import org.json.JSONException;
@ -37,6 +38,7 @@ import org.json.JSONException;
this.jsMessageQueue = jsMessageQueue; this.jsMessageQueue = jsMessageQueue;
} }
@JavascriptInterface
public String exec(String service, String action, String callbackId, String arguments) throws JSONException { public String exec(String service, String action, String callbackId, String arguments) throws JSONException {
jsMessageQueue.setPaused(true); jsMessageQueue.setPaused(true);
try { try {
@ -51,10 +53,12 @@ import org.json.JSONException;
} }
} }
@JavascriptInterface
public void setNativeToJsBridgeMode(int value) { public void setNativeToJsBridgeMode(int value) {
jsMessageQueue.setBridgeMode(value); jsMessageQueue.setBridgeMode(value);
} }
@JavascriptInterface
public String retrieveJsMessages() { public String retrieveJsMessages() {
return jsMessageQueue.popAndEncode(); return jsMessageQueue.popAndEncode();
} }