mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-03 14:14:26 +02:00
test: use findClass with className & cleanup
This commit is contained in:
parent
4087f49863
commit
a1b6b06bd3
@ -36,11 +36,11 @@ fun main() {
|
|||||||
signatures
|
signatures
|
||||||
)
|
)
|
||||||
|
|
||||||
val mainMethodPatchViaClassProxy = object : Patch("main-method-patch-via-proxy") {
|
patcher.addPatches(
|
||||||
|
object : Patch("main-method-patch-via-proxy") {
|
||||||
override fun execute(cache: Cache): PatchResult {
|
override fun execute(cache: Cache): PatchResult {
|
||||||
val proxy = cache.findClass { classDef ->
|
val proxy = cache.findClass("XAdRemover")
|
||||||
classDef.type.contains("XAdRemover")
|
?: return PatchResultError("Class 'XAdRemover' could not be found")
|
||||||
} ?: return PatchResultError("Class 'XAdRemover' could not be found")
|
|
||||||
|
|
||||||
val xAdRemoverClass = proxy.resolve()
|
val xAdRemoverClass = proxy.resolve()
|
||||||
val hideReelMethod = xAdRemoverClass.methods.single { method -> method.name.contains("HideReel") }
|
val hideReelMethod = xAdRemoverClass.methods.single { method -> method.name.contains("HideReel") }
|
||||||
@ -73,20 +73,18 @@ fun main() {
|
|||||||
)
|
)
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
object : Patch("main-method-patch-via-signature") {
|
||||||
val mainMethodPatchViaSignature = object : Patch("main-method-patch-via-signature") {
|
|
||||||
override fun execute(cache: Cache): PatchResult {
|
override fun execute(cache: Cache): PatchResult {
|
||||||
val mainMethodMap = cache.resolvedMethods["main-method"]
|
val mainMethodMap = cache.resolvedMethods["main-method"]
|
||||||
mainMethodMap.definingClassProxy.immutableClass.methods.single { method ->
|
mainMethodMap.definingClassProxy.immutableClass.methods.single { method ->
|
||||||
method.name == mainMethodMap.resolvedMethodName
|
method.name == mainMethodMap.resolvedMethodName
|
||||||
}
|
}
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
patcher.addPatches(mainMethodPatchViaClassProxy, mainMethodPatchViaSignature)
|
|
||||||
patcher.applyPatches()
|
patcher.applyPatches()
|
||||||
patcher.save()
|
patcher.save()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user