Skip to content

fix(fileprovider): add external-path for Download/Kizzy to prevent crash#456

Merged
dead8309 merged 1 commit intodead8309:masterfrom
fann22:master
Oct 23, 2025
Merged

fix(fileprovider): add external-path for Download/Kizzy to prevent crash#456
dead8309 merged 1 commit intodead8309:masterfrom
fann22:master

Conversation

@fann22
Copy link
Contributor

@fann22 fann22 commented Oct 23, 2025

Fix FileProvider crash when exporting custom RPC config

Summary

This PR fixes a crash that occurs on Android 13 and above when exporting a custom RPC configuration file located under Download/Kizzy/.
FileProvider was not configured to expose external Download/ paths, leading to an IllegalArgumentException when generating a content:// URI.

Root cause

Starting from Android 13, scoped storage enforcement became stricter.
FileProvider only allows sharing files from roots explicitly declared in res/xml/provider_paths.xml.

Since /storage/emulated/0/Download/Kizzy/<name>.json was outside the configured roots (which only included files-path), the system threw:

IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Download/Kizzy/<name>.json

Changes

  • Added <external-path name="downloads" path="Download/" /> to res/xml/provider_paths.xml to allow sharing files from Download/ and its subdirectories (including Download/Kizzy/).
  • This resolves the crash occurring when exporting or sharing custom RPC config files.

provider_paths.xml (updated)

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path
        name="files"
        path="." />
    <!-- Allow sharing files inside Download/ (includes Download/Kizzy/) -->
    <external-path
        name="downloads"
        path="Download/" />
</paths>

@dead8309 dead8309 requested a review from Copilot October 23, 2025 09:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a crash occurring on Android 13+ when exporting custom RPC configuration files to the Download/Kizzy/ directory. The crash was caused by FileProvider not being configured to expose external download paths, resulting in an IllegalArgumentException when attempting to generate content URIs for these files.

Key Changes:

  • Added external-path configuration to provider_paths.xml to allow sharing files from the Download/ directory and its subdirectories

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

name="files"
path="." />

<external-path
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The external-path element exposes the entire Download/ directory and all its subdirectories to other apps through FileProvider. This creates a broad security surface since any file placed in Download/ can now be shared via content URIs. Consider using external-files-path with getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) instead, which provides app-specific external storage that doesn't require broad access permissions and is automatically cleaned up when the app is uninstalled.

Suggested change
<external-path
<external-files-path

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About Copilot’s suggestion to use <external-files-path>

This app intentionally uses <external-path path="Download/" /> because the exported files (custom RPC configs) are meant to be directly accessible by the user in the public Download/Kizzy/ directory.
The main goal of this feature is to let users easily locate, edit, or share their exported configuration without needing developer tools or special file access.

Using <external-files-path> would place the file inside /Android/data/<package>/files/Download/, which is not visible to most file managers on Android 11+ due to scoped storage restrictions.
That would make the “Export Config” feature confusing and effectively unusable for end users.

The chosen implementation limits access to the Download/ directory only (and its subdirectories), which is acceptable for user-generated exports and does not expose sensitive app data.

In short, this is a deliberate design choice prioritizing user accessibility over isolation, within a controlled and predictable export path.

@dead8309
Copy link
Owner

we don't have any plans to publish the app on playstore as of now, so I'm merging this. You can skip the copilot review

@dead8309 dead8309 merged commit bdb8826 into dead8309:master Oct 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants