TeamAmaze / TeamAmaze/AmazeFileManager

Unable to move a file between 2 removables storage

Open
#1,057 1 comment 1 reaction 1 assignee View on GitHub

@TranceLove is already working on this.

Since Mar 31, 2018.

Issue-Bug
Dominant language
Kotlin
Stars
6.4k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
1

Description

Hi,

Whenever you want to write to an external storage (removable usb or external sdcard) we must have access granted via the internal file provider?

In this case it is impossible to cut / paste a file between 2 removables storage.

I added this in MainActivity's onCreate () to check uris granted:
(minSdkVersion 19 in gradle)

List<UriPermission> permissionList = getContentResolver().getPersistedUriPermissions();
        for (UriPermission perm : permissionList){
            Log.i("perm",perm.getUri().toString());
        }

result output:

I/perm: content://com.android.externalstorage.documents/tree/C853-72E5%3A
I/perm: content://com.android.externalstorage.documents/tree/44F4-DBD5%3A
I/perm: content://com.android.externalstorage.documents/tree/8A26-6180%3A

The uris of my three storages are persistent granted and registered in PreferencesConstants.PREFERENCE_URI:

....
else if (requestCode == 3) {
            Uri treeUri;
            if (responseCode == Activity.RESULT_OK) {
                // Get Uri from Storage Access Framework.
                treeUri = intent.getData();
                // Persist URI - this is required for verification of writability.
                if (treeUri != null) getPrefs().edit().putString(PreferencesConstants.PREFERENCE_URI,
                        treeUri.toString()).commit();
            } else {
                // If not confirmed SAF, or if still not writable, then revert settings.
                /* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false, currentFolder);
                        ||!FileUtil.isWritableNormalOrSaf(currentFolder)*/
                return;
            }

            // After confirmation, update stored value of folder.
            // Persist access permissions.

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION
                        | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            }
....

I did not find in the code where are handle checking preferences to check if the destination uri is ok.

NB: it seems that solidExplorer offers this possibility of persistence of all the uris granted

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.