saf icon indicating copy to clipboard operation
saf copied to clipboard

Bug: getDirectoryPermission does not work for `!isDynamic`

Open 4ntoine opened this issue 2 years ago • 16 comments

Here is the code i use:

var saf = Saf("/storage/emulated/0/MyApp");

Then i check the permission:

   var permission = await _saf!.getDirectoryPermission(
        grantWritePermission: true,
        isDynamic: false
    );

Before the file manager is shown the uri is content://com.android.externalstorage.documents/tree/primary%3A%2Fstorage%2Femulated%2F0%2FMyApp. The file manager is shown and i just click "Use this directory" and tap "Allow". After the file manager is shown the uri becomes content://com.android.externalstorage.documents/tree/primary%3AMyApp (selectedDirectoryUri value).

So the following is true and the permission is released:

   if (!isDynamic && selectedDirectoryUri != _uriString) {
        releasePersistableUriPermission(selectedDirectoryUri);
        return false;
      }

As a result, no permission is granted.

4ntoine avatar Mar 25 '22 19:03 4ntoine