Closed tsoen closed 2 weeks ago
In all of my native plugins, I enforce the permissions to avoid edge cases. I've seen countless edge cases where something doesn't work on a very specific configuration (Xiaomis on landscape orientation, Huaweis with MIUI, etc.) and some of those edge cases are caused by missing permissions (although the permission is supposed to be optional). Sometimes, even the official documentation says something and that turns out to be false on certain devices for unknown reasons. So I take all necessary precautions to eliminate the edge cases as much as possible.
I add configurable parameters for certain native stuff (they are mostly "use at your own risk" parameters) and I may add a similar parameter here, too.
I've implemented the flag. You can call this in Awake to enable it:
#if UNITY_ANDROID
using( AndroidJavaClass ajc = new AndroidJavaClass( "com.yasirkula.unity.NativeFilePicker" ) )
ajc.SetStatic<bool>( "PermissionFreeMode", true );
#endif
Description of the bug
We force the permission READ_EXTERNAL_STORAGE to be removed from our manifest for security reason, and we don't need to read the external storage. When we try to import a file (
NativeFilePicker.PickFile
) on a Android 12- device, the picker doesn't open because theRequestPermission
method returnsPermission.Denied
.The Picker works fine on Android 13+ devices and we are able to import files from the internal storage.
I think the issue comes from your NativeFilePicker.java class:
Even if I comment the permission check in C# like this:
I can't check if it would actually work without the READ_EXTERNAL_STORAGE in the manifest, because your Java
PickFiles
method checks again for the permisison :Reproduction steps
Try to PickFile on Android 12- with READ_EXTERNAL_STORAGE removed from AndroidManifest like this:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove" />
Platform specs
Please provide the following info if this is a Unity 3D repository.
Additional info
No error message. CheckPermission returns Permission.Denied.