mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-29 14:11:03 +00:00
This commit introduces a couple changes besides the refactor. Executing patches can be cancelled, multiple bundles loaded into the same class loader and `Patch.execute` does not have to return anymore. BREAKING CHANGE: Various public APIs have been changed. The `Version` annotation has been removed. Patches do not return anything anymore and instead throw `PatchException`. Multiple patch bundles can now be loaded in a single ClassLoader to bypass class loader isolation.
39 lines
1.1 KiB
Kotlin
39 lines
1.1 KiB
Kotlin
package app.revanced.patcher.patch
|
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
|
import app.revanced.patcher.data.Context
|
|
import app.revanced.patcher.data.ResourceContext
|
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
import java.io.Closeable
|
|
|
|
typealias PatchClass = Class<out Patch<Context<*>>>
|
|
|
|
/**
|
|
* A ReVanced patch.
|
|
*
|
|
* If it implements [Closeable], it will be closed after all patches have been executed.
|
|
* Closing will be done in reverse execution order.
|
|
*/
|
|
sealed interface Patch<out T : Context<*>> {
|
|
/**
|
|
* The main function of the [Patch] which the patcher will call.
|
|
*
|
|
* @param context The [Context] the patch will work on.
|
|
* @return The result of executing the patch.
|
|
*/
|
|
fun execute(context: @UnsafeVariance T)
|
|
}
|
|
|
|
/**
|
|
* Resource patch for the Patcher.
|
|
*/
|
|
interface ResourcePatch : Patch<ResourceContext>
|
|
|
|
/**
|
|
* Bytecode patch for the Patcher.
|
|
*
|
|
* @param fingerprints A list of [MethodFingerprint] this patch relies on.
|
|
*/
|
|
abstract class BytecodePatch(
|
|
internal val fingerprints: Iterable<MethodFingerprint>? = null
|
|
) : Patch<BytecodeContext> |