Skip to content

Android: storage.List(uri) call results in crash when permission has expired #6117

@MaxGyver83

Description

@MaxGyver83

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

This line runs fine on my Android device right after selecting a folder with dialog.ShowFolderOpen:

filelist, err := storage.List(uri)

But when I store the folder URI (in the app preferences) and try opening the folder again after an app restart, it crashes because of a missing permission:

02-18 15:39:20.403  1702  1987 W ContentProviderHelper: Permission Denial: opening provider com.android.externalstorage.ExternalStorageProvider from ProcessRecord{213a2b6 5506:com.goodtemperapps.markdownviewer/u0a639} (pid=5506, uid=10639) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
02-18 15:39:20.415  5506 17072 F .markdownviewer: java_vm_ext.cc:616] JNI DETECTED ERROR IN APPLICATION: JNI GetObjectClass called with pending exception java.lang.SecurityException: Permission Denial: opening provider com.android.externalstorage.ExternalStorageProvider from ProcessRecord{213a2b6 5506:com.goodtemperapps.markdownviewer/u0a639} (pid=5506, uid=10639) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs

I expect that the function returns err != nil in such a case.

How to reproduce

  1. Pick folder with dialog.ShowFolderOpen.
  2. Read content with storage.List(uri).
  3. Store uri in preferences.
  4. Restart app.
  5. Load preferences.
  6. Call storage.List(uri).

Screenshots

No response

Example code

I'll try to add a minimal app to reproduce this crash.

Fyne version

develop branch

Go compiler version

go1.25.7

Operating system and version

Arch Linux

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions