Skip to content

Commit

Permalink
Add @JavascriptInterface annotations to ExposedJsApi.
Browse files Browse the repository at this point in the history
And re-enable the JS bridge on 4.2.
https://issues.apache.org/jira/browse/CB-1879
  • Loading branch information
agrieve committed Nov 22, 2012
1 parent 92d69e3 commit 3566154
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions framework/src/org/apache/cordova/CordovaWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,6 @@ private void exposeJsInterface() {
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");
}

Expand Down
4 changes: 4 additions & 0 deletions framework/src/org/apache/cordova/ExposedJsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Licensed to the Apache Software Foundation (ASF) under one
*/
package org.apache.cordova;

import android.webkit.JavascriptInterface;
import org.apache.cordova.api.PluginManager;
import org.apache.cordova.api.PluginResult;
import org.json.JSONException;
Expand All @@ -37,6 +38,7 @@ public ExposedJsApi(PluginManager pluginManager, NativeToJsMessageQueue jsMessag
this.jsMessageQueue = jsMessageQueue;
}

@JavascriptInterface
public String exec(String service, String action, String callbackId, String arguments) throws JSONException {
jsMessageQueue.setPaused(true);
try {
Expand All @@ -51,10 +53,12 @@ public String exec(String service, String action, String callbackId, String argu
}
}

@JavascriptInterface
public void setNativeToJsBridgeMode(int value) {
jsMessageQueue.setBridgeMode(value);
}

@JavascriptInterface
public String retrieveJsMessages() {
return jsMessageQueue.popAndEncode();
}
Expand Down

0 comments on commit 3566154

Please sign in to comment.