mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 01:01:56 +01:00
fix: migrate patches to latest patcher api changes
This commit is contained in:
parent
603680f10f
commit
8a0ee03a71
14 changed files with 65 additions and 18 deletions
|
@ -25,7 +25,7 @@ repositories {
|
|||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.21")
|
||||
|
||||
implementation("app.revanced:revanced-patcher:1.0.0-dev.16")
|
||||
implementation("app.revanced:revanced-patcher:1.0.0-dev.17")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.21")
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ class CodecsUnlockPatch : BytecodePatch(
|
|||
val instructionIndex = result.scanResult.startIndex
|
||||
|
||||
result = signatures.last().result!!
|
||||
val codecMethod = data.toMethodWalker(result.immutableMethod).walk(result.scanResult.startIndex).getMethod()
|
||||
val codecMethod =
|
||||
data.toMethodWalker(result.immutableMethod).nextMethod(result.scanResult.startIndex).getMethod()
|
||||
|
||||
implementation.replaceInstruction(
|
||||
instructionIndex,
|
||||
|
|
|
@ -6,8 +6,8 @@ import app.revanced.patcher.annotation.Name
|
|||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.implementation.BytecodeData
|
||||
import app.revanced.patcher.data.implementation.toMethodWalker
|
||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResultError
|
||||
|
@ -23,7 +23,7 @@ import org.jf.dexlib2.AccessFlags
|
|||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction11x
|
||||
|
||||
@Patch
|
||||
//@Patch(dependencies = [IntegrationsPatch::class])
|
||||
@Name("home-promo-ads")
|
||||
@Description("Patch to remove promoted ads in YouTube.")
|
||||
@PromotionsCompatibility
|
||||
|
@ -47,14 +47,14 @@ class PromotionsPatch : BytecodePatch(
|
|||
val toBePatchedInvokeOffset =
|
||||
requiredMethod.immutableMethod.implementation!!.instructions.indexOfFirst { it.opcode == Opcode.INVOKE_DIRECT }
|
||||
val toBePatchedMethod =
|
||||
data.toMethodWalker(requiredMethod.immutableMethod).walk(toBePatchedInvokeOffset, true)
|
||||
data.toMethodWalker(requiredMethod.immutableMethod).nextMethod(toBePatchedInvokeOffset, true)
|
||||
.getMethod() as MutableMethod
|
||||
|
||||
val implementation = toBePatchedMethod.implementation!!
|
||||
val invokeVirtualOffset = implementation.instructions.indexOfFirst { it.opcode == Opcode.INVOKE_VIRTUAL }
|
||||
|
||||
val moveResultInstruction = implementation.instructions[invokeVirtualOffset + 1]
|
||||
if (moveResultInstruction.opcode != Opcode.MOVE_RESULT_OBJECT) return PatchResultError("The toBePatchedInvokeOffset offset was wrong in ${(this::class.annotations.find { it is Name } as Name).name}")
|
||||
if (moveResultInstruction.opcode != Opcode.MOVE_RESULT_OBJECT) return PatchResultError("The toBePatchedInvokeOffset offset was wrong in ${this.javaClass.patchName}")
|
||||
|
||||
val register = (moveResultInstruction as Instruction11x).registerA
|
||||
implementation.injectHideCall(invokeVirtualOffset + 2, register)
|
||||
|
|
|
@ -17,9 +17,10 @@ import app.revanced.patcher.signature.implementation.method.annotation.MatchingM
|
|||
import app.revanced.patcher.util.smali.toInstructions
|
||||
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
|
||||
import app.revanced.patches.youtube.ad.video.signatures.ShowVideoAdsConstructorSignature
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
@Patch
|
||||
@Patch(dependencies = [IntegrationsPatch::class])
|
||||
@Name("video-ads")
|
||||
@Description("Patch to remove ads in the YouTube video player.")
|
||||
@VideoAdsCompatibility
|
||||
|
@ -37,7 +38,6 @@ class VideoAdsPatch : BytecodePatch(
|
|||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("Z"), null
|
||||
) {}) ?: return PatchResultError("Required parent method could not be found.")
|
||||
|
||||
|
||||
// Override the parameter by calling shouldShowAds and setting the parameter to the result
|
||||
result.method.implementation!!.addInstructions(
|
||||
0, """
|
||||
|
|
|
@ -14,6 +14,7 @@ import app.revanced.patcher.util.smali.toInstructions
|
|||
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility
|
||||
import app.revanced.patches.youtube.interaction.seekbar.signatures.SeekbarTappingParentSignature
|
||||
import app.revanced.patches.youtube.interaction.seekbar.signatures.SeekbarTappingSignature
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
|
||||
import org.jf.dexlib2.iface.Method
|
||||
|
@ -21,7 +22,7 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction11n
|
|||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||
|
||||
|
||||
@Patch
|
||||
@Patch(dependencies = [IntegrationsPatch::class])
|
||||
@Name("seekbar-tapping")
|
||||
@Description("Enable tapping on the seekbar of the YouTube player.")
|
||||
@SeekbarTappingCompatibility
|
||||
|
|
|
@ -9,10 +9,15 @@ import app.revanced.patcher.patch.implementation.ResourcePatch
|
|||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||
import app.revanced.patches.youtube.layout.amoled.annotations.AmoledCompatibility
|
||||
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
|
||||
import org.w3c.dom.Element
|
||||
import java.io.File
|
||||
|
||||
@Patch
|
||||
@Patch(
|
||||
dependencies = [
|
||||
FixLocaleConfigErrorPatch::class
|
||||
]
|
||||
)
|
||||
@Name("amoled")
|
||||
@Description("Enables pure black theme.")
|
||||
@AmoledCompatibility
|
||||
|
|
|
@ -12,10 +12,11 @@ import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
|||
import app.revanced.patcher.util.smali.toInstruction
|
||||
import app.revanced.patches.youtube.layout.createbutton.annotations.CreateButtonCompatibility
|
||||
import app.revanced.patches.youtube.layout.createbutton.signatures.CreateButtonSignature
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||
|
||||
@Patch
|
||||
@Patch(dependencies = [IntegrationsPatch::class])
|
||||
@Name("disable-create-button")
|
||||
@Description("Disable the create button.")
|
||||
@CreateButtonCompatibility
|
||||
|
|
|
@ -19,7 +19,6 @@ import app.revanced.patches.youtube.layout.minimizedplayback.signatures.Minimize
|
|||
@Description("Enable minimized and background playback.")
|
||||
@MinimizedPlaybackCompatibility
|
||||
@Version("0.0.1")
|
||||
|
||||
class MinimizedPlaybackPatch : BytecodePatch(
|
||||
listOf(
|
||||
MinimizedPlaybackManagerSignature
|
||||
|
|
|
@ -17,11 +17,12 @@ import app.revanced.patcher.signature.implementation.method.annotation.MatchingM
|
|||
import app.revanced.patcher.util.smali.toInstructions
|
||||
import app.revanced.patches.youtube.layout.oldqualitylayout.annotations.OldQualityLayoutCompatibility
|
||||
import app.revanced.patches.youtube.layout.oldqualitylayout.signatures.OldQualityParentSignature
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
|
||||
|
||||
@Patch
|
||||
@Patch(dependencies = [IntegrationsPatch::class])
|
||||
@Name("old-quality-layout")
|
||||
@Description("Enable the original quality flyout menu.")
|
||||
@OldQualityLayoutCompatibility
|
||||
|
|
|
@ -12,9 +12,10 @@ import app.revanced.patcher.util.smali.toInstruction
|
|||
import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility
|
||||
import app.revanced.patches.youtube.layout.shorts.button.signatures.PivotBarButtonTabenumSignature
|
||||
import app.revanced.patches.youtube.layout.shorts.button.signatures.PivotBarButtonsViewSignature
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction11x
|
||||
|
||||
@Patch
|
||||
@Patch(dependencies = [IntegrationsPatch::class])
|
||||
@Name("shorts-button")
|
||||
@Description("Hide the shorts button.")
|
||||
@ShortsButtonCompatibility
|
||||
|
|
|
@ -6,9 +6,9 @@ import app.revanced.patcher.annotation.Version
|
|||
import app.revanced.patcher.data.implementation.BytecodeData
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResultError
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||
import app.revanced.patcher.util.smali.toInstructions
|
||||
|
@ -18,7 +18,6 @@ import org.jf.dexlib2.AccessFlags
|
|||
import org.jf.dexlib2.immutable.ImmutableMethod
|
||||
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
|
||||
|
||||
@Patch
|
||||
@Name("integrations")
|
||||
@Description("Applies mandatory patches to implement the ReVanced integrations into the application.")
|
||||
@IntegrationsCompatibility
|
||||
|
@ -29,6 +28,9 @@ class IntegrationsPatch : BytecodePatch(
|
|||
)
|
||||
) {
|
||||
override fun execute(data: BytecodeData): PatchResult {
|
||||
if (data.findClass("Lapp/revanced/integrations/Globals") == null)
|
||||
return PatchResultError("Integrations have not been merged yet. This patch can not succeed without the integrations.")
|
||||
|
||||
val result = signatures.first().result!!
|
||||
|
||||
val implementation = result.method.implementation!!
|
||||
|
|
|
@ -4,14 +4,12 @@ import app.revanced.patcher.annotation.Description
|
|||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.implementation.ResourceData
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.patch.implementation.ResourcePatch
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||
import app.revanced.patches.youtube.misc.manifest.annotations.FixLocaleConfigErrorCompatibility
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@Patch
|
||||
@Name("locale-config-fix")
|
||||
@Description("Fix an error when building the resources by patching the manifest file.")
|
||||
@FixLocaleConfigErrorCompatibility
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package app.revanced.patches.youtube.misc.mapping.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.implementation.ResourceData
|
||||
import app.revanced.patcher.patch.implementation.ResourcePatch
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||
import app.revanced.patches.youtube.ad.general.resource.util.Extensions.doRecursively
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@Name("resource-id-mapping-provider-resource-patch-dependency")
|
||||
@Description("This patch works as a acts as a provider for resources mapped to their ids.")
|
||||
@Version("0.0.1")
|
||||
class ResourceIdMappingProviderResourcePatch : ResourcePatch() {
|
||||
companion object {
|
||||
internal lateinit var resourceMappings: Map<String, Long>
|
||||
private set
|
||||
}
|
||||
|
||||
override fun execute(data: ResourceData): PatchResult {
|
||||
data.getXmlEditor("res/values/public.xml").use { editor ->
|
||||
resourceMappings = buildMap {
|
||||
editor.file.documentElement.doRecursively { node ->
|
||||
if (node !is Element) return@doRecursively
|
||||
val nameAttribute = node.getAttribute("name")
|
||||
if (node.nodeName != "public" || nameAttribute.startsWith("APKTOOL")) return@doRecursively
|
||||
this[nameAttribute] = node.getAttribute("id").substring(2).toLong(16)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
|
@ -135,11 +135,13 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||
const/4 v0, 0x0
|
||||
return-object v0
|
||||
"""
|
||||
|
||||
'V' -> "return-void"
|
||||
'I' -> """
|
||||
const/4 v0, 0x0
|
||||
return v0
|
||||
"""
|
||||
|
||||
else -> throw Exception("This case should never happen.")
|
||||
}
|
||||
result.method.implementation!!.addInstructions(
|
||||
|
|
Loading…
Reference in a new issue