mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-06-13 05:37:38 +02:00

BREAKING CHANGE: various changes in which packages classes previously where and their implementation
44 lines
1.2 KiB
Kotlin
44 lines
1.2 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
|
|
|
|
/**
|
|
* 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> : Closeable {
|
|
/**
|
|
* 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): PatchResult
|
|
|
|
/**
|
|
* The closing function for this patch.
|
|
*
|
|
* This can be treated like popping the patch from the current patch stack.
|
|
*/
|
|
override fun close() {}
|
|
}
|
|
|
|
/**
|
|
* 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> |