From 1a49bbdbc4ff6f427934259536218e161908b449 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 18 Apr 2022 18:41:26 +0200 Subject: [PATCH] fix: breaking changes of the patcher --- .../app/revanced/patches/ad/HomeAdsPatch.kt | 98 ++++++++++--------- .../app/revanced/patches/ad/HomePromoPatch.kt | 31 +++--- .../app/revanced/patches/ad/VideoAdsPatch.kt | 33 ++++--- .../interaction/EnableSeekbarTappingPatch.kt | 7 +- .../layout/CreateButtonRemoverPatch.kt | 7 +- .../revanced/patches/layout/HideReelsPatch.kt | 12 ++- .../patches/layout/MinimizedPlaybackPatch.kt | 12 ++- .../patches/layout/OldQualityLayoutPatch.kt | 13 ++- .../patches/misc/IntegrationsPatch.kt | 12 ++- .../app/revanced/patches/SignatureChecker.kt | 6 +- 10 files changed, 140 insertions(+), 91 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/ad/HomeAdsPatch.kt b/src/main/kotlin/app/revanced/patches/ad/HomeAdsPatch.kt index 32acbeeb2..88af1a2fa 100644 --- a/src/main/kotlin/app/revanced/patches/ad/HomeAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/ad/HomeAdsPatch.kt @@ -3,10 +3,7 @@ package app.revanced.patches.ad import app.revanced.extensions.injectHideCall import app.revanced.patcher.PatcherData import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.Patch -import app.revanced.patcher.patch.PatchMetadata -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.* import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -16,17 +13,26 @@ import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction11x import org.jf.dexlib2.iface.instruction.formats.Instruction35c -private val compatiblePackages = listOf("com.google.android.youtube") +private val packageMetadata = listOf( + PackageMetadata( + "com.google.android.youtube", + listOf("17.03.38") + ), +) + +private val patchMetadata = PatchMetadata( + "home-ads", + "Home Ads Patch", + "Patch to remove ads in YouTube", + packageMetadata, + "0.0.1" +) + +private val signatureDescription = "Required signature for ${patchMetadata.name}. Discovered in version 17.03.38." class HomeAdsPatch : Patch( - PatchMetadata( - "home-ads", - "Home Ads Patch", - "Patch to remove ads in YouTube", - compatiblePackages, - "0.0.1" - ), + patchMetadata, listOf( MethodSignature( MethodSignatureMetadata( @@ -36,8 +42,8 @@ class HomeAdsPatch : Patch( "k", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "Z", @@ -86,8 +92,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -158,8 +164,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -229,8 +235,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -279,8 +285,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -332,8 +338,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -401,8 +407,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -460,8 +466,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -524,8 +530,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -586,8 +592,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -669,8 +675,8 @@ class HomeAdsPatch : Patch( "lG", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -729,8 +735,8 @@ class HomeAdsPatch : Patch( "b", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -797,8 +803,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -832,8 +838,8 @@ class HomeAdsPatch : Patch( "b", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -896,8 +902,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -1042,8 +1048,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", @@ -1177,8 +1183,8 @@ class HomeAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. - compatiblePackages, - "Found in YouTube version v17.03.38", + packageMetadata, + signatureDescription, "0.0.1" ), "V", diff --git a/src/main/kotlin/app/revanced/patches/ad/HomePromoPatch.kt b/src/main/kotlin/app/revanced/patches/ad/HomePromoPatch.kt index efb556a24..a8b6b8854 100644 --- a/src/main/kotlin/app/revanced/patches/ad/HomePromoPatch.kt +++ b/src/main/kotlin/app/revanced/patches/ad/HomePromoPatch.kt @@ -14,16 +14,25 @@ import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction11x -private val compatiblePackages = listOf("com.google.android.youtube") +private val compatiblePackages = listOf( + PackageMetadata( + "com.google.android.youtube", + listOf("17.03.38", "17.14.35") + ) +) + +private val patchMetadata = PatchMetadata( + "home-promo-ads", + "Home Promo Ads Patch", + "Patch to remove promoted ads in YouTube", + compatiblePackages, + "0.0.1" +) + +private val signatureDescription = "Required signature for ${patchMetadata.name}. Discovered in version 17.03.38." class HomePromoPatch : Patch( - PatchMetadata( - "home-promo-ads", - "Home Promo Ads Patch", - "Patch to remove promoted ads in YouTube", - compatiblePackages, - "0.0.1" - ), + patchMetadata, listOf( MethodSignature( MethodSignatureMetadata( @@ -34,7 +43,7 @@ class HomePromoPatch : Patch( ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. compatiblePackages, - "Found in YouTube version v17.03.38", + signatureDescription, "0.0.1" ), "V", @@ -85,7 +94,7 @@ class HomePromoPatch : Patch( ), PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. compatiblePackages, - "Found in YouTube version v17.03.38", + signatureDescription, "0.0.1" ), "V", @@ -140,7 +149,7 @@ class HomePromoPatch : Patch( methodMetadata, PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value. compatiblePackages, - "Found in YouTube version v17.03.38", + signatureDescription, "0.0.1" ), "V", diff --git a/src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt index 20cbd92e8..ad8b413e2 100644 --- a/src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt @@ -12,16 +12,23 @@ import app.revanced.patcher.smali.toInstructions import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -private val compatiblePackages = listOf("com.google.android.youtube") +private val packageMetadata = listOf( + PackageMetadata( + "com.google.android.youtube", + listOf("17.14.35") + ) +) + +private val patchMetadata = PatchMetadata( + "video-ads", + "YouTube Video Ads Patch", + "Patch to remove ads in the YouTube video player.", + packageMetadata, + "0.0.1" +) class VideoAdsPatch : Patch( - PatchMetadata( - "video-ads", - "YouTube Video Ads Patch", - "Patch to remove ads in the YouTube video player.", - compatiblePackages, - "0.0.1" - ), + patchMetadata, listOf( MethodSignature( MethodSignatureMetadata( @@ -31,10 +38,8 @@ class VideoAdsPatch : Patch( "", ), PatternScanMethod.Fuzzy(2),// FIXME: Test this threshold and find the best value. - compatiblePackages, - """Signature for the constructor of some class. - This signature is being used to find another method in the parent class - and was discovered in the YouTube version v17.03.38""".trimIndent(), + packageMetadata, + "Required signature for ${patchMetadata.name}. Discovered in version 17.14.35.", "0.0.1" ), "V", @@ -72,8 +77,8 @@ class VideoAdsPatch : Patch( null // unknown ), PatternScanMethod.Direct(), - compatiblePackages, - "Signature to find the method, which is responsible for showing the video ads", + packageMetadata, + "Signature to find the method, which is responsible for showing the video ads. Discovered in version 17.14.35", "0.0.1" ), "V", diff --git a/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt index f42516ec4..dedf0d4dc 100644 --- a/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt @@ -16,7 +16,12 @@ import org.jf.dexlib2.iface.Method import org.jf.dexlib2.iface.instruction.formats.Instruction11n import org.jf.dexlib2.iface.instruction.formats.Instruction35c -private val compatiblePackages = listOf("com.google.android.youtube") +private val compatiblePackages = listOf( + PackageMetadata( + "com.google.android.youtube", + listOf("17.14.35") + ) +) class EnableSeekbarTappingPatch : Patch( PatchMetadata( diff --git a/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt index 1b014b16e..d945f8e79 100644 --- a/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt @@ -12,7 +12,12 @@ import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction35c -private val compatiblePackages = listOf("com.google.android.youtube") +private val compatiblePackages = listOf( + PackageMetadata( + "com.google.android.youtube", + listOf("17.14.35") + ) +) class CreateButtonRemoverPatch : Patch( PatchMetadata( diff --git a/src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt b/src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt index a8ae7e9aa..7ae117dc8 100644 --- a/src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt @@ -2,10 +2,7 @@ package app.revanced.patches.layout import app.revanced.patcher.PatcherData import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.Patch -import app.revanced.patcher.patch.PatchMetadata -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.* import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -14,7 +11,12 @@ import app.revanced.patcher.smali.toInstruction import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -private val compatiblePackages = listOf("com.google.android.youtube") +private val compatiblePackages = listOf( + PackageMetadata( + "com.google.android.youtube", + listOf("17.14.35") + ) +) class HideReelsPatch : Patch( PatchMetadata( diff --git a/src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt index 3a1c705dd..0bbf7645f 100644 --- a/src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt @@ -3,10 +3,7 @@ package app.revanced.patches.layout import app.revanced.patcher.PatcherData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.Patch -import app.revanced.patcher.patch.PatchMetadata -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.* import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -15,7 +12,12 @@ import app.revanced.patcher.smali.toInstructions import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -private val compatiblePackages = listOf("com.google.android.youtube") +private val compatiblePackages = listOf( + PackageMetadata( + "com.google.android.youtube", + listOf("17.14.35") + ) +) class MinimizedPlaybackPatch : Patch( PatchMetadata( diff --git a/src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt index 6fb2e40ea..a69c00718 100644 --- a/src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt @@ -13,7 +13,12 @@ import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21t -private val compatiblePackages = listOf("com.google.android.youtube") +private val compatiblePackages = listOf( + PackageMetadata( + "com.google.android.youtube", + listOf("17.14.35") + ) +) class OldQualityLayoutPatch : Patch( PatchMetadata( @@ -98,7 +103,11 @@ class OldQualityLayoutPatch : Patch( // if useOldStyleQualitySettings == true, jump over all instructions val jmpInstruction = - BuilderInstruction21t(Opcode.IF_NEZ, 0, implementation.instructions[result.scanData.endIndex].location.labels.first()) + BuilderInstruction21t( + Opcode.IF_NEZ, + 0, + implementation.instructions[result.scanData.endIndex].location.labels.first() + ) implementation.addInstruction(5, jmpInstruction) implementation.addInstructions( 0, diff --git a/src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt index 606709e83..109da2e76 100644 --- a/src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt @@ -3,10 +3,7 @@ package app.revanced.patches.misc import app.revanced.patcher.PatcherData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.Patch -import app.revanced.patcher.patch.PatchMetadata -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess +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 @@ -18,7 +15,12 @@ import org.jf.dexlib2.Opcode import org.jf.dexlib2.immutable.ImmutableMethod import org.jf.dexlib2.immutable.ImmutableMethodImplementation -private val compatiblePackages = listOf("com.google.android.youtube") +private val compatiblePackages = listOf( + PackageMetadata( + "com.google.android.youtube", + listOf("17.03.38", "17.14.35") + ) +) class IntegrationsPatch : Patch( PatchMetadata( diff --git a/src/test/kotlin/app/revanced/patches/SignatureChecker.kt b/src/test/kotlin/app/revanced/patches/SignatureChecker.kt index 67d6de8b4..244e4c784 100644 --- a/src/test/kotlin/app/revanced/patches/SignatureChecker.kt +++ b/src/test/kotlin/app/revanced/patches/SignatureChecker.kt @@ -28,7 +28,11 @@ internal class SignatureChecker { if (patternScanMethod is PatternScanMethod.Fuzzy) { val warnings = patternScanMethod.warnings!! val method = signature.result!!.method - val methodFromMetadata = if (signature.metadata.methodMetadata != null) signature.metadata.methodMetadata!! else MethodMetadata(null, null) + val methodFromMetadata = + if (signature.metadata.methodMetadata != null) signature.metadata.methodMetadata!! else MethodMetadata( + null, + null + ) println("Signature: ${signature.metadata.name}.\nMethod: ${methodFromMetadata.definingClass}->${methodFromMetadata.name} (Signature matches: ${method.definingClass}->${method.toStr()})\nWarnings: ${warnings.count()}") for (warning in warnings) {