mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-01 13:44:25 +02:00
Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
09f6ab4155
14
CHANGELOG.md
14
CHANGELOG.md
@ -1,3 +1,17 @@
|
|||||||
|
## [3.3.1](https://github.com/revanced/revanced-patcher/compare/v3.3.0...v3.3.1) (2022-08-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* revert soft dependencies ([7b2d058](https://github.com/revanced/revanced-patcher/commit/7b2d058144b0718992d329731e2af7cc704e4370))
|
||||||
|
|
||||||
|
# [3.3.0](https://github.com/revanced/revanced-patcher/compare/v3.2.1...v3.3.0) (2022-08-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add getValue & setValue for PatchOption ([2572cd0](https://github.com/revanced/revanced-patcher/commit/2572cd04b5da4eeae738c8dde31493177edf0bf8))
|
||||||
|
|
||||||
## [3.2.1](https://github.com/revanced/revanced-patcher/compare/v3.2.0...v3.2.1) (2022-08-02)
|
## [3.2.1](https://github.com/revanced/revanced-patcher/compare/v3.2.0...v3.2.1) (2022-08-02)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 3.2.1
|
version = 3.3.1
|
||||||
|
@ -262,16 +262,15 @@ class Patcher(private val options: PatcherOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// recursively apply all dependency patches
|
// recursively apply all dependency patches
|
||||||
patch.dependencies.forEach {
|
patch.dependencies?.forEach {
|
||||||
val dependency = it.patch.java
|
val patchDependency = it.java
|
||||||
|
|
||||||
|
val result = applyPatch(patchDependency, appliedPatches)
|
||||||
|
|
||||||
val result = applyPatch(dependency, appliedPatches)
|
|
||||||
if (result.isSuccess()) return@forEach
|
if (result.isSuccess()) return@forEach
|
||||||
|
|
||||||
val error = result.error()!!
|
val errorMessage = result.error()!!.cause
|
||||||
val errorMessage = error.cause ?: error.message
|
return PatchResultError("'$patchName' depends on '${patchDependency.patchName}' but the following error was raised: $errorMessage")
|
||||||
|
|
||||||
return PatchResultError("'$patchName' depends on '${dependency.patchName}' but the following error was raised: $errorMessage")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val patchInstance = patch.getDeclaredConstructor().newInstance()
|
val patchInstance = patch.getDeclaredConstructor().newInstance()
|
||||||
|
@ -7,9 +7,6 @@ import app.revanced.patcher.annotation.Version
|
|||||||
import app.revanced.patcher.data.Data
|
import app.revanced.patcher.data.Data
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import app.revanced.patcher.patch.Patch
|
import app.revanced.patcher.patch.Patch
|
||||||
import app.revanced.patcher.patch.annotations.Dependencies
|
|
||||||
import app.revanced.patcher.patch.annotations.DependencyType
|
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,26 +35,20 @@ private fun <T : Annotation> Class<*>.findAnnotationRecursively(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private typealias PatchClass = Class<out Patch<Data>>
|
|
||||||
|
|
||||||
object PatchExtensions {
|
object PatchExtensions {
|
||||||
val PatchClass.patchName: String get() = recursiveAnnotation(Name::class)?.name ?: this.javaClass.simpleName
|
val Class<out Patch<Data>>.patchName: String
|
||||||
val PatchClass.version get() = recursiveAnnotation(Version::class)?.version
|
get() = recursiveAnnotation(Name::class)?.name ?: this.javaClass.simpleName
|
||||||
val PatchClass.include get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.Patch::class)!!.include
|
val Class<out Patch<Data>>.version get() = recursiveAnnotation(Version::class)?.version
|
||||||
val PatchClass.description get() = recursiveAnnotation(Description::class)?.description
|
val Class<out Patch<Data>>.include get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.Patch::class)!!.include
|
||||||
val PatchClass.dependencies get() = buildList {
|
val Class<out Patch<Data>>.description get() = recursiveAnnotation(Description::class)?.description
|
||||||
recursiveAnnotation(DependsOn::class)?.let { add(PatchDependency(it.value, it.type)) }
|
val Class<out Patch<Data>>.dependencies get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.DependsOn::class)?.dependencies
|
||||||
recursiveAnnotation(Dependencies::class)?.dependencies?.forEach { add(PatchDependency(it, DependencyType.HARD)) }
|
val Class<out Patch<Data>>.compatiblePackages get() = recursiveAnnotation(Compatibility::class)?.compatiblePackages
|
||||||
}.toTypedArray()
|
|
||||||
val PatchClass.compatiblePackages get() = recursiveAnnotation(Compatibility::class)?.compatiblePackages
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun PatchClass.dependsOn(patch: PatchClass): Boolean {
|
fun Class<out Patch<Data>>.dependsOn(patch: Class<out Patch<Data>>): Boolean {
|
||||||
if (this.patchName == patch.patchName) throw IllegalArgumentException("thisval and patch may not be the same")
|
if (this.patchName == patch.patchName) throw IllegalArgumentException("thisval and patch may not be the same")
|
||||||
return this.dependencies.any { it.patch.java.patchName == this@dependsOn.patchName }
|
return this.dependencies?.any { it.java.patchName == this@dependsOn.patchName } == true
|
||||||
}
|
}
|
||||||
|
|
||||||
class PatchDependency internal constructor(val patch: KClass<out Patch<Data>>, val type: DependencyType = DependencyType.HARD)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object MethodFingerprintExtensions {
|
object MethodFingerprintExtensions {
|
||||||
|
@ -19,29 +19,6 @@ annotation class Patch(val include: Boolean = true)
|
|||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
@MustBeDocumented
|
@MustBeDocumented
|
||||||
@Deprecated(
|
|
||||||
"Does not support new parameter 'type'",
|
|
||||||
ReplaceWith("DependsOn")
|
|
||||||
)
|
|
||||||
annotation class Dependencies(
|
|
||||||
val dependencies: Array<KClass<out Patch<Data>>> = []
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation for dependencies of [Patch]es .
|
|
||||||
*/
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
|
||||||
@MustBeDocumented
|
|
||||||
@Repeatable
|
|
||||||
annotation class DependsOn(
|
annotation class DependsOn(
|
||||||
val value: KClass<out Patch<Data>>,
|
val dependencies: Array<KClass<out Patch<Data>>> = []
|
||||||
val type: DependencyType = DependencyType.HARD
|
)
|
||||||
)
|
|
||||||
|
|
||||||
enum class DependencyType {
|
|
||||||
/**
|
|
||||||
* Enforces that the dependency is applied, even if it was not selected.
|
|
||||||
*/
|
|
||||||
HARD
|
|
||||||
}
|
|
@ -11,7 +11,6 @@ import app.revanced.patcher.patch.PatchOption
|
|||||||
import app.revanced.patcher.patch.PatchOptions
|
import app.revanced.patcher.patch.PatchOptions
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependencyType
|
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patcher.patch.impl.BytecodePatch
|
import app.revanced.patcher.patch.impl.BytecodePatch
|
||||||
@ -39,7 +38,7 @@ import org.jf.dexlib2.util.Preconditions
|
|||||||
@Description("Example demonstration of a bytecode patch.")
|
@Description("Example demonstration of a bytecode patch.")
|
||||||
@ExampleResourceCompatibility
|
@ExampleResourceCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
@DependsOn(ExampleBytecodePatch::class, DependencyType.HARD)
|
@DependsOn([ExampleBytecodePatch::class])
|
||||||
class ExampleBytecodePatch : BytecodePatch(listOf(ExampleFingerprint)) {
|
class ExampleBytecodePatch : BytecodePatch(listOf(ExampleFingerprint)) {
|
||||||
// This function will be executed by the patcher.
|
// This function will be executed by the patcher.
|
||||||
// You can treat it as a constructor
|
// You can treat it as a constructor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user