CB-5481 Fix for Cordova trying to get config.xml from the wrong namespace

This commit is contained in:
Håkon Nilsen 2013-12-04 21:06:15 +01:00 committed by Andrew Grieve
parent e646a0840d
commit 28c10dba09
2 changed files with 15 additions and 5 deletions

View File

@ -68,11 +68,16 @@ public class Config {
return; return;
} }
// First checking the class namespace for config.xml
int id = action.getResources().getIdentifier("config", "xml", action.getClass().getPackage().getName()); int id = action.getResources().getIdentifier("config", "xml", action.getClass().getPackage().getName());
if (id == 0) {
// If we couldn't find config.xml there, we'll look in the namespace from AndroidManifest.xml
id = action.getResources().getIdentifier("config", "xml", action.getPackageName());
if (id == 0) { if (id == 0) {
LOG.i("CordovaLog", "config.xml missing. Ignoring..."); LOG.i("CordovaLog", "config.xml missing. Ignoring...");
return; return;
} }
}
// Add implicitly allowed URLs // Add implicitly allowed URLs
whitelist.addWhiteListEntry("file:///*", false); whitelist.addWhiteListEntry("file:///*", false);

View File

@ -110,12 +110,17 @@ public class PluginManager {
* Load plugins from res/xml/config.xml * Load plugins from res/xml/config.xml
*/ */
public void loadPlugins() { public void loadPlugins() {
// First checking the class namespace for config.xml
int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getClass().getPackage().getName()); int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getClass().getPackage().getName());
if (id == 0) {
// If we couldn't find config.xml there, we'll look in the namespace from AndroidManifest.xml
id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getPackageName());
if (id == 0) { if (id == 0) {
this.pluginConfigurationMissing(); this.pluginConfigurationMissing();
//We have the error, we need to exit without crashing! //We have the error, we need to exit without crashing!
return; return;
} }
}
XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id); XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
int eventType = -1; int eventType = -1;
String service = "", pluginClass = "", paramType = ""; String service = "", pluginClass = "", paramType = "";