Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission not requested on Android 10 when targeting API 33 #586

Open
3 tasks done
alexisGandar opened this issue Jul 27, 2023 · 1 comment
Open
3 tasks done

Permission not requested on Android 10 when targeting API 33 #586

alexisGandar opened this issue Jul 27, 2023 · 1 comment

Comments

@alexisGandar
Copy link

alexisGandar commented Jul 27, 2023

Bug Report

When writing file in this path " window.cordova.file.externalRootDirectory + 'Download' " it always throws a permission error on getFile action. The bug occur when upgrading on cordova-plugin-file V8 and cordova-android V12 and only on device with Android 10 and bellow. It does work on cordova-plugin-file V7 and cordova-android V11

Problem

The modal that request user authorisation for writing (WRITE_EXTERNAL_STORAGE) does not pop on screen witch lead to an INVALID_MODIFICATION_ERR (code 9) because the permission is not granted

What is expected to happen?

The modal that request the permission is displayed.

What does actually happen?

The modal does not appear

Information

I found out that when writing a file the following action are executed in FileUtils.java :

  • ResolveLocalFileSystemURI
  • RequestAllFileSystem
  • GetFile
  • GetFileMetaData
  • Write

The permission is checked on the "Write" step but on Android 10 (for reasons that I can't explain) the permission seems to be required at the GetFile steps.

I did patch this issus by editing the GetFile steps in order to always ask for permission if needed on this step but I am not sure of the concequencies of this edit : see pull request #587

Command or Code

To reproduce the problem try to save a file with "writeFile" to " window.cordova.file.externalRootDirectory + 'Download'

Environment, Platform, Device

Android 10 with cordova-plugin-file V8 and cordova-android V12

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@erisu
Copy link
Member

erisu commented Oct 19, 2023

@alexisGandar , can you test the main branch to see if this issue still exists?

There is a PR that was merged in recently. It fixed an issue in the hasWritePermission method. I believe it might might have fixed this issue as well. If it did, this issue and the PR #587, which you submitted, could be closed.

Can you confirm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants