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

DocumentProvider does not allow createDocument() #1350

Closed
x0b opened this issue Nov 17, 2019 · 3 comments
Closed

DocumentProvider does not allow createDocument() #1350

x0b opened this issue Nov 17, 2019 · 3 comments

Comments

@x0b
Copy link
Contributor

x0b commented Nov 17, 2019

Problem description
When using the Termux DocumentProvider from another app, you can not save files into the termux user directory or its children.

Steps to reproduce

  1. Start a write request to the Termux' DocumentProvider
  2. An error message appears and logcat writes:
E/DatabaseUtils: Writing exception to parcel
    java.lang.UnsupportedOperationException: Create not supported
        at android.provider.DocumentsProvider.createDocument(DocumentsProvider.java:227)
        at android.provider.DocumentsProvider.callUnchecked(DocumentsProvider.java:757)
        at android.provider.DocumentsProvider.call(DocumentsProvider.java:716)
        at android.content.ContentProvider$Transport.call(ContentProvider.java:492)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:283)
        at android.os.Binder.execTransact(Binder.java:565)
W/DocumentsActivity: Failed to create document
    java.lang.UnsupportedOperationException: Create not supported
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
        at android.content.ContentProviderProxy.call(ContentProviderNative.java:646)
        at android.content.ContentProviderClient.call(ContentProviderClient.java:456)
        at android.provider.DocumentsContract.createDocument(DocumentsContract.java:1083)
        at com.android.documentsui.DocumentsActivity$CreateFinishTask.run(DocumentsActivity.java:573)
        at com.android.documentsui.DocumentsActivity$CreateFinishTask.run(DocumentsActivity.java:564)
        at com.android.documentsui.PairedTask.doInBackground(PairedTask.java:67)
        at android.os.AsyncTask$2.call(AsyncTask.java:304)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at com.android.documentsui.ProviderExecutor.run(ProviderExecutor.java:104)

Cause:
Flag indicates create support:

flags |= Document.FLAG_SUPPORTS_WRITE | Document.FLAG_SUPPORTS_DELETE;

2.:

row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_SEARCH);

but no create is implemented.

Expected behavior
Termux allows me to write to the user directory if the user has granted permissions to do so by selecting the Termux' DocumentProvider in DocumentsUI.

Additional information

What am I trying to achieve?

I'm currently trying to introduce support for shared config files into RcloneExplorer so that users can use Termux for the full shell experience and rcloneExplorer for the day to day browsing.

EDIT
Is there interest in implementing createDocument()? If so, I could probably submit a pull request. openDocument() is not restricted to reads anyway, so either this a implementation or security error since you could do a openDocumentStream() on the underlying file anyways.

@x0b x0b changed the title DocumentProvider does not allow write access DocumentProvider does not allow createDocument() Nov 17, 2019
@x0b
Copy link
Contributor Author

x0b commented Dec 8, 2019

bump

Is there interest in implementing createDocument()? If so, I could probably submit a pull request. openDocument() is not restricted to reads anyway, so either this a implementation or security error since you could do a openDocumentStream() on the underlying file anyways.

@chrysn
Copy link

chrysn commented Feb 6, 2020

As a termux user, I'd appreciate this a lot, as together with #1424 it'd give back sone UNIX experience to Android 10+, and make git-annex usable more easily across appiications.

x0b added a commit to x0b/termux-app that referenced this issue Feb 6, 2020
@fornwall
Copy link
Member

fornwall commented Feb 9, 2020

Fixed by @x0b (great work!) in #1460, which has just been released in version 0.92 of the app.

@ghost ghost locked and limited conversation to collaborators Oct 17, 2021
AdamMickiewich pushed a commit to VolyaTeam/dzida-app that referenced this issue Aug 8, 2022
shrihankp pushed a commit to reisxd/termux-app that referenced this issue Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants