trebleshot / android

An open-source app that allows you to transfer files one to one securely or using a browser, all without the internet
GNU General Public License v2.0
143 stars 42 forks source link

Sharing Through Google Photos & Chrome Fails #97

Open velitasali opened 5 years ago

velitasali commented 5 years ago

Describe the bug When the content from Downloads in Google Chrome or any photo from Google Photos and similar apps is shared, the process fails with the below error

java.io.FileNotFoundException: Failed to create right connection for content://com.google.android.apps.photos.contentprovider/0/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F110326/REQUIRE_ORIGINAL/NONE/257810451
    at com.genonbeta.android.framework.io.DocumentFile.fromUri(DocumentFile.java:52)
    at com.genonbeta.android.framework.util.FileUtils.fromUri(FileUtils.java:132)
    at com.genonbeta.TrebleShot.adapter.TransferListAdapter.onLoad(TransferListAdapter.java:194)
    at com.genonbeta.TrebleShot.widget.GroupEditableListAdapter.onLoad(GroupEditableListAdapter.java:74)
    at com.genonbeta.android.framework.app.ListFragment$ListLoader.loadInBackground(ListFragment.java:361)
    at com.genonbeta.android.framework.app.ListFragment$ListLoader.loadInBackground(ListFragment.java:341)
    at androidx.loader.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:307)
    at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:60)
    at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:48)
    at androidx.loader.content.ModernAsyncTask$2.call(ModernAsyncTask.java:141)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)

To Reproduce Select and share any item as described above. The error can easily be seen when the file information is shown in the transfer activity

Expected behavior Share the files

Environment (please complete the following information):

mubashir-rehman commented 4 years ago

Describe the Isuue

The same happens with Files app. If we open Files app, select a file and then via share button share ti through TrebleShot. It gives error. 04-14 14:31:53.666 32617 1754 W System.err: java.lang.SecurityException: Permission Denial: opening provider com.android.externalstorage.ExternalStorageProvider from ProcessRecord{494e96b 32617:com.genonbeta.TrebleShot:transfer/u0a151} (pid=32617, uid=10151) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs 04-14 14:31:53.675

Environment (please complete the following information):

Android version: Android 10 ROM: Extendid UI Language: EN/US App version 1.4.2 Device Model and Brand: Nexus 6p

velitasali commented 4 years ago

@mubashir-rehman edited your comment to only include the necessary part. Thanks for the report.

velitasali commented 3 years ago

New findings:

This error occurs because intent validity is bound to the activity that receives it (SharingActivity in this case). As soon as the receiver activity finishes, the permission to open the URIs is revoked unless one of the URIs is still open. In order words, leaving the activity and without starting the transfer will result in this error (which will not be recoverable).