cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ian Clelland (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CB-6890) Android plugins which use pluginManager fields break on 4.0.x branch
Date Fri, 06 Jun 2014 19:06:02 GMT

     [ https://issues.apache.org/jira/browse/CB-6890?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Ian Clelland resolved CB-6890.
------------------------------

    Resolution: Fixed

Fixed in three core plugins.

> Android plugins which use pluginManager fields break on 4.0.x branch
> --------------------------------------------------------------------
>
>                 Key: CB-6890
>                 URL: https://issues.apache.org/jira/browse/CB-6890
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin File, Plugin File Transfer, Plugin Media Capture
>    Affects Versions: 4.0.0
>            Reporter: Ian Clelland
>            Assignee: Ian Clelland
>
> The field {{CordovaWebView.pluginManager}} was changed from a public field to a getter,
{{getPluginManager()}}, for Cordova-Android v4.0.0. (to support pluggable webviews)
> This means that code in plugins like this:
> {code}
> PluginManager pm = webView.pluginManager;
> {code}
> will break. However, the replacement code,
> {code}
> PluginManager pm = webView.getPluginManager();
> {code}
> will break on existing 3.x versions of Cordova.
> The solution is to use reflection in the plugin to determine whether the method or the
field is available, and to use the appropriate access method to get the plugin manager. This
code works in both old and new versions of Cordova:
> {code}
> Class webViewClass = webView.getClass();
> PluginManager pm = null;
> try {
>     Method gpm = webViewClass.getMethod("getPluginManager");
>     pm = (PluginManager) gpm.invoke(webView);
> } catch (NoSuchMethodException e) {
> } catch (IllegalAccessException e) {
> } catch (InvocationTargetException e) {
> }
> if (pm == null) {
>     try {
>         Field pmf = webViewClass.getField("pluginManager");
>         pm = (PluginManager)pmf.get(webView);
>     } catch (NoSuchFieldException e) {
>     } catch (IllegalAccessException e) {
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message