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

getDirectory and Android 13 #606

Closed
petr-vytlacil opened this issue Sep 27, 2023 · 3 comments
Closed

getDirectory and Android 13 #606

petr-vytlacil opened this issue Sep 27, 2023 · 3 comments
Labels
Milestone

Comments

@petr-vytlacil
Copy link

petr-vytlacil commented Sep 27, 2023

Is any way ho use getDirectory on Android 13?

Example usage

fileSystem.root.getDirectory( 'Download', { create: true }, (dirEntry) => { console.log('createFile') log.info('saveBlob2File -> requestFileSystem', 'createFile') createFile(dirEntry, fileName, blob) }, (error) => { log.error(logSource, 'Directory Download could not be created.') log.error(logSource, error) const notificationObj = { message: logSource + ' | fileSystem.root.getDirectory | ' + ': error: ' + error.message, timeMark: new Date().getTime() } store.dispatch('appNotifications/setMessage', notificationObj) updateCircularProgressVisible(false) })

In FileUtils is else if (action.equals("getDirectory")) { where check permission but its for old Android API.

private void getWritePermission(String rawArgs, int action, CallbackContext callbackContext) { int requestCode = pendingRequests.createRequest(rawArgs, action, callbackContext); PermissionHelper.requestPermission(this, requestCode, Manifest.permission.WRITE_EXTERNAL_STORAGE); }

THX

@breautek breautek added the bug label Oct 3, 2023
@breautek
Copy link
Contributor

breautek commented Oct 3, 2023

Yes, I believe this needs to be API guarded...

API 29 and later doesn't need WRITE_EXTERNAL_STORAGE because scoped storage is in effect which removes the permission requirement. So on API 29 or later, I think we can simply return true...

private boolean hasWritePermission() {

private boolean hasWritePermission() {
-    return PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
+   if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
+       return PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
+   }
+
+   return true;
}

Honestly this whole permission checking can be further improved, since it seems like it's also requesting permissions on internal storage usage, which isn't necessary since API 19.

@breautek breautek added this to the 8.0.1 milestone Oct 3, 2023
@breautek
Copy link
Contributor

I believe #581 fixes this issue

But it tests for TIRAMISU (API 33) instead of P (API 29), which I think is fine because if we test for P like I originally suggested, it means we will actually lose out on the implicit read grant which is still necessary for API 29-32.

It would be great if you can give PR #581 a test to see if it solves your issue.

@erisu
Copy link
Member

erisu commented Oct 17, 2023

Should be resolved by #608

@erisu erisu closed this as completed Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants