-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
On Amaze 3.2.1, if another app starts an ACTION_VIEW
Intent
for text/plain
and a valid Uri
pointing to read-only content, TextReader
crashes:
java.lang.SecurityException: Permission Denial: writing android.support.v4.content.FileProvider uri content://com.commonsware.myapplication.provider/Download/hello_world.txt from pid=592, uid=10170 requires the provider be exported, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:2004)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:146)
at android.content.ContentProviderProxy.openAssetFile(ContentProviderNative.java:625)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1265)
at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1100)
at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1054)
at com.amaze.filemanager.activities.TextReader.getInputStream(TextReader.java:685)
at com.amaze.filemanager.activities.TextReader.access$400(TextReader.java:92)
at com.amaze.filemanager.activities.TextReader$4.run(TextReader.java:461)
That comes from this code segment. I think that your algorithm is fine, but you need to check for SecurityException
in addition to FileNotFoundException
, and try the read-only access in both cases.
The attached sample project reproduces the problem. It is nearly the same as the one from issue #1014, except that this one fixes the null
Uri
problem that triggered that earlier crash. Like the first one, it requires a hello_world.txt
file in the Download/
directory of external storage.
This can be reproduced on Android 8.1 at minimum, though I suspect that it will yield similar results on other modern versions of Android.