Remove unused async arg from PluginManager.exec().

This commit is contained in:
Andrew Grieve
2012-09-24 23:32:31 -04:00
parent afcdccf783
commit c7ce9598a8
3 changed files with 10 additions and 9 deletions
@@ -101,7 +101,7 @@ public class CordovaWebViewClient extends WebViewClient {
String action = url.substring(idx2 + 1, idx3); String action = url.substring(idx2 + 1, idx3);
String callbackId = url.substring(idx3 + 1, idx4); String callbackId = url.substring(idx3 + 1, idx4);
String jsonArgs = url.substring(idx4 + 1); String jsonArgs = url.substring(idx4 + 1);
appView.pluginManager.exec(service, action, callbackId, jsonArgs, true /* async */); appView.pluginManager.exec(service, action, callbackId, jsonArgs);
} }
/** /**
@@ -40,7 +40,7 @@ import org.json.JSONException;
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 {
boolean wasSync = pluginManager.exec(service, action, callbackId, arguments, true /* async */); boolean wasSync = pluginManager.exec(service, action, callbackId, arguments);
String ret = ""; String ret = "";
if (!NativeToJsMessageQueue.DISABLE_EXEC_CHAINING || wasSync) { if (!NativeToJsMessageQueue.DISABLE_EXEC_CHAINING || wasSync) {
ret = jsMessageQueue.popAndEncode(); ret = jsMessageQueue.popAndEncode();
@@ -209,20 +209,16 @@ public class PluginManager {
* this is an async plugin call. * this is an async plugin call.
* @param args An Array literal string containing any arguments needed in the * @param args An Array literal string containing any arguments needed in the
* plugin execute method. * plugin execute method.
* @param async Boolean indicating whether the calling JavaScript code is expecting an
* immediate return value. If true, either Cordova.callbackSuccess(...) or
* Cordova.callbackError(...) is called once the plugin code has executed.
* @return Whether the task completed synchronously. * @return Whether the task completed synchronously.
*/ */
public boolean exec(final String service, final String action, final String callbackId, final String jsonArgs, final boolean async) { public boolean exec(final String service, final String action, final String callbackId, final String jsonArgs) {
PluginResult cr = null; PluginResult cr = null;
boolean runAsync = async; final IPlugin plugin = this.getPlugin(service);
boolean runAsync = !plugin.isSynch(action);
try { try {
final JSONArray args = new JSONArray(jsonArgs); final JSONArray args = new JSONArray(jsonArgs);
final IPlugin plugin = this.getPlugin(service);
//final CordovaInterface ctx = this.ctx; //final CordovaInterface ctx = this.ctx;
if (plugin != null) { if (plugin != null) {
runAsync = async && !plugin.isSynch(action);
if (runAsync) { if (runAsync) {
// Run this on a different thread so that this one can return back to JS // Run this on a different thread so that this one can return back to JS
ctx.getThreadPool().execute(new Runnable() { ctx.getThreadPool().execute(new Runnable() {
@@ -266,6 +262,11 @@ public class PluginManager {
return true; return true;
} }
@Deprecated
public boolean exec(String service, String action, String callbackId, String jsonArgs, boolean async) {
return exec(service, action, callbackId, jsonArgs);
}
/** /**
* Get the plugin object that implements the service. * Get the plugin object that implements the service.
* If the plugin object does not already exist, then create it. * If the plugin object does not already exist, then create it.