fix!: Make CoreAndroid plugin instantiate on load (#1605)

I don't anticipate breaking changes from this change, however it is a difference
in behaviour since CoreAndroid won't be lazily loaded, therefore I've marked this
commit has a breaking change.
This commit is contained in:
Norman Breau 2023-04-21 16:00:11 -03:00 committed by GitHub
parent 7efe90faac
commit a62f699380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -115,7 +115,7 @@ public class CordovaWebViewImpl implements CordovaWebView {
// This isn't enforced by the compiler, so assert here.
assert engine.getView() instanceof CordovaWebViewEngine.EngineView;
pluginManager.addService(CoreAndroid.PLUGIN_NAME, "org.apache.cordova.CoreAndroid");
pluginManager.addService(CoreAndroid.PLUGIN_NAME, "org.apache.cordova.CoreAndroid", true);
pluginManager.init();
}

View File

@ -197,7 +197,18 @@ public class PluginManager {
* @param className The plugin class name
*/
public void addService(String service, String className) {
PluginEntry entry = new PluginEntry(service, className, false);
addService(service, className, false);
}
/**
* Add a plugin class that implements a service to the service entry table.
*
* @param service The service name
* @param className The plugin class name
* @param onload If true, the plugin will be instantiated immediately
*/
public void addService(String service, String className, boolean onload) {
PluginEntry entry = new PluginEntry(service, className, onload);
this.addService(entry);
}