这是indexloc提供的服务,不要输入任何密码
Skip to content

DocumentProvider does not allow createDocument() #1350

@x0b

Description

@x0b

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions