Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10e6c71e authored by Kelvin Kwan's avatar Kelvin Kwan Committed by Automerger Merge Worker
Browse files

Merge "Returns a correct cross profile uri for CREATE_DOCUMENT" into rvc-dev am: cd1ac87b

Change-Id: Id1d8e2db7e956c5495de5dfa6b337007e82c1a95
parents 901d44aa cd1ac87b
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -154,12 +154,26 @@ public interface DocumentsAccess {
            final ContentResolver resolver = parentDoc.userId.getContentResolver(mContext);
            try (ContentProviderClient client = DocumentsApplication.acquireUnstableProviderOrThrow(
                    resolver, parentDoc.derivedUri.getAuthority())) {
                return DocumentsContract.createDocument(
                Uri createUri = DocumentsContract.createDocument(
                        wrap(client), parentDoc.derivedUri, mimeType, displayName);
                // If the document info's user is the current user, we can simply return the uri.
                // Otherwise, we need to create document with the content resolver from the other
                // user. The uri returned from that content resolver does not contain the user
                // info. Hence we need to append the other user info to the uri otherwise an app
                // will think the uri is from the current user.
                // The way to append a userInfo is to use the authority which contains user info
                // obtained from the parentDoc.getDocumentUri().
                return UserId.CURRENT_USER.equals(parentDoc.userId)
                        ? createUri : appendEncodedParentAuthority(parentDoc, createUri);
            } catch (Exception e) {
                Log.w(TAG, "Failed to create document", e);
                return null;
            }
        }

        private Uri appendEncodedParentAuthority(DocumentInfo parentDoc, Uri uri) {
            return uri.buildUpon().encodedAuthority(
                    parentDoc.getDocumentUri().getAuthority()).build();
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -419,7 +419,7 @@ class ActionHandler<T extends FragmentActivity & Addons> extends AbstractActionH
        if (mFeatures.isOverwriteConfirmationEnabled()) {
            mInjector.dialogs.confirmAction(fm, replaceTarget, ConfirmFragment.TYPE_OVERWRITE);
        } else {
            finishPicking(replaceTarget.derivedUri);
            finishPicking(replaceTarget.getDocumentUri());
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ public class ConfirmFragment extends DialogFragment {
                        android.R.string.ok,
                        (DialogInterface dialog, int id) -> {
                            pickResult.increaseActionCount();
                            mActions.finishPicking(mTarget.derivedUri);
                            mActions.finishPicking(mTarget.getDocumentUri());
                        });
                break;
            case TYPE_OEPN_TREE: