fr3ts0n / StageFever

Show stage notes, amp/effect settings, BPM etc for any song in setlist
GNU General Public License v3.0
8 stars 9 forks source link

access denied #2

Closed ghost closed 7 years ago

ghost commented 7 years ago

I get the following error when opening a csv file:


Load content: file:///storage/emulated/0/a.csv
/storage/emulated/0/a.csv: open failed: EACCES (Permission denied)
java.io.FileNotFoundException: /storage/emulated/0/a.csv: open failed: EACCES (Permission denied)
    at libcore.io.IoBridge.open(IoBridge.java:452)
    at java.io.FileInputStream.<init>(FileInputStream.java:76)
    at java.io.FileInputStream.<init>(FileInputStream.java:103)
    at android.content.ContentResolver.openInputStream(ContentResolver.java:662)
    at com.fr3ts0n.stagefever.MainActivity.onActivityResult(MainActivity.java:185)
    at android.app.Activity.dispatchActivityResult(Activity.java:6456)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:3729)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3776)
    at android.app.ActivityThread.-wrap16(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5461)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
    at libcore.io.Posix.open(Native Method)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
    at libcore.io.IoBridge.open(IoBridge.java:438)
    ... 15 more
fr3ts0n commented 7 years ago

The permissions to read/write external storage are set in the Manifest, so reading a CSV from SD card usually works.

However, it is definitely missing permissions on the file, which leads me to some questions:

Please could you also post the output of following command on adb command line

ls -l /storage/emulated/0/

Thx

ghost commented 7 years ago

I have Android 6 and all files permissions on /sdcard are: -rw-rw---- (AFAIR, /sdcard has FAT which doesn't have permissions so are set/masked by the system during mount and cannot be changed).

The 2nd answer from https://stackoverflow.com/questions/8854359/exception-open-failed-eacces-permission-denied-on-android could be relevant:

For API 23+ you need to request the read/write permissions even if they are already in your manifest.

What do you think?

ghost commented 7 years ago
-rw-rw----  1 root sdcard_rw   12 2016-12-01 01:42 a.csv

(created with Android's text editor)

(there's no real SD card in my phone, it's all internal memory)

fr3ts0n commented 7 years ago

This should be fixed now with the latest commit.

Unfortunately I don't have any Android 6+ device available for testing. Do you have a chance to build from the sources and test it?

ghost commented 7 years ago

I get the following exception when pressing the search icon:

AndroidRuntime: FATAL EXCEPTION: main
AndroidRuntime: Process: com.fr3ts0n.stagefever, PID: 14821
AndroidRuntime: android.os.FileUriExposedException: file:///storage/emulated/0/com.fr3ts0n.stagefever exposed beyond app through Intent.getData()
AndroidRuntime:     at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
AndroidRuntime:     at android.net.Uri.checkFileUriExposed(Uri.java:2346)
AndroidRuntime:     at android.content.Intent.prepareToLeaveProcess(Intent.java:8981)
AndroidRuntime:     at android.content.Intent.prepareToLeaveProcess(Intent.java:8942)
AndroidRuntime:     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1519)
AndroidRuntime:     at android.app.Activity.startActivityForResult(Activity.java:4225)
AndroidRuntime:     at android.app.Activity.startActivityForResult(Activity.java:4183)
AndroidRuntime:     at com.fr3ts0n.stagefever.MainActivity.selectFileToLoad(MainActivity.java:189)
AndroidRuntime:     at com.fr3ts0n.stagefever.MainActivity.onOptionsItemSelected(MainActivity.java:162)
AndroidRuntime:     at android.app.Activity.onMenuItemSelected(Activity.java:3204)
AndroidRuntime:     at com.android.internal.policy.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1215)
AndroidRuntime:     at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:761)
AndroidRuntime:     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
AndroidRuntime:     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:904)
AndroidRuntime:     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:894)
AndroidRuntime:     at android.widget.ActionMenuView.invokeItem(ActionMenuView.java:616)
AndroidRuntime:     at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:152)
AndroidRuntime:     at android.view.View.performClick(View.java:5637)
AndroidRuntime:     at android.view.View$PerformClick.run(View.java:22433)
AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:751)
AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
AndroidRuntime:     at android.os.Looper.loop(Looper.java:154)
AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:6126)
AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
ActivityManager:   Force finishing activity com.fr3ts0n.stagefever/.MainActivity
ghost commented 7 years ago

I was wandering if it would be useful to use an emulator to test the program on Android M or N.

ghost commented 7 years ago

I don't have SDK setup to build the app from the source. I'm not sure, if I know how to do it.

fr3ts0n commented 7 years ago

Yes, they changed quite a bit in the file management. I will be able to emulate Android >= M after Christmas (with a new PC)

ghost commented 7 years ago

Thank your for fixing it!