mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-24 11:41:02 +00:00
This commit allows reading and writing arbitrary files in an APK file. Additionally it allows deleting files from APK files. A `RawResourcePatch` class has been added which has access to `ResourceContext` but ReVanced Patcher will not decode APK resources. A regular `ResourcePatch` can read and write arbitrary files from an APK file, unless they are decoded to `PatcherConfig.apkFiles`. On attempt to get a file from `PatcherConfig.apkFiles` if the second parameter is true, it will read and write the raw resource file from the original APK to `PatcherConfig.apkFiles` if it does not exist. With this commit, many APIs have been deprecated as well, such as `DomFileEditor` and instead a `Document` has been added.
29 lines
803 B
Kotlin
29 lines
803 B
Kotlin
package app.revanced.patcher.patch
|
|
|
|
import app.revanced.patcher.data.ResourceContext
|
|
import kotlin.test.Test
|
|
import app.revanced.patcher.patch.annotation.Patch as PatchAnnotation
|
|
|
|
object PatchInitializationTest {
|
|
@Test
|
|
fun `initialize using constructor`() {
|
|
val patch =
|
|
object : RawResourcePatch(name = "Resource patch test") {
|
|
override fun execute(context: ResourceContext) {}
|
|
}
|
|
|
|
assert(patch.name == "Resource patch test")
|
|
}
|
|
|
|
@Test
|
|
fun `initialize using annotation`() {
|
|
val patch =
|
|
@PatchAnnotation("Resource patch test")
|
|
object : RawResourcePatch() {
|
|
override fun execute(context: ResourceContext) {}
|
|
}
|
|
|
|
assert(patch.name == "Resource patch test")
|
|
}
|
|
}
|