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,10 +68,15 @@ 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 (id == 0) {
LOG.i("CordovaLog", "config.xml missing. Ignoring..."); // If we couldn't find config.xml there, we'll look in the namespace from AndroidManifest.xml
return; id = action.getResources().getIdentifier("config", "xml", action.getPackageName());
if (id == 0) {
LOG.i("CordovaLog", "config.xml missing. Ignoring...");
return;
}
} }
// Add implicitly allowed URLs // Add implicitly allowed URLs

View File

@ -110,11 +110,16 @@ 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 (id == 0) {
this.pluginConfigurationMissing(); // If we couldn't find config.xml there, we'll look in the namespace from AndroidManifest.xml
//We have the error, we need to exit without crashing! id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getPackageName());
return; if (id == 0) {
this.pluginConfigurationMissing();
//We have the error, we need to exit without crashing!
return;
}
} }
XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id); XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
int eventType = -1; int eventType = -1;