MauriceFrank commented on issue #561:
URL: 
https://github.com/apache/cordova-plugin-file/issues/561#issuecomment-1527154468

   > > shared storage cannot be accessed even if MANAGE_EXTERNAL_STORAGE 
permission is granted.
   > 
   > This could be a bug in the android platform, as `MANAGE_EXTERNAL_STORAGE` 
is suppose to provide [All Files 
Access](https://developer.android.com/about/versions/11/privacy/storage#all-files-access).
 So if this is not providing you access, a bug maybe should be raised with 
Android, if not already.
   > 
   > However, `MANAGE_EXTERNAL_STORAGE` external access requires justification 
to use if you intend to deploy through the google play store, so unless if you 
absolutely have a need for the permission (such as a File manager kind of app), 
you should be using the granular permissions.
   > 
   > I've added this to the 8.x milestone as it will require a breaking change 
(we need the cordova-android@12 which is currently in development for SDK 33.
   > 
   > > Are there any known workarounds / alternatives ?
   > 
   > I don't think there is an easy way. At minimum, you'll need to fork and 
get your hands dirty to monkey patch in requesting the appropriate permissions.
   > 
   > A workaround would require:
   > 
   > 1. cordova-android@11 (as it has API 31+ support)
   > 2. `android-buildToolsVersion` preference set to `33.0.0` (or the latest 
patch available, ideally). Android SDK Manager also needs to be used to install 
the build tools version.
   > 3. `android-compileSdkVesion` set to `33`
   > 4. `android-targetSdkVersion` set to `33`
   > 5. Potentially updates to additional androidx dependencies if any of them 
has a max sdk version set that is less than `33`
   > 6. Update to 
https://github.com/apache/cordova-plugin-file/blob/b32be30e4bd012f9d9568a9cc11926b2ad6c14f7/src/android/FileUtils.java#L106
   >     to add the new permissions. Note that `READ_EXTERNAL_STORAGE` I think 
is still required if your app can run on devices pre-API 33. 
`WRITE_EXTERNAL_STORAGE` I believe is still required if your app can run on 
devices pre-API 29.
   > 7. 
https://github.com/apache/cordova-plugin-file/blob/b32be30e4bd012f9d9568a9cc11926b2ad6c14f7/src/android/FileUtils.java#L580
   >     will need to be updated to use the one of the new read permissions if 
the API is >= 33, and falback to `READ_EXTERNAL_STORAGE` otherwise.
   > 8. This list is not exhaustive, there could be things missing, this is 
just a initial first glance analysis.
   
   
   Thanks! Your suggestions work - at least the method "file.listDir()" I had 
security errors with.
   I actually tried the changes first with READ_MEDIA_IMAGES and the method 
"file.listDir()" did not throw any security errors anymore, while accessing 
external storage directories like the "Pictures" folder and entries within it.
   
   
   However, there are 3 new READ-Permissiosn for Android 13+ needed, therefore 
we would need to request all 3.
   I created a Pull-Request if anyone is interested in the change or needs 
media-file access (read) on Android 13, located in the external storage such as 
the Gallery:
   
   https://github.com/apache/cordova-plugin-file/pull/566
   
   However, this will automatically request all 3 permissions(images,video and 
audio). If the file-plugin should only request the needed permission for the 
specific read-request, the plugin has to be changed in a more extensive way.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to