From 0acdf89ae91f109ebcfa7496ec094df670066151 Mon Sep 17 00:00:00 2001 From: Lucaskyy Date: Thu, 14 Apr 2022 12:11:24 +0200 Subject: [PATCH] refactor: make patches compatible with breaking changes of the patcher also commented HideSuggestionsPatch.kt so warnings suppressed --- .../app/revanced/patches/ad/VideoAdsPatch.kt | 6 +++--- .../interaction/EnableSeekbarTappingPatch.kt | 8 ++++---- .../patches/layout/CreateButtonRemoverPatch.kt | 6 +++--- .../revanced/patches/layout/HideReelsPatch.kt | 6 +++--- .../patches/layout/HideSuggestionsPatch.kt | 18 +++++------------- .../patches/layout/MinimizedPlaybackPatch.kt | 6 +++--- .../patches/layout/OldQualityLayoutPatch.kt | 6 +++--- .../revanced/patches/misc/IntegrationsPatch.kt | 8 ++++---- 8 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt index 13b123921..9b079a6fa 100644 --- a/src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt @@ -1,14 +1,14 @@ package app.revanced.patches.ad import app.revanced.patcher.PatcherData -import app.revanced.patcher.extensions.AccessFlagExtensions.Companion.or +import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.* import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod -import app.revanced.patcher.smali.asInstructions +import app.revanced.patcher.smali.toInstructions import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -94,7 +94,7 @@ class VideoAdsPatch : Patch( """ invoke-static { }, Lfi/vanced/libraries/youtube/whitelisting/Whitelist;->shouldShowAds()Z move-result v1 - """.trimIndent().asInstructions() + """.trimIndent().toInstructions() ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt index 9db84c5c2..70a9998e7 100644 --- a/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.interaction import app.revanced.patcher.PatcherData -import app.revanced.patcher.extensions.AccessFlagExtensions.Companion.or +import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.PatchMetadata @@ -11,7 +11,7 @@ import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod -import app.revanced.patcher.smali.asInstructions +import app.revanced.patcher.smali.toInstructions import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21t @@ -162,7 +162,7 @@ class EnableSeekbarTappingPatch : Patch( """ invoke-virtual { v12, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V invoke-virtual { v12, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V - """.trimIndent().asInstructions() + """.trimIndent().toInstructions() ) // if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label @@ -176,7 +176,7 @@ class EnableSeekbarTappingPatch : Patch( """ invoke-static { }, Lfi/razerman/youtube/preferences/BooleanPreferences;->isTapSeekingEnabled()Z move-result v0 - """.trimIndent().asInstructions() + """.trimIndent().toInstructions() ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt index e9499dced..f49f2344e 100644 --- a/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.layout import app.revanced.patcher.PatcherData -import app.revanced.patcher.extensions.AccessFlagExtensions.Companion.or +import app.revanced.patcher.extensions.or import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.PatchMetadata import app.revanced.patcher.patch.PatchResult @@ -10,7 +10,7 @@ import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod -import app.revanced.patcher.smali.asInstruction +import app.revanced.patcher.smali.toInstruction import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -80,7 +80,7 @@ class CreateButtonRemoverPatch : Patch( // Hide the button view via proxy by passing it to the hideCreateButton method result.method.implementation!!.addInstruction( result.scanData.endIndex, - "invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".asInstruction() + "invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".toInstruction() ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt b/src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt index 9ea37869b..d6e2c2b54 100644 --- a/src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.layout import app.revanced.patcher.PatcherData -import app.revanced.patcher.extensions.AccessFlagExtensions.Companion.or +import app.revanced.patcher.extensions.or import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.PatchMetadata import app.revanced.patcher.patch.PatchResult @@ -10,7 +10,7 @@ import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod -import app.revanced.patcher.smali.asInstruction +import app.revanced.patcher.smali.toInstruction import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -101,7 +101,7 @@ class HideReelsPatch : Patch( // so we pass the view to the HideReel method implementation.addInstruction( result.scanData.endIndex - 1, - "invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V".asInstruction() + "invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V".toInstruction() ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/layout/HideSuggestionsPatch.kt b/src/main/kotlin/app/revanced/patches/layout/HideSuggestionsPatch.kt index dd38b95d8..9e37a9cf9 100644 --- a/src/main/kotlin/app/revanced/patches/layout/HideSuggestionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/layout/HideSuggestionsPatch.kt @@ -1,23 +1,14 @@ package app.revanced.patches.layout import app.revanced.patcher.PatcherData -import app.revanced.patcher.extensions.AccessFlagExtensions.Companion.or -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.or import app.revanced.patcher.patch.* -import app.revanced.patcher.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod -import app.revanced.patcher.smali.asInstructions import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -import org.jf.dexlib2.builder.instruction.BuilderInstruction22c -import org.jf.dexlib2.builder.instruction.BuilderInstruction35c -import org.jf.dexlib2.iface.instruction.formats.Instruction22c -import org.jf.dexlib2.iface.instruction.formats.Instruction35c -import org.jf.dexlib2.immutable.ImmutableMethod -import org.jf.dexlib2.immutable.ImmutableMethodImplementation private val compatiblePackages = listOf("com.google.android.youtube") @@ -72,6 +63,8 @@ class HideSuggestionsPatch : Patch( ) ) { override fun execute(patcherData: PatcherData): PatchResult { + return PatchResultSuccess() // FIXME: fix below + /* val result = signatures.first().result!!.findParentMethod( MethodSignature( methodSignatureMetadata = MethodSignatureMetadata( @@ -117,8 +110,6 @@ class HideSuggestionsPatch : Patch( val clonedImplementation = clonedMethod.implementation!! - return PatchResultSuccess() // TODO: fix below - // fix the instructions registers clonedImplementation.instructions.forEachIndexed { index, it -> val opcode = it.opcode @@ -166,8 +157,9 @@ class HideSuggestionsPatch : Patch( move-result-object v0 invoke-virtual/range { v0 .. v0 }, Ljava/lang/Boolean;->booleanValue()Z move-result v2 - """.trimIndent().asInstructions() + """.trimIndent().toInstructions() ) return PatchResultSuccess() + */ } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt index 529892555..9e7a98ee7 100644 --- a/src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt @@ -1,14 +1,14 @@ package app.revanced.patches.layout import app.revanced.patcher.PatcherData -import app.revanced.patcher.extensions.AccessFlagExtensions.Companion.or +import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.* import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod -import app.revanced.patcher.smali.asInstructions +import app.revanced.patcher.smali.toInstructions import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -73,7 +73,7 @@ class MinimizedPlaybackPatch : Patch( """ const/4 v0, 0x1 return v0 - """.trimIndent().asInstructions() + """.trimIndent().toInstructions() ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt index 0767c7232..932853875 100644 --- a/src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt @@ -1,14 +1,14 @@ package app.revanced.patches.layout import app.revanced.patcher.PatcherData -import app.revanced.patcher.extensions.AccessFlagExtensions.Companion.or +import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.* import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod -import app.revanced.patcher.smali.asInstructions +import app.revanced.patcher.smali.toInstructions import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21t @@ -110,7 +110,7 @@ class OldQualityLayoutPatch : Patch( """ invoke-static { }, Lfi/razerman/youtube/XGlobals;->useOldStyleQualitySettings()Z move-result v0 - """.trimIndent().asInstructions() + """.trimIndent().toInstructions() ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt index f7a9a962e..682b46ce9 100644 --- a/src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.misc import app.revanced.patcher.PatcherData -import app.revanced.patcher.extensions.AccessFlagExtensions.Companion.or +import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.* import app.revanced.patcher.proxy.mutableTypes.MutableMethod.Companion.toMutable @@ -9,7 +9,7 @@ import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod -import app.revanced.patcher.smali.asInstructions +import app.revanced.patcher.smali.toInstructions import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode import org.jf.dexlib2.immutable.ImmutableMethod @@ -86,7 +86,7 @@ class IntegrationsPatch : Patch( """ invoke-static {v$count}, Lpl/jakubweg/StringRef;->setContext(Landroid/content/Context;)V sput-object v$count, Lapp/revanced/integrations/Globals;->context:Landroid/content/Context; - """.trimIndent().asInstructions() + """.trimIndent().toInstructions() ) val classDef = result.definingClassProxy.resolve() @@ -105,7 +105,7 @@ class IntegrationsPatch : Patch( invoke-static { }, Lapp/revanced/integrations/Globals;->getAppContext()Landroid/content/Context; move-result-object v0 return-object v0 - """.trimIndent().asInstructions(), + """.trimIndent().toInstructions(), null, null )