mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-18 17:03:56 +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.
62 lines
2.0 KiB
Kotlin
62 lines
2.0 KiB
Kotlin
package app.revanced.patcher.patch
|
|
|
|
import app.revanced.patcher.PatchClass
|
|
import app.revanced.patcher.Patcher
|
|
import app.revanced.patcher.data.BytecodeContext
|
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
|
import java.io.Closeable
|
|
|
|
/**
|
|
* A [Patch] that accesses a [BytecodeContext].
|
|
*
|
|
* If an implementation of [Patch] also implements [Closeable]
|
|
* it will be closed in reverse execution order of patches executed by [Patcher].
|
|
*/
|
|
@Suppress("unused")
|
|
abstract class BytecodePatch : Patch<BytecodeContext> {
|
|
/**
|
|
* The fingerprints to resolve before executing the patch.
|
|
*/
|
|
internal val fingerprints: Set<MethodFingerprint>
|
|
|
|
/**
|
|
* Create a new [BytecodePatch].
|
|
*
|
|
* @param fingerprints The fingerprints to resolve before executing the patch.
|
|
*/
|
|
constructor(fingerprints: Set<MethodFingerprint> = emptySet()) {
|
|
this.fingerprints = fingerprints
|
|
}
|
|
|
|
/**
|
|
* Create a new [BytecodePatch].
|
|
*
|
|
* @param name The name of the patch.
|
|
* @param description The description of the patch.
|
|
* @param compatiblePackages The packages the patch is compatible with.
|
|
* @param dependencies Other patches this patch depends on.
|
|
* @param use Weather or not the patch should be used.
|
|
* @param requiresIntegrations Weather or not the patch requires integrations.
|
|
*/
|
|
constructor(
|
|
name: String? = null,
|
|
description: String? = null,
|
|
compatiblePackages: Set<CompatiblePackage>? = null,
|
|
dependencies: Set<PatchClass>? = null,
|
|
use: Boolean = true,
|
|
requiresIntegrations: Boolean = false,
|
|
fingerprints: Set<MethodFingerprint> = emptySet(),
|
|
) : super(name, description, compatiblePackages, dependencies, use, requiresIntegrations) {
|
|
this.fingerprints = fingerprints
|
|
}
|
|
|
|
/**
|
|
* Create a new [BytecodePatch].
|
|
*/
|
|
@Deprecated(
|
|
"Use the constructor with fingerprints instead.",
|
|
ReplaceWith("BytecodePatch(emptySet())"),
|
|
)
|
|
constructor() : this(emptySet())
|
|
}
|