nimble0 / dotterel

Dotterel is a free, open source program that provides the ability to use stenographic input on the Android platform.
GNU General Public License v2.0
85 stars 6 forks source link

3rd party program cannot be used to select dictionary #13

Open user202729 opened 3 years ago

user202729 commented 3 years ago

Currently I'm using CX file explorer.

I'm not entirely sure if this is problem on Android side or the application, but it is definitely not trivial for a typical user to see where the issue is.

Reproduce:

Result: Dotterel crashes.

Possibly-relevant logcat section:

AndroidRuntime: FATAL EXCEPTION: main
AndroidRuntime: Process: nimble.dotterel, PID: 6406
AndroidRuntime: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=196610, result=-1, data=Intent { dat=content://com.cxinventor.file.explorer.fileprovider/root/storage/emulated/0/dotterel_dict/user_combined.json flg=0x3 }} to activity {nimble.dotterel/nimble.dotterel.DotterelSettings}: java.lang.SecurityException: No persistable permission grants found for UID 10150 and Uri 0 @ content://com.cxinventor.file.explorer.fileprovider/root/storage/emulated/0/dotterel_dict/user_combined.json
AndroidRuntime:     at android.app.ActivityThread.deliverResults(ActivityThread.java:4547)
AndroidRuntime:     at android.app.ActivityThread.handleSendResult(ActivityThread.java:4590)
AndroidRuntime:     at android.app.ActivityThread.-wrap20(ActivityThread.java)
AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1772)
AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:110)
AndroidRuntime:     at android.os.Looper.loop(Looper.java:232)
AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:6806)
AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
AndroidRuntime: Caused by: java.lang.SecurityException: No persistable permission grants found for UID 10150 and Uri 0 @ content://com.cxinventor.file.explorer.fileprovider/root/storage/emulated/0/dotterel_dict/user_combined.json
AndroidRuntime:     at android.os.Parcel.readException(Parcel.java:1708)
AndroidRuntime:     at android.os.Parcel.readException(Parcel.java:1661)
AndroidRuntime:     at android.app.ActivityManagerProxy.takePersistableUriPermission(ActivityManagerNative.java:5155)
AndroidRuntime:     at android.content.ContentResolver.takePersistableUriPermission(ContentResolver.java:2006)
AndroidRuntime:     at nimble.dotterel.DictionariesPreferenceFragment.onActivityResult(DictionariesPreference.kt:305)
AndroidRuntime:     at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:170)
AndroidRuntime:     at android.app.Activity.dispatchActivityResult(Activity.java:7234)
AndroidRuntime:     at android.app.ActivityThread.deliverResults(ActivityThread.java:4543)
AndroidRuntime:     ... 9 more
nimble0 commented 3 years ago

Dotterel needs persistent access to dictionaries so your dictionaries don't stop working when you reopen it. Not catching the exception is a bug but the main problem appears to be with CX file explorer not granting persistent access.

user202729 commented 3 years ago

As a workaround, I guess it is still possible to save the file (and inform the user that if they update the dictionary file they have to explicitly reselect it)?

I didn't try any other third party application, but this could be an issue with the android operating system too.

(also should there be any way for the program to require persistent access?)

==

The problem persists when I allow "storage" permission for dotterel (although I observe that dotterel works well even without that permission)

nimble0 commented 3 years ago

I'd be reluctant to do that since then there'd need to be a way to manage those saved files. Dotterel does require persistent, it's what's causing the exception.

I just tried CX file explorer 1.5.2 and didn't get any error. Could you provide your version of Android and CX file explorer?

user202729 commented 3 years ago

Upgraded to 1.5.2 and the problem disappeared.

My previous version was 1.4.2.

Given that it's likely a bug in the other program, perhaps dotterel should just catch the exception and show a warning message.