Check plugin against new Plugin and IPlugin to determine if valid plugin class.

This commit is contained in:
Bryce Curtis 2010-10-05 00:39:57 -05:00
parent 68146329b9
commit 385be26046

View File

@ -101,6 +101,9 @@ public final class PluginManager {
} }
// if async we have already returned at this point unless there was an error... // if async we have already returned at this point unless there was an error...
if (runAsync) { if (runAsync) {
if (cr == null) {
cr = new PluginResult(PluginResult.Status.CLASS_NOT_FOUND_EXCEPTION);
}
ctx.sendJavascript(cr.toErrorCallbackString(callbackId)); ctx.sendJavascript(cr.toErrorCallbackString(callbackId));
} }
if (cr != null) { if (cr != null) {
@ -128,15 +131,16 @@ public final class PluginManager {
* @return Boolean indicating if the class implements com.phonegap.api.Plugin * @return Boolean indicating if the class implements com.phonegap.api.Plugin
*/ */
private boolean isPhoneGapPlugin(Class c) { private boolean isPhoneGapPlugin(Class c) {
boolean isPlugin = false; if (c.getSuperclass().getName().equals("com.phonegap.api.Plugin")) {
return true;
}
Class[] interfaces = c.getInterfaces(); Class[] interfaces = c.getInterfaces();
for (int j=0; j<interfaces.length; j++) { for (int j=0; j<interfaces.length; j++) {
if (interfaces[j].getName().equals("com.phonegap.api.Plugin")) { if (interfaces[j].getName().equals("com.phonegap.api.IPlugin")) {
isPlugin = true; return true;
break;
} }
} }
return isPlugin; return false;
} }
/** /**