apache / cordova-plugin-file-transfer

Apache Cordova File Transfer Plugin
https://cordova.apache.org/
Apache License 2.0
595 stars 888 forks source link

feat!: remove deprecated whitelist usage #307

Closed erisu closed 2 years ago

erisu commented 2 years ago

Platforms affected

Android

Motivation and Context

Build is failing in Cordova-Android 10.

fixes: #306

Description

The Whitelist import can be removed.

The getWhitelist method was removed a long time ago. The getWhitelist method was related to the commented statement:

This code exists for compatibility between 3.x and 4.x versions of Cordova.

The AllowList which was integrated into the core of cordova-android is still being loaded as if it was a plugin so there for the next if block should still work as usual to fetch the shouldAllowRequest value.

if (shouldAllowRequest == null) {
    try {
        Method gpm = webView.getClass().getMethod("getPluginManager");
        PluginManager pm = (PluginManager)gpm.invoke(webView);
        Method san = pm.getClass().getMethod("shouldAllowRequest", String.class);
        shouldAllowRequest = (Boolean)san.invoke(pm, source);
    } catch (NoSuchMethodException e) {
    } catch (IllegalAccessException e) {
    } catch (InvocationTargetException e) {
    }
}

Additionally, since there hasn't been a release since the undeprecation, it should be safe to say that the next release will be major and removing this old code is acceptable.

Testing

If anyone wants to confirm the shouldAllowRequest functionality continues to work as expected with their app, that would be appreciated.

Checklist

bftcntyapps commented 2 years ago

This is not found in the latest version of this plugin and is failing on Android API 30 using Ionic Appflow. Will this be fixed soon?

brunoalex commented 2 years ago

realy need this fixed please

growthengineering commented 2 years ago

Its a problem! This needs to be fixed

gwhenne commented 2 years ago

This needs to be fixed

LSDCF commented 1 year ago

please add it to the fix to the plugin, the error remain even now after 1 year

RenzoPH commented 1 year ago

Hi all, I still encounter this issue also. even I delete the Whitelist still appearing on my logs.. any solution that did to working fine

Task :capacitor-cordova-android-plugins:compileDebugJavaWithJavac The following annotation processors are not incremental: dagger-compiler-2.8.jar (com.google.dagger:dagger-compiler:2.8). Make sure all annotation processors are incremental to improve your build speed. /Users/runner/work/1/s/android/capacitor-cordova-android-plugins/src/main/java/org/apache/cordova/filetransfer/FileTransfer.java:48: error: cannot find symbol import org.apache.cordova.Whitelist; ^ symbol: class Whitelist location: package org.apache.cordova /Users/runner/work/1/s/android/capacitor-cordova-android-plugins/src/main/java/org/apache/cordova/filetransfer/FileTransfer.java:691: error: cannot find symbol Whitelist whitelist = (Whitelist)gwl.invoke(webView); ^ symbol: class Whitelist location: class FileTransfer /Users/runner/work/1/s/android/capacitor-cordova-android-plugins/src/main/java/org/apache/cordova/filetransfer/FileTransfer.java:691: error: cannot find symbol Whitelist whitelist = (Whitelist)gwl.invoke(webView); ^ symbol: class Whitelist location: class FileTransfer Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors