Loading src/com/android/documentsui/DocumentsAccess.java +16 −2 Original line number Diff line number Diff line Loading @@ -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(); } } } src/com/android/documentsui/picker/ActionHandler.java +1 −1 Original line number Diff line number Diff line Loading @@ -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()); } } Loading src/com/android/documentsui/picker/ConfirmFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -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: Loading Loading
src/com/android/documentsui/DocumentsAccess.java +16 −2 Original line number Diff line number Diff line Loading @@ -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(); } } }
src/com/android/documentsui/picker/ActionHandler.java +1 −1 Original line number Diff line number Diff line Loading @@ -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()); } } Loading
src/com/android/documentsui/picker/ConfirmFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -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: Loading