Skip to content

Comments

feat: Migrate option file selector to SAF#2953

Open
X1nto wants to merge 8 commits intoReVanced:devfrom
X1nto:compose/saf
Open

feat: Migrate option file selector to SAF#2953
X1nto wants to merge 8 commits intoReVanced:devfrom
X1nto:compose/saf

Conversation

@X1nto
Copy link

@X1nto X1nto commented Feb 19, 2026

This gets rid of external file access requirements by moving the patcher options path selector to Storage Access Framework. Because of this change, it has become necessary to 1) separate folder and file selector actions and 2) copy selected folder/file to the app's internal storage. Internal storage refers to Filesystem.tempDir.

androidx.documentfile was added to handle SAF and everything related to external storage permissions have been removed.

screen-20260219-230118.mp4

@X1nto X1nto changed the title chore: Migrate option file selector to SAF feat: Migrate option file selector to SAF Feb 19, 2026
@oSumAtrIX
Copy link
Member

If we exit the app does it remove these files?

@Ushie
Copy link
Member

Ushie commented Feb 19, 2026

Yes, it's stored in the same place as the temporary files generated for patcher

Copy link
Member

@Axelen123 Axelen123 left a comment

Choose a reason for hiding this comment

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

The temporary files will be gone after an app restart and won't be present if manager attempts to use saved patch options. This is partly why I chose not to use SAF when implementing patch options.

@X1nto X1nto requested a review from Axelen123 February 21, 2026 15:12
work-runtime-ktx = { group = "androidx.work", name = "work-runtime-ktx", version.ref = "work-runtime" }
preferences-datastore = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "preferences-datastore" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
documentfile = { group = "androidx.documentfile", name = "documentfile", version.ref="documentfile" }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
documentfile = { group = "androidx.documentfile", name = "documentfile", version.ref="documentfile" }
documentfile = { group = "androidx.documentfile", name = "documentfile", version.ref = "documentfile" }

@Axelen123
Copy link
Member

Axelen123 commented Feb 21, 2026

@X1nto app restarts still need to be handled, since the temporary directory will be cleared on restarts. To fix this, you could:

  • Create a new data class for holding the SAF URI (and whether or not it is a folder). The data class probably needs to be java.io.Serializable and/or Parcelable.
  • Change StringOptionEditor to : OptionEditor<Any>.
  • Set it to a string whenever a string is specified and the custom type otherwise.
  • In Options.kt, define and implement a json object representation for the custom type whenever a patch option with the string type is encountered. The SAF URI will be valid even after a restart and can be persisted in the database.
  • Move the SAF copying logic and transform the custom types into strings right before passing the options to runtime.execute in PatcherWorker.kt

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.

4 participants