diff --git a/build.gradle.kts b/build.gradle.kts index 9c731d244..4dbf84e39 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,7 +20,7 @@ repositories { } dependencies { - implementation("app.revanced:revanced-patcher:5.1.2") + implementation("app.revanced:revanced-patcher:6.0.0") implementation("app.revanced:multidexlib2:2.5.2.r2") // Required for meta implementation("com.google.code.gson:gson:2.9.1") diff --git a/src/main/kotlin/app/revanced/extensions/Extensions.kt b/src/main/kotlin/app/revanced/extensions/Extensions.kt index 61120799f..5b31631a1 100644 --- a/src/main/kotlin/app/revanced/extensions/Extensions.kt +++ b/src/main/kotlin/app/revanced/extensions/Extensions.kt @@ -1,7 +1,7 @@ package app.revanced.extensions -import app.revanced.patcher.data.impl.BytecodeData -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.util.proxy.mutableTypes.MutableClass @@ -35,9 +35,9 @@ internal fun MutableMethodImplementation.injectHideCall( * @param targetClass the class to start traversing the class hierarchy from * @param callback function that is called for every class in the hierarchy */ -fun BytecodeData.traverseClassHierarchy(targetClass: MutableClass, callback: MutableClass.() -> Unit) { +fun BytecodeContext.traverseClassHierarchy(targetClass: MutableClass, callback: MutableClass.() -> Unit) { callback(targetClass) - this.findClass(targetClass.superclass ?: return)?.resolve()?.let { + this.findClass(targetClass.superclass ?: return)?.mutableClass?.let { traverseClassHierarchy(it, callback) } } @@ -135,7 +135,7 @@ internal fun MutableMethod.injectConsumableEventHook(hookRef: ImmutableMethodRef * @param resourceType the resource type, for example 'drawable'. this has to match both the source and the target * @param resourceFileNames names of all resources of this type to inject */ -fun ResourceData.injectResources( +fun ResourceContext.injectResources( classLoader: ClassLoader, patchDirectoryPath: String, resourceType: String, @@ -160,7 +160,7 @@ fun ResourceData.injectResources( * @param patchDirectoryPath path to the files. this will be the directory you created under the 'resources' source folder * @param languageIdentifier ISO 639-2 two- letter language code identifier (aka the one android uses for values directory) */ -fun ResourceData.injectStrings( +fun ResourceContext.injectStrings( classLoader: ClassLoader, patchDirectoryPath: String, languageIdentifier: String? = null, diff --git a/src/main/kotlin/app/revanced/meta/Meta.kt b/src/main/kotlin/app/revanced/meta/Meta.kt index b629c66d7..6be5ed00e 100644 --- a/src/main/kotlin/app/revanced/meta/Meta.kt +++ b/src/main/kotlin/app/revanced/meta/Meta.kt @@ -2,12 +2,12 @@ package app.revanced.meta import app.revanced.meta.json.generateJson import app.revanced.meta.readme.generateText -import app.revanced.patcher.data.Data +import app.revanced.patcher.data.Context import app.revanced.patcher.patch.Patch -import app.revanced.patcher.util.patch.impl.JarPatchBundle +import app.revanced.patcher.util.patch.PatchBundle import java.io.File -typealias Bundle = List>> +typealias Bundle = List>> object Meta { @JvmStatic @@ -20,7 +20,7 @@ object Meta { } } -fun accumulatePatches() = JarPatchBundle( +fun accumulatePatches() = PatchBundle.Jar( File("build/libs/").listFiles()!!.first { it.name.startsWith("revanced-patches-") && it.name.endsWith(".jar") }.absolutePath diff --git a/src/main/kotlin/app/revanced/meta/readme/Extensions.kt b/src/main/kotlin/app/revanced/meta/readme/Extensions.kt index 72779a009..d568eb858 100644 --- a/src/main/kotlin/app/revanced/meta/readme/Extensions.kt +++ b/src/main/kotlin/app/revanced/meta/readme/Extensions.kt @@ -1,10 +1,10 @@ package app.revanced.meta.readme -import app.revanced.patcher.data.Data +import app.revanced.patcher.data.Context import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages import app.revanced.patcher.patch.Patch -internal fun Class>.getLatestVersion() = +internal fun Class>.getLatestVersion() = this.compatiblePackages?.first()?.versions?.map { SemanticVersion.fromString(it) }?.maxWithOrNull(SemanticVersionComparator) diff --git a/src/main/kotlin/app/revanced/meta/readme/Generator.kt b/src/main/kotlin/app/revanced/meta/readme/Generator.kt index 3358d9719..bdce66cbc 100644 --- a/src/main/kotlin/app/revanced/meta/readme/Generator.kt +++ b/src/main/kotlin/app/revanced/meta/readme/Generator.kt @@ -1,7 +1,7 @@ package app.revanced.meta.readme import app.revanced.meta.Bundle -import app.revanced.patcher.data.Data +import app.revanced.patcher.data.Context import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages import app.revanced.patcher.extensions.PatchExtensions.description import app.revanced.patcher.extensions.PatchExtensions.patchName @@ -15,7 +15,7 @@ private val TABLE_REGEX = Regex("\\{\\{\\s?table\\s?}}") fun generateText(bundle: Bundle) { val output = StringBuilder() - val packages = mutableMapOf>>>() + val packages = mutableMapOf>>>() for (patch in bundle) { patch.compatiblePackages?.forEach { pkg -> diff --git a/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsConstructorFingerprint.kt index 7cd26d2ac..218deb011 100644 --- a/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsConstructorFingerprint.kt @@ -3,18 +3,13 @@ package app.revanced.patches.music.ad.video.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.ad.video.annotations.MusicVideoAdsCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("show-video-ads-constructor-fingerprint") -@MatchingMethod( - "Laghd;", - "", -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MusicVideoAdsCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsFingerprint.kt index 4fd432ea0..4ef541364 100644 --- a/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsFingerprint.kt @@ -4,16 +4,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.ad.video.annotations.MusicVideoAdsCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("show-video-ads-method-fingerprint") -@MatchingMethod( - "Laghd;", "d" -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MusicVideoAdsCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt index 96e1b09a1..bbf484831 100644 --- a/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.music.ad.video.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.music.ad.video.annotations.MusicVideoAdsCompatibility import app.revanced.patches.music.ad.video.fingerprints.ShowMusicVideoAdsConstructorFingerprint import app.revanced.patches.music.ad.video.fingerprints.ShowMusicVideoAdsFingerprint @@ -24,8 +24,8 @@ class MusicVideoAdsPatch : BytecodePatch( ShowMusicVideoAdsConstructorFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { - ShowMusicVideoAdsFingerprint.resolve(data, ShowMusicVideoAdsConstructorFingerprint.result!!.classDef) + override fun execute(context: BytecodeContext): PatchResult { + ShowMusicVideoAdsFingerprint.resolve(context, ShowMusicVideoAdsConstructorFingerprint.result!!.classDef) val result = ShowMusicVideoAdsFingerprint.result!! diff --git a/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/AllCodecsReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/AllCodecsReferenceFingerprint.kt index 7ab93ee3d..abf7d8fa1 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/AllCodecsReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/AllCodecsReferenceFingerprint.kt @@ -3,18 +3,13 @@ package app.revanced.patches.music.audio.codecs.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher. fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.audio.codecs.annotations.CodecsUnlockCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("all-codecs-reference-fingerprint") -@MatchingMethod( - "Laari;", - "b", -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @CodecsUnlockCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/CodecsLockFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/CodecsLockFingerprint.kt index 10a3f65b1..dea41a202 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/CodecsLockFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/CodecsLockFingerprint.kt @@ -4,17 +4,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.audio.codecs.annotations.CodecsUnlockCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("codec-lock-fingerprint") -@MatchingMethod( - "Lacfr;", - "a", -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @CodecsUnlockCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt index 3e91ab1a7..9ff6916b8 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.music.audio.codecs.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData -import app.revanced.patcher.data.impl.toMethodWalker -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.toMethodWalker +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.toInstruction import app.revanced.patches.music.audio.codecs.annotations.CodecsUnlockCompatibility import app.revanced.patches.music.audio.codecs.fingerprints.AllCodecsReferenceFingerprint @@ -25,7 +25,7 @@ class CodecsUnlockPatch : BytecodePatch( CodecsLockFingerprint, AllCodecsReferenceFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val codecsLockResult = CodecsLockFingerprint.result!! val implementation = codecsLockResult.mutableMethod.implementation!! @@ -42,7 +42,7 @@ class CodecsUnlockPatch : BytecodePatch( val allCodecsResult = AllCodecsReferenceFingerprint.result!! val allCodecsMethod = - data.toMethodWalker(allCodecsResult.method) + context.toMethodWalker(allCodecsResult.method) .nextMethod(allCodecsResult.scanResult.patternScanResult!!.startIndex) .getMethod() diff --git a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt index 77db34b2a..657b1de3f 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt @@ -3,19 +3,14 @@ package app.revanced.patches.music.audio.exclusiveaudio.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.audio.exclusiveaudio.annotations.ExclusiveAudioCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("audio-only-enabler-fingerprint") -@MatchingMethod( - "Lgmd;", - "d" -) -@DirectPatternScanMethod + @ExclusiveAudioCompatibility @Version( "0.0.1" diff --git a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/ExclusiveAudioFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/ExclusiveAudioFingerprint.kt index f4965890d..fe2f45bda 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/ExclusiveAudioFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/ExclusiveAudioFingerprint.kt @@ -3,17 +3,13 @@ package app.revanced.patches.music.audio.exclusiveaudio.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.audio.exclusiveaudio.annotations.ExclusiveAudioCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("exclusive-audio-fingerprints") -@MatchingMethod( - "Lgmd;", "c" -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @ExclusiveAudioCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt index ace902685..d679e8702 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.music.audio.exclusiveaudio.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.music.audio.exclusiveaudio.annotations.ExclusiveAudioCompatibility import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint @@ -23,7 +23,7 @@ class ExclusiveAudioPatch : BytecodePatch( AudioOnlyEnablerFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val method = AudioOnlyEnablerFingerprint.result!!.mutableMethod method.replaceInstruction(method.implementation!!.instructions.count() - 1, "const/4 v0, 0x1") method.addInstruction("return v0") diff --git a/src/main/kotlin/app/revanced/patches/music/layout/compactheader/fingerprints/CompactHeaderConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/compactheader/fingerprints/CompactHeaderConstructorFingerprint.kt index 5f2032292..8a1e7f8c1 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/compactheader/fingerprints/CompactHeaderConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/compactheader/fingerprints/CompactHeaderConstructorFingerprint.kt @@ -4,15 +4,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.music.layout.compactheader.annotations.CompactHeaderCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("compact-header-constructor-fingerprint") -@MatchingMethod( - "Llcz;", "" -) @CompactHeaderCompatibility @Version("0.0.1") object CompactHeaderConstructorFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt index ae05a5c85..879dfa0c0 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.music.layout.compactheader.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.music.layout.compactheader.annotations.CompactHeaderCompatibility import app.revanced.patches.music.layout.compactheader.fingerprints.CompactHeaderConstructorFingerprint import org.jf.dexlib2.builder.instruction.BuilderInstruction11x @@ -23,7 +23,7 @@ class CompactHeaderPatch : BytecodePatch( CompactHeaderConstructorFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val result = CompactHeaderConstructorFingerprint.result!! val method = result.mutableMethod diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt index b9845befc..f24131e54 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt @@ -4,15 +4,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.music.layout.minimizedplayback.annotations.MinimizedPlaybackCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("minimized-playback-manager-fingerprint") -@MatchingMethod( - "Llxw;", "c" -) @MinimizedPlaybackCompatibility @Version("0.0.1") object MinimizedPlaybackManagerFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt index dad628128..dcfdb9f05 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -3,18 +3,14 @@ package app.revanced.patches.music.layout.minimizedplayback.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData -import app.revanced.patcher.data.impl.toMethodWalker +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.music.layout.minimizedplayback.annotations.MinimizedPlaybackCompatibility import app.revanced.patches.music.layout.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint -import org.jf.dexlib2.iface.instruction.ReferenceInstruction -import org.jf.dexlib2.iface.reference.MethodReference @Patch @Name("minimized-playback-music") @@ -26,7 +22,7 @@ class MinimizedPlaybackPatch : BytecodePatch( MinimizedPlaybackManagerFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { MinimizedPlaybackManagerFingerprint.result!!.mutableMethod.addInstructions( 0, """ return-void diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt index 981c168c3..5d03e16ac 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt @@ -4,15 +4,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.music.layout.premium.annotations.HideGetPremiumCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("hide-get-premium-fingerprint") -@MatchingMethod( - "Lktn;", "k" -) @HideGetPremiumCompatibility @Version("0.0.1") object HideGetPremiumFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumParentFingerprint.kt index 8c77119fd..5244ab561 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumParentFingerprint.kt @@ -4,15 +4,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.music.layout.premium.annotations.HideGetPremiumCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("hide-get-premium-parent-fingerprint") -@MatchingMethod( - "Lktn;", "k" -) @HideGetPremiumCompatibility @Version("0.0.1") object HideGetPremiumParentFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt index a85ee5b7e..727ff9dd9 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt @@ -3,14 +3,14 @@ package app.revanced.patches.music.layout.premium.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.music.layout.premium.annotations.HideGetPremiumCompatibility import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumFingerprint import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumParentFingerprint @@ -25,9 +25,9 @@ class HideGetPremiumPatch : BytecodePatch( HideGetPremiumParentFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val parentResult = HideGetPremiumParentFingerprint.result!! - HideGetPremiumFingerprint.resolve(data, parentResult.classDef) + HideGetPremiumFingerprint.resolve(context, parentResult.classDef) val startIndex = parentResult.scanResult.patternScanResult!!.startIndex diff --git a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt index 0839d543a..db9133ac5 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt @@ -3,17 +3,13 @@ package app.revanced.patches.music.layout.tastebuilder.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.layout.tastebuilder.annotations.RemoveTasteBuilderCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("taste-builder-constructor-fingerprint") -@MatchingMethod( - "Lkyu;", "" -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @RemoveTasteBuilderCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt index 934af5b40..d3b61a3f7 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.music.layout.tastebuilder.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.music.layout.tastebuilder.annotations.RemoveTasteBuilderCompatibility import app.revanced.patches.music.layout.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint import org.jf.dexlib2.iface.instruction.formats.Instruction22c @@ -23,7 +23,7 @@ class RemoveTasteBuilderPatch : BytecodePatch( TasteBuilderConstructorFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val result = TasteBuilderConstructorFingerprint.result!! val method = result.mutableMethod diff --git a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/fingerprints/PivotBarConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/fingerprints/PivotBarConstructorFingerprint.kt index 20e7a5371..43f2edde5 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/fingerprints/PivotBarConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/fingerprints/PivotBarConstructorFingerprint.kt @@ -3,17 +3,13 @@ package app.revanced.patches.music.layout.upgradebutton.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.layout.upgradebutton.annotations.RemoveUpgradeButtonCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("pivot-bar-constructor-fingerprint") -@MatchingMethod( - "Lhfu;", "" -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @RemoveUpgradeButtonCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt index df735e0e1..9bf8ad011 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.music.layout.upgradebutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.music.layout.upgradebutton.annotations.RemoveUpgradeButtonCompatibility import app.revanced.patches.music.layout.upgradebutton.fingerprints.PivotBarConstructorFingerprint @@ -28,7 +28,7 @@ class RemoveUpgradeButtonPatch : BytecodePatch( PivotBarConstructorFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val result = PivotBarConstructorFingerprint.result!! val implementation = result.mutableMethod.implementation!! diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastContextFetchFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastContextFetchFingerprint.kt index 7ef6fba14..0ddd7e0b6 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastContextFetchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastContextFetchFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.music.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility @Name("cast-context-fetch-fingerprint") -@MatchingMethod( - "Lvvz;", "a" -) -@DirectPatternScanMethod + @MicroGPatchCompatibility @Version("0.0.1") object CastContextFetchFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt index 3e262188e..0259d0f13 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.music.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility @Name("cast-module-fingerprint") -@MatchingMethod( - "Llqh;", "c" -) -@DirectPatternScanMethod + @MicroGPatchCompatibility @Version("0.0.1") object CastDynamiteModuleFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt index 4c117108f..981b3db9f 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.music.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility @Name("cast-context-fetch-fingerprint") -@MatchingMethod( - "Lmcf;", "c" -) -@DirectPatternScanMethod + @MicroGPatchCompatibility @Version("0.0.1") object CastDynamiteModuleV2Fingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt index d12b0bf9b..6befa1851 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt @@ -3,17 +3,13 @@ package app.revanced.patches.music.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.misc.microg.annotations.MusicMicroGPatchCompatibility import org.jf.dexlib2.AccessFlags @Name("google-play-utility-fingerprint") -@MatchingMethod( - "Lnuv;", "b" -) -@DirectPatternScanMethod + @MusicMicroGPatchCompatibility @Version("0.0.1") object GooglePlayUtilityFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/PrimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/PrimeFingerprint.kt index 65ec90479..4af8de362 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/PrimeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/PrimeFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.music.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.misc.microg.annotations.MusicMicroGPatchCompatibility @Name("google-play-prime-fingerprint") -@MatchingMethod( - "Lrwi;", "a" -) -@DirectPatternScanMethod + @MusicMicroGPatchCompatibility @Version("0.0.1") object PrimeFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/ServiceCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/ServiceCheckFingerprint.kt index 2e9091373..4ecf0eb31 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/ServiceCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/fingerprints/ServiceCheckFingerprint.kt @@ -4,15 +4,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.misc.microg.annotations.MusicMicroGPatchCompatibility import org.jf.dexlib2.AccessFlags @Name("google-play-service-checker-fingerprint") -@MatchingMethod( - "Lnuv;", "d" -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MusicMicroGPatchCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/MusicMicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/MusicMicroGBytecodePatch.kt index be04b566e..7fca848f8 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/MusicMicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/bytecode/MusicMicroGBytecodePatch.kt @@ -3,11 +3,11 @@ package app.revanced.patches.music.misc.microg.patch.bytecode import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.music.misc.microg.annotations.MusicMicroGPatchCompatibility import app.revanced.patches.music.misc.microg.fingerprints.* import app.revanced.patches.music.misc.microg.patch.resource.MusicMicroGResourcePatch @@ -39,10 +39,10 @@ class MusicMicroGBytecodePatch : BytecodePatch( // - "com.google.android.gms.phenotype.PACKAGE_NAME", // - "com.google.android.gms.phenotype.UPDATE", // - "com.google.android.gms.phenotype", - override fun execute(data: BytecodeData) = + override fun execute(context: BytecodeContext) = // apply common microG patch MicroGBytecodeHelper.patchBytecode( - data, + context, arrayOf( MicroGBytecodeHelper.packageNameTransform( Constants.PACKAGE_NAME, diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/MusicMicroGResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/MusicMicroGResourcePatch.kt index 341e1e78e..19daba368 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/MusicMicroGResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/patch/resource/MusicMicroGResourcePatch.kt @@ -3,10 +3,10 @@ package app.revanced.patches.music.misc.microg.patch.resource import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patches.music.misc.microg.annotations.MusicMicroGPatchCompatibility import app.revanced.patches.music.misc.microg.shared.Constants.MUSIC_PACKAGE_NAME import app.revanced.patches.music.misc.microg.shared.Constants.REVANCED_MUSIC_APP_NAME @@ -20,11 +20,11 @@ import app.revanced.util.microg.MicroGResourceHelper @Description("Resource patch to allow YouTube Music ReVanced to run without root and under a different package name.") @MusicMicroGPatchCompatibility @Version("0.0.2") -class MusicMicroGResourcePatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { +class MusicMicroGResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { // update manifest MicroGResourceHelper.patchManifest( - data, + context, MUSIC_PACKAGE_NAME, REVANCED_MUSIC_PACKAGE_NAME, REVANCED_MUSIC_APP_NAME @@ -32,7 +32,7 @@ class MusicMicroGResourcePatch : ResourcePatch() { // add metadata to the manifest MicroGManifestHelper.addSpoofingMetadata( - data, + context, SPOOFED_PACKAGE_NAME, SPOOFED_PACKAGE_SIGNATURE ) diff --git a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/fingerprints/BackgroundPlaybackDisableFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/fingerprints/BackgroundPlaybackDisableFingerprint.kt index 4f498732d..c8150caa2 100644 --- a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/fingerprints/BackgroundPlaybackDisableFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/fingerprints/BackgroundPlaybackDisableFingerprint.kt @@ -3,17 +3,13 @@ package app.revanced.patches.music.premium.backgroundplay.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.music.premium.backgroundplay.annotations.BackgroundPlayCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("background-playback-disabler-fingerprint") -@MatchingMethod( - "Lafgf;", "e" -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @BackgroundPlayCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt index 3e9d240ff..9c860a9c3 100644 --- a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.music.premium.backgroundplay.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.music.premium.backgroundplay.annotations.BackgroundPlayCompatibility import app.revanced.patches.music.premium.backgroundplay.fingerprints.BackgroundPlaybackDisableFingerprint @@ -22,7 +22,7 @@ class BackgroundPlayPatch : BytecodePatch( BackgroundPlaybackDisableFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { BackgroundPlaybackDisableFingerprint.result!!.mutableMethod.addInstructions( 0, """ diff --git a/src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/GeneralAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/GeneralAdsPatch.kt index 843928398..86341a62a 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/GeneralAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/GeneralAdsPatch.kt @@ -3,12 +3,11 @@ package app.revanced.patches.reddit.ad.general.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData -import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.reddit.ad.general.annotations.GeneralAdsCompatibility import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21c @@ -22,8 +21,8 @@ import org.jf.dexlib2.immutable.reference.ImmutableStringReference @GeneralAdsCompatibility @Version("0.0.1") class GeneralAdsPatch : BytecodePatch() { - override fun execute(data: BytecodeData): PatchResult { - data.classes.forEach { classDef -> + override fun execute(context: BytecodeContext): PatchResult { + context.classes.forEach { classDef -> classDef.methods.forEach methodLoop@{ method -> val implementation = method.implementation ?: return@methodLoop @@ -31,7 +30,7 @@ class GeneralAdsPatch : BytecodePatch() { if (instruction.opcode != Opcode.CONST_STRING) return@forEachIndexed if (((instruction as ReferenceInstruction).reference as StringReference).string != "AdPost") return@forEachIndexed - val proxiedClass = data.proxy(classDef).resolve() + val proxiedClass = context.proxy(classDef).mutableClass val proxiedImplementation = proxiedClass.methods.first { it.name == method.name && it.parameterTypes.containsAll(method.parameterTypes) diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/fingerprints/PremiumIconFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/fingerprints/PremiumIconFingerprint.kt index db36dceca..3eb53afd6 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/fingerprints/PremiumIconFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/fingerprints/PremiumIconFingerprint.kt @@ -2,14 +2,10 @@ package app.revanced.patches.reddit.layout.premiumicon.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.reddit.layout.premiumicon.annotations.PremiumIconCompatibility @Name("premium-icon-fingerprint") -@MatchingMethod( - "Lcom/reddit/domain/model/MyAccount;", "isPremiumSubscriber" -) @PremiumIconCompatibility @Version("0.0.1") object PremiumIconFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/patch/PremiumIconPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/patch/PremiumIconPatch.kt index 1b6bfb136..9aabaad24 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/patch/PremiumIconPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/patch/PremiumIconPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.reddit.layout.premiumicon.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.reddit.layout.premiumicon.annotations.PremiumIconCompatibility import app.revanced.patches.reddit.layout.premiumicon.fingerprints.PremiumIconFingerprint @@ -22,7 +22,7 @@ class PremiumIconPatch : BytecodePatch( PremiumIconFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val method = PremiumIconFingerprint.result!!.mutableMethod method.addInstructions( 0, diff --git a/src/main/kotlin/app/revanced/patches/spotify/audio/bytecode/patch/DisableCaptureRestrictionBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/spotify/audio/bytecode/patch/DisableCaptureRestrictionBytecodePatch.kt index a6e60bddd..5cf39625d 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/audio/bytecode/patch/DisableCaptureRestrictionBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/audio/bytecode/patch/DisableCaptureRestrictionBytecodePatch.kt @@ -3,14 +3,14 @@ package app.revanced.patches.spotify.audio.bytecode.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.instruction import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.spotify.audio.annotation.DisableCaptureRestrictionCompatibility import app.revanced.patches.spotify.audio.fingerprints.DisableCaptureRestrictionAudioDriverFingerprint @@ -36,7 +36,7 @@ class DisableCaptureRestrictionBytecodePatch : BytecodePatch( ) } - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val method = DisableCaptureRestrictionAudioDriverFingerprint.result!!.mutableMethod // Replace constant that contains the capture policy parameter for AudioAttributesBuilder.setAllowedCapturePolicy() diff --git a/src/main/kotlin/app/revanced/patches/spotify/audio/fingerprints/DisableCaptureRestrictionAudioDriverFingerprint.kt b/src/main/kotlin/app/revanced/patches/spotify/audio/fingerprints/DisableCaptureRestrictionAudioDriverFingerprint.kt index fcd168525..d4c0788e9 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/audio/fingerprints/DisableCaptureRestrictionAudioDriverFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/audio/fingerprints/DisableCaptureRestrictionAudioDriverFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.spotify.audio.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.spotify.audio.annotation.DisableCaptureRestrictionCompatibility @Name("disable-capture-restriction-audio-driver-fingerprint") -@MatchingMethod( - "Lcom/spotify/playback/playbacknative/AudioDriver;", "constructAudioAttributes" -) -@DirectPatternScanMethod + @DisableCaptureRestrictionCompatibility @Version("0.0.1") object DisableCaptureRestrictionAudioDriverFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/spotify/audio/resource/patch/DisableCaptureRestrictionResourcePatch.kt b/src/main/kotlin/app/revanced/patches/spotify/audio/resource/patch/DisableCaptureRestrictionResourcePatch.kt index 85c39ef4e..9274c6815 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/audio/resource/patch/DisableCaptureRestrictionResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/audio/resource/patch/DisableCaptureRestrictionResourcePatch.kt @@ -3,23 +3,21 @@ package app.revanced.patches.spotify.audio.resource.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patches.spotify.audio.annotation.DisableCaptureRestrictionCompatibility -import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import org.w3c.dom.Element @Name("disable-capture-restriction-resource-patch") @Description("Sets allowAudioPlaybackCapture in manifest to true.") @DisableCaptureRestrictionCompatibility @Version("0.0.1") -class DisableCaptureRestrictionResourcePatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { +class DisableCaptureRestrictionResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { // create an xml editor instance - data.xmlEditor["AndroidManifest.xml"].use { dom -> + context.xmlEditor["AndroidManifest.xml"].use { dom -> // get the application node val applicationNode = dom .file diff --git a/src/main/kotlin/app/revanced/patches/spotify/layout/theme/patch/ThemePatch.kt b/src/main/kotlin/app/revanced/patches/spotify/layout/theme/patch/ThemePatch.kt index ebda9d25d..dfbc7fd17 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/layout/theme/patch/ThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/layout/theme/patch/ThemePatch.kt @@ -3,14 +3,10 @@ package app.revanced.patches.spotify.layout.theme.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData -import app.revanced.patcher.patch.OptionsContainer -import app.revanced.patcher.patch.PatchOption -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.* import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.spotify.layout.theme.annotations.ThemeCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import org.w3c.dom.Element @@ -21,9 +17,9 @@ import org.w3c.dom.Element @Description("Applies a custom theme.") @ThemeCompatibility @Version("0.0.1") -class ThemePatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { - data.xmlEditor["res/values/colors.xml"].use { editor -> +class ThemePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + context.xmlEditor["res/values/colors.xml"].use { editor -> val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element for (i in 0 until resourcesNode.childNodes.length) { diff --git a/src/main/kotlin/app/revanced/patches/spotify/premium_navbar_tab/patch/PremiumNavbarTabPatch.kt b/src/main/kotlin/app/revanced/patches/spotify/premium_navbar_tab/patch/PremiumNavbarTabPatch.kt index fc50e17fd..4c992bbf2 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/premium_navbar_tab/patch/PremiumNavbarTabPatch.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/premium_navbar_tab/patch/PremiumNavbarTabPatch.kt @@ -3,14 +3,14 @@ package app.revanced.patches.spotify.premium_navbar_tab.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.spotify.premium_navbar_tab.annotations.PremiumNavbarTabCompatibility import app.revanced.patches.spotify.premium_navbar_tab.fingerprints.AddPremiumNavbarTabFingerprint import app.revanced.patches.spotify.premium_navbar_tab.fingerprints.AddPremiumNavbarTabParentFingerprint @@ -29,9 +29,9 @@ class PremiumNavbarTabPatch : BytecodePatch( AddPremiumNavbarTabParentFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val parentResult = AddPremiumNavbarTabParentFingerprint.result!! - AddPremiumNavbarTabFingerprint.resolve(data, parentResult.classDef) + AddPremiumNavbarTabFingerprint.resolve(context, parentResult.classDef) val result = AddPremiumNavbarTabFingerprint.result!! @@ -39,7 +39,8 @@ class PremiumNavbarTabPatch : BytecodePatch( val methodInstructions = method.implementation!!.instructions val lastInstructionIdx = methodInstructions.size - 1 - val premiumTabId = ResourceMappingResourcePatch.resourceMappings.single{it.type == "id" && it.name == "premium_tab"}.id + val premiumTabId = + ResourceMappingResourcePatch.resourceMappings.single { it.type == "id" && it.name == "premium_tab" }.id var removeAmount = 2 // 2nd const remove method diff --git a/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/ConvertHelpFeedItemListFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/ConvertHelpFeedItemListFingerprint.kt index dce123f60..e3c6d4b61 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/ConvertHelpFeedItemListFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/ConvertHelpFeedItemListFingerprint.kt @@ -2,15 +2,10 @@ package app.revanced.patches.tiktok.ad.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.ad.annotations.TiktokAdsCompatibility @Name("convert-help-v2-feeditemlist-fingerprint") -@MatchingMethod( - "Lbeancopy/ConvertHelp;", - "com${'$'}ss${'$'}ugc${'$'}aweme${'$'}proto${'$'}aweme_v2_feed_response${'$'}${'$'}com${'$'}ss${'$'}android${'$'}ugc${'$'}aweme${'$'}feed${'$'}model${'$'}FeedItemList", -) @TiktokAdsCompatibility @Version("0.0.1") object ConvertHelpFeedItemListFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/FeedItemListCloneFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/FeedItemListCloneFingerprint.kt index 875277f9a..7b2e3e017 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/FeedItemListCloneFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/ad/fingerprints/FeedItemListCloneFingerprint.kt @@ -2,15 +2,10 @@ package app.revanced.patches.tiktok.ad.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.ad.annotations.TiktokAdsCompatibility @Name("feed-item-clone-fingerprint") -@MatchingMethod( - "Lcom/ss/android/ugc/aweme/feed/model/FeedItemList;", - "clone", -) @TiktokAdsCompatibility @Version("0.0.1") object FeedItemListCloneFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/ad/patch/TiktokAdsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/ad/patch/TiktokAdsPatch.kt index 2c910143d..b79f994b1 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/ad/patch/TiktokAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/ad/patch/TiktokAdsPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.tiktok.ad.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.tiktok.ad.annotations.TiktokAdsCompatibility import app.revanced.patches.tiktok.ad.fingerprints.ConvertHelpFeedItemListFingerprint import app.revanced.patches.tiktok.ad.fingerprints.FeedItemListCloneFingerprint @@ -29,7 +29,7 @@ class TiktokAdsPatch : BytecodePatch( ConvertHelpFeedItemListFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { listOf( FeedItemListCloneFingerprint, ConvertHelpFeedItemListFingerprint diff --git a/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/fingerprints/FeedApiServiceLIZFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/fingerprints/FeedApiServiceLIZFingerprint.kt index 987299029..8a17f48b0 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/fingerprints/FeedApiServiceLIZFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/fingerprints/FeedApiServiceLIZFingerprint.kt @@ -3,16 +3,11 @@ package app.revanced.patches.tiktok.feedfilter.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.feedfilter.annotations.FeedFilterCompatibility import org.jf.dexlib2.AccessFlags @Name("feed-api-service-fingerprint") -@MatchingMethod( - "Lcom/ss/android/ugc/aweme/feed/FeedApiService;", - "LIZ", -) @FeedFilterCompatibility @Version("0.0.1") object FeedApiServiceLIZFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/patch/TiktokFeedFilter.kt b/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/patch/TiktokFeedFilter.kt index a31ed3b3b..1717e9ab2 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/patch/TiktokFeedFilter.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/patch/TiktokFeedFilter.kt @@ -3,13 +3,13 @@ package app.revanced.patches.tiktok.feedfilter.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.tiktok.feedfilter.annotations.FeedFilterCompatibility import app.revanced.patches.tiktok.feedfilter.fingerprints.FeedApiServiceLIZFingerprint import app.revanced.patches.tiktok.misc.integrations.patch.TikTokIntegrationsPatch @@ -30,7 +30,7 @@ class TiktokFeedFilter : BytecodePatch( SettingsStatusLoadFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val method = FeedApiServiceLIZFingerprint.result!!.mutableMethod for ((index, instruction) in method.implementation!!.instructions.withIndex()) { if (instruction.opcode != Opcode.RETURN_OBJECT) continue diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint.kt index 8fcc3ad78..a6a53337b 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint.kt @@ -3,13 +3,11 @@ package app.revanced.patches.tiktok.interaction.downloads.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.interaction.downloads.annotations.DownloadsCompatibility import org.jf.dexlib2.AccessFlags @Name("acl-common-share-get-code") -@MatchingMethod("ACLCommonShare", "getCode") @DownloadsCompatibility @Version("0.0.1") object ACLCommonShareFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint2.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint2.kt index 33bb8a8b3..384530db7 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint2.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint2.kt @@ -3,13 +3,11 @@ package app.revanced.patches.tiktok.interaction.downloads.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.interaction.downloads.annotations.DownloadsCompatibility import org.jf.dexlib2.AccessFlags @Name("acl-common-share-get-show-type") -@MatchingMethod("ACLCommonShare", "getShowType") @DownloadsCompatibility @Version("0.0.1") object ACLCommonShareFingerprint2 : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint3.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint3.kt index 59120277d..cf585dd21 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint3.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint3.kt @@ -3,13 +3,11 @@ package app.revanced.patches.tiktok.interaction.downloads.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.interaction.downloads.annotations.DownloadsCompatibility import org.jf.dexlib2.AccessFlags @Name("acl-common-share-get-transcode") -@MatchingMethod("ACLCommonShare", "getTranscode") @DownloadsCompatibility @Version("0.0.1") object ACLCommonShareFingerprint3 : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/DownloadPathParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/DownloadPathParentFingerprint.kt index dda746765..56d5469b2 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/DownloadPathParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/DownloadPathParentFingerprint.kt @@ -3,13 +3,11 @@ package app.revanced.patches.tiktok.interaction.downloads.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.interaction.downloads.annotations.DownloadsCompatibility import org.jf.dexlib2.AccessFlags @Name("download-path-parent-fingerprint") -@MatchingMethod("LX/4bF;", "LIZ") @DownloadsCompatibility @Version("0.0.1") object DownloadPathParentFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt index 87902350c..ed5237f55 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt @@ -3,18 +3,18 @@ package app.revanced.patches.tiktok.interaction.downloads.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData -import app.revanced.patcher.data.impl.toMethodWalker +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.toMethodWalker import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.extensions.replaceInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.tiktok.interaction.downloads.annotations.DownloadsCompatibility import app.revanced.patches.tiktok.interaction.downloads.fingerprints.ACLCommonShareFingerprint @@ -44,7 +44,7 @@ class DownloadsPatch : BytecodePatch( SettingsStatusLoadFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val method1 = ACLCommonShareFingerprint.result!!.mutableMethod method1.replaceInstructions( 0, @@ -92,7 +92,7 @@ class DownloadsPatch : BytecodePatch( } if (targetOffset == -1) return PatchResultError("Can not find download path uri method.") //Change videos' download path. - val downloadUriMethod = data + val downloadUriMethod = context .toMethodWalker(DownloadPathParentFingerprint.result!!.method) .nextMethod(targetOffset, true) .getMethod() as MutableMethod diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/fingerprints/AwemeGetVideoControlFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/fingerprints/AwemeGetVideoControlFingerprint.kt index a52db973c..00cc75328 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/fingerprints/AwemeGetVideoControlFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/fingerprints/AwemeGetVideoControlFingerprint.kt @@ -2,13 +2,11 @@ package app.revanced.patches.tiktok.interaction.seekbar.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.interaction.seekbar.annotations.SeekbarCompatibility import org.jf.dexlib2.AccessFlags @Name("aweme-get-video-control") -@MatchingMethod("Aweme", "getVideoControl") @SeekbarCompatibility @Version("0.0.1") object AwemeGetVideoControlFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/TiktokSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/TiktokSeekbarPatch.kt index 90ecf04e5..2948263e2 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/TiktokSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/TiktokSeekbarPatch.kt @@ -3,15 +3,15 @@ package app.revanced.patches.tiktok.interaction.seekbar.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.tiktok.interaction.seekbar.annotations.SeekbarCompatibility -import app.revanced.patches.tiktok.interaction.seekbar.fingerprints.* +import app.revanced.patches.tiktok.interaction.seekbar.fingerprints.AwemeGetVideoControlFingerprint import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction11n import org.jf.dexlib2.builder.instruction.BuilderInstruction22c @@ -26,9 +26,9 @@ class TiktokSeekbarPatch : BytecodePatch( AwemeGetVideoControlFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { //Get VideoControl FieldReference - val videoControl = data.findClass { it.type.endsWith("/VideoControl;") } + val videoControl = context.findClass { it.type.endsWith("/VideoControl;") } ?: return PatchResultError("Can not find target class") val fieldList = videoControl.immutableClass.fields.associateBy { field -> field.name } diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/fingerprints/SpeedControlParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/fingerprints/SpeedControlParentFingerprint.kt index 73ea3df3a..bdce80e1e 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/fingerprints/SpeedControlParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/fingerprints/SpeedControlParentFingerprint.kt @@ -3,13 +3,11 @@ package app.revanced.patches.tiktok.interaction.speed.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.interaction.speed.annotations.SpeedCompatibility import org.jf.dexlib2.AccessFlags @Name("speed-control-parent-fingerprint") -@MatchingMethod("LX/4cP;", "LJIILL") @SpeedCompatibility @Version("0.0.1") object SpeedControlParentFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/patch/SpeedPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/patch/SpeedPatch.kt index 28152195c..1023fc0d8 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/patch/SpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/patch/SpeedPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.tiktok.interaction.speed.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData -import app.revanced.patcher.data.impl.toMethodWalker +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.toMethodWalker import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.tiktok.interaction.speed.annotations.SpeedCompatibility import app.revanced.patches.tiktok.interaction.speed.fingerprints.SpeedControlParentFingerprint @@ -25,12 +25,12 @@ class SpeedPatch : BytecodePatch( SpeedControlParentFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val parentMethod = SpeedControlParentFingerprint.result!!.mutableMethod val parentMethodInstructions = parentMethod.implementation!!.instructions for ((index, instruction) in parentMethodInstructions.withIndex()) { if (instruction.opcode != Opcode.INVOKE_VIRTUAL) continue - val isSpeedEnableMethod = data + val isSpeedEnableMethod = context .toMethodWalker(parentMethod) .nextMethod(index, true) .getMethod() as MutableMethod diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/fingerprints/MandatoryLoginServiceFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/fingerprints/MandatoryLoginServiceFingerprint.kt index 8c1b85847..85bf2f931 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/fingerprints/MandatoryLoginServiceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/fingerprints/MandatoryLoginServiceFingerprint.kt @@ -2,12 +2,10 @@ package app.revanced.patches.tiktok.misc.forcelogin.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.misc.forcelogin.annotations.DisableForceLoginCompatibility @Name("mandatory-login-service-fingerprint") -@MatchingMethod("/MandatoryLoginService;", "enableForcedLogin") @DisableForceLoginCompatibility @Version("0.0.1") object MandatoryLoginServiceFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/fingerprints/MandatoryLoginServiceFingerprint2.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/fingerprints/MandatoryLoginServiceFingerprint2.kt index 7c3e51edc..62eabf353 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/fingerprints/MandatoryLoginServiceFingerprint2.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/fingerprints/MandatoryLoginServiceFingerprint2.kt @@ -2,12 +2,10 @@ package app.revanced.patches.tiktok.misc.forcelogin.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.misc.forcelogin.annotations.DisableForceLoginCompatibility @Name("mandatory-login-service-fingerprint2") -@MatchingMethod("/MandatoryLoginService;", "shouldShowForcedLogin") @DisableForceLoginCompatibility @Version("0.0.1") object MandatoryLoginServiceFingerprint2 : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/patch/DisableForceLoginPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/patch/DisableForceLoginPatch.kt index 8f36d5d1d..928c912a2 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/patch/DisableForceLoginPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/patch/DisableForceLoginPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.tiktok.misc.forcelogin.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.tiktok.misc.forcelogin.annotations.DisableForceLoginCompatibility import app.revanced.patches.tiktok.misc.forcelogin.fingerprints.MandatoryLoginServiceFingerprint import app.revanced.patches.tiktok.misc.forcelogin.fingerprints.MandatoryLoginServiceFingerprint2 @@ -24,7 +24,7 @@ class DisableForceLoginPatch : BytecodePatch( MandatoryLoginServiceFingerprint2 ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { listOf( MandatoryLoginServiceFingerprint, MandatoryLoginServiceFingerprint2 diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/fingerprints/InitFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/fingerprints/InitFingerprint.kt index eb9189665..1fd49a59e 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/fingerprints/InitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/fingerprints/InitFingerprint.kt @@ -2,14 +2,10 @@ package app.revanced.patches.tiktok.misc.integrations.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.misc.integrations.annotations.TikTokIntegrationsCompatibility @Name("init-fingerprint") -@MatchingMethod( - "Lcom/ss/android/ugc/aweme/app/host/AwemeHostApplication;", "onCreate" -) @TikTokIntegrationsCompatibility @Version("0.0.1") object InitFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/patch/TikTokIntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/patch/TikTokIntegrationsPatch.kt index 14e6ba1b0..79780d1dd 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/patch/TikTokIntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/patch/TikTokIntegrationsPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.tiktok.misc.integrations.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.tiktok.misc.integrations.annotations.TikTokIntegrationsCompatibility import app.revanced.patches.tiktok.misc.integrations.fingerprints.InitFingerprint @@ -21,8 +21,8 @@ class TikTokIntegrationsPatch : BytecodePatch( InitFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { - if (data.findClass("Lapp/revanced/tiktok/utils/ReVancedUtils") == null) + override fun execute(context: BytecodeContext): PatchResult { + if (context.findClass("Lapp/revanced/tiktok/utils/ReVancedUtils") == null) return PatchResultError("Integrations have not been merged yet. This patch can not succeed without the integrations.") val result = InitFingerprint.result!! diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/AdPersonalizationActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/AdPersonalizationActivityFingerprint.kt index 2a6ee3690..66e58ebac 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/AdPersonalizationActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/AdPersonalizationActivityFingerprint.kt @@ -2,15 +2,10 @@ package app.revanced.patches.tiktok.misc.settings.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility @Name("ad-personalization-activity-fingerprint") -@MatchingMethod( - "Lcom/bytedance/ies/ugc/aweme/commercialize/compliance/personalization/AdPersonalizationActivity;", - "onCreate" -) @TikTokSettingsCompatibility @Version("0.0.1") object AdPersonalizationActivityFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/CopyRightSettingsStringFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/CopyRightSettingsStringFingerprint.kt index a818e2867..c1e8650f2 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/CopyRightSettingsStringFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/CopyRightSettingsStringFingerprint.kt @@ -2,15 +2,10 @@ package app.revanced.patches.tiktok.misc.settings.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility @Name("copyright-settings-string-fingerprint") -@MatchingMethod( - "Lcom/ss/android/ugc/aweme/setting/ui/SettingNewVersionFragment;", - "onViewCreated" -) @TikTokSettingsCompatibility @Version("0.0.1") object CopyRightSettingsStringFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/SettingsStatusLoadFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/SettingsStatusLoadFingerprint.kt index 8a2a0f96b..7b759956a 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/SettingsStatusLoadFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/fingerprints/SettingsStatusLoadFingerprint.kt @@ -2,15 +2,10 @@ package app.revanced.patches.tiktok.misc.settings.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility @Name("settings-status-load-fingerprint") -@MatchingMethod( - "Lapp/revanced/tiktok/settingsmenu/SettingsStatus;", - "load" -) @TikTokSettingsCompatibility @Version("0.0.1") object SettingsStatusLoadFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/TikTokSettingsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/TikTokSettingsPatch.kt index cb561f9cb..5e7122718 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/TikTokSettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/TikTokSettingsPatch.kt @@ -3,15 +3,15 @@ package app.revanced.patches.tiktok.misc.settings.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.tiktok.misc.integrations.patch.TikTokIntegrationsPatch import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility import app.revanced.patches.tiktok.misc.settings.fingerprints.AdPersonalizationActivityFingerprint @@ -35,7 +35,7 @@ class TikTokSettingsPatch : BytecodePatch( CopyRightSettingsStringFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { //Replace string `Copyright Policy` to 'Revanced Settings` in TikTok settings. val method1 = CopyRightSettingsStringFingerprint.result!!.mutableMethod val implementation1 = method1.implementation!! @@ -66,7 +66,7 @@ class TikTokSettingsPatch : BytecodePatch( if (clickInstruction.opcode != Opcode.INVOKE_DIRECT) return PatchResultError("Can not find click listener.") val clickClass = ((clickInstruction as ReferenceInstruction).reference as MethodReference).definingClass - val mutableClickClass = data.findClass(clickClass)!!.resolve() + val mutableClickClass = context.findClass(clickClass)!!.mutableClass val mutableOnClickMethod = mutableClickClass.methods.first { it.name == "onClick" } diff --git a/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/fingerprints/TimelineTweetJsonParserFingerprint.kt b/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/fingerprints/TimelineTweetJsonParserFingerprint.kt index 3894aa5aa..b38cd77ab 100644 --- a/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/fingerprints/TimelineTweetJsonParserFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/fingerprints/TimelineTweetJsonParserFingerprint.kt @@ -2,13 +2,11 @@ package app.revanced.patches.twitter.ad.timeline.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.twitter.ad.timeline.annotations.TimelineAdsCompatibility import org.jf.dexlib2.Opcode @Name("timeline-tweet-json-parser-fingerprint") -@MatchingMethod("LJsonTimelineTweet\$\$JsonObjectMapper;", "parseField") @TimelineAdsCompatibility @Version("0.0.1") object TimelineTweetJsonParserFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/patch/TimelineAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/patch/TimelineAdsPatch.kt index 425d80f8f..c8722e0c7 100644 --- a/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/patch/TimelineAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/patch/TimelineAdsPatch.kt @@ -3,16 +3,16 @@ package app.revanced.patches.twitter.ad.timeline.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.instruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.twitter.ad.timeline.annotations.TimelineAdsCompatibility import app.revanced.patches.twitter.ad.timeline.fingerprints.TimelineTweetJsonParserFingerprint @@ -31,7 +31,7 @@ import org.jf.dexlib2.iface.reference.StringReference class TimelineAdsPatch : BytecodePatch( listOf(TimelineTweetJsonParserFingerprint) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { if (removePromotedAds()) return PatchResultError("The instruction for the tweet id field could not be found") diff --git a/src/main/kotlin/app/revanced/patches/twitter/misc/dynamiccolor/patch/DynamicColorPatch.kt b/src/main/kotlin/app/revanced/patches/twitter/misc/dynamiccolor/patch/DynamicColorPatch.kt index 85ffd63f7..3ba3b564c 100644 --- a/src/main/kotlin/app/revanced/patches/twitter/misc/dynamiccolor/patch/DynamicColorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitter/misc/dynamiccolor/patch/DynamicColorPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.twitter.misc.dynamiccolor.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.twitter.misc.dynamiccolor.annotations.DynamicColorCompatibility import java.io.FileWriter import java.nio.file.Files @@ -18,9 +18,9 @@ import java.nio.file.Files @Description("Replaces the default Twitter Blue with the users Material You palette.") @DynamicColorCompatibility @Version("0.0.1") -class DynamicColorPatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { - val resDirectory = data["res"] +class DynamicColorPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + val resDirectory = context["res"] if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.") val valuesV31Directory = resDirectory.resolve("values-v31") @@ -39,7 +39,7 @@ class DynamicColorPatch : ResourcePatch() { } } - data.xmlEditor["res/values-v31/colors.xml"].use { editor -> + context.xmlEditor["res/values-v31/colors.xml"].use { editor -> val document = editor.file mapOf( @@ -62,7 +62,7 @@ class DynamicColorPatch : ResourcePatch() { } } - data.xmlEditor["res/values-night-v31/colors.xml"].use { editor -> + context.xmlEditor["res/values-night-v31/colors.xml"].use { editor -> val document = editor.file mapOf( diff --git a/src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/patch/MonochromeIconPatch.kt b/src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/patch/MonochromeIconPatch.kt index d5936c7c2..6e83ca519 100644 --- a/src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/patch/MonochromeIconPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitter/misc/monochrome/patch/MonochromeIconPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.twitter.misc.monochrome.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.twitter.misc.monochrome.annotations.MonochromeIconCompatibility import java.io.FileWriter import java.nio.file.Files @@ -18,9 +18,9 @@ import java.nio.file.Files @Description("Adds a monochrome icon.") @MonochromeIconCompatibility @Version("0.0.1") -class MonochromeIconPatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { - val resDirectory = data["res"] +class MonochromeIconPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + val resDirectory = context["res"] if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.") val mipmapV33Directory = resDirectory.resolve("mipmap-anydpi-v33") diff --git a/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/fingerprints/GetCertMessagingFingerprint.kt b/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/fingerprints/GetCertMessagingFingerprint.kt index 6f94634c0..b326c34c8 100644 --- a/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/fingerprints/GetCertMessagingFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/fingerprints/GetCertMessagingFingerprint.kt @@ -2,14 +2,10 @@ package app.revanced.patches.warnwetter.misc.firebasegetcert.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.warnwetter.misc.firebasegetcert.annotations.FirebaseGetCertPatchCompatibility @Name("messaging-app-certificate-fingerprint") -@MatchingMethod( - "Lcom/google/firebase/installations/remote/c;", "f" -) @FirebaseGetCertPatchCompatibility @Version("0.0.1") object GetMessagingCertFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/fingerprints/GetCertRegistrationFingerprint.kt b/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/fingerprints/GetCertRegistrationFingerprint.kt index 8a19a2338..80963b507 100644 --- a/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/fingerprints/GetCertRegistrationFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/fingerprints/GetCertRegistrationFingerprint.kt @@ -2,14 +2,10 @@ package app.revanced.patches.warnwetter.misc.firebasegetcert.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.warnwetter.misc.firebasegetcert.annotations.FirebaseGetCertPatchCompatibility @Name("registration-app-certificate-fingerprint") -@MatchingMethod( - "Lcom/google/firebase/remoteconfig/internal/ConfigFetchHttpClient;", "f" -) @FirebaseGetCertPatchCompatibility @Version("0.0.1") object GetReqistrationCertFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/patch/FirebaseGetCertPatch.kt b/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/patch/FirebaseGetCertPatch.kt index e4a12df4a..c7dd384d4 100644 --- a/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/patch/FirebaseGetCertPatch.kt +++ b/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/patch/FirebaseGetCertPatch.kt @@ -3,13 +3,14 @@ package app.revanced.patches.warnwetter.misc.firebasegetcert.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.impl.BytecodePatch -import app.revanced.patches.warnwetter.misc.firebasegetcert.fingerprints.* import app.revanced.patches.warnwetter.misc.firebasegetcert.annotations.FirebaseGetCertPatchCompatibility +import app.revanced.patches.warnwetter.misc.firebasegetcert.fingerprints.GetMessagingCertFingerprint +import app.revanced.patches.warnwetter.misc.firebasegetcert.fingerprints.GetReqistrationCertFingerprint @Name("spoof-cert-patch") @Description("Spoofs the X-Android-Cert header.") @@ -21,7 +22,7 @@ class FirebaseGetCertPatch : BytecodePatch( GetMessagingCertFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val spoofedInstruction = """ const-string v0, "0799DDF0414D3B3475E88743C91C0676793ED450" diff --git a/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/fingerprints/PromoCodeUnlockFingerprint.kt b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/fingerprints/PromoCodeUnlockFingerprint.kt index bf1158403..7f6402419 100644 --- a/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/fingerprints/PromoCodeUnlockFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/fingerprints/PromoCodeUnlockFingerprint.kt @@ -2,14 +2,10 @@ package app.revanced.patches.warnwetter.misc.promocode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.warnwetter.misc.promocode.annotations.PromoCodeUnlockCompatibility @Name("promo-code-unlock-fingerprint") -@MatchingMethod( - "Lde/dwd/warnapp/model/PromoTokenVerification;", "isValid" -) @PromoCodeUnlockCompatibility @Version("0.0.1") object PromoCodeUnlockFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt index 6da25f1df..68ee1de05 100644 --- a/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.warnwetter.misc.promocode.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.warnwetter.misc.firebasegetcert.patch.FirebaseGetCertPatch import app.revanced.patches.warnwetter.misc.promocode.annotations.PromoCodeUnlockCompatibility import app.revanced.patches.warnwetter.misc.promocode.fingerprints.PromoCodeUnlockFingerprint @@ -30,7 +30,7 @@ class PromoCodeUnlockPatch : BytecodePatch( ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val method = PromoCodeUnlockFingerprint.result!!.mutableMethod method.addInstructions( 0, diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt index 2eff59a84..b6eab675e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt @@ -4,17 +4,17 @@ import app.revanced.extensions.injectHideCall import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.instruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel @@ -67,7 +67,7 @@ class GeneralBytecodeAdsPatch : BytecodePatch() { "LoggingProperties are not in proto format" ) - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.ADS.addPreferences( SwitchPreference( "revanced_home_ads_removal", @@ -191,7 +191,7 @@ class GeneralBytecodeAdsPatch : BytecodePatch() { ) // iterating through all classes is expensive - for (classDef in data.classes) { + for (classDef in context.classes) { var mutableClass: MutableClass? = null method@ for (method in classDef.methods) { @@ -213,7 +213,7 @@ class GeneralBytecodeAdsPatch : BytecodePatch() { if (invokeInstruction.opcode != Opcode.INVOKE_VIRTUAL) return@forEachIndexed // create proxied method, make sure to not re-resolve() the current class - if (mutableClass == null) mutableClass = data.proxy(classDef).resolve() + if (mutableClass == null) mutableClass = context.proxy(classDef).mutableClass if (mutableMethod == null) mutableMethod = mutableClass!!.findMutableMethodOf(method) @@ -230,7 +230,7 @@ class GeneralBytecodeAdsPatch : BytecodePatch() { if (iPutInstruction.opcode != Opcode.IPUT_OBJECT) return@forEachIndexed // create proxied method, make sure to not re-resolve() the current class - if (mutableClass == null) mutableClass = data.proxy(classDef).resolve() + if (mutableClass == null) mutableClass = context.proxy(classDef).mutableClass if (mutableMethod == null) mutableMethod = mutableClass!!.findMutableMethodOf(method) @@ -245,7 +245,7 @@ class GeneralBytecodeAdsPatch : BytecodePatch() { if (invokeInstruction.opcode != Opcode.INVOKE_VIRTUAL) return@forEachIndexed // create proxied method, make sure to not re-resolve() the current class - if (mutableClass == null) mutableClass = data.proxy(classDef).resolve() + if (mutableClass == null) mutableClass = context.proxy(classDef).mutableClass if (mutableMethod == null) mutableMethod = mutableClass!!.findMutableMethodOf(method) @@ -260,7 +260,7 @@ class GeneralBytecodeAdsPatch : BytecodePatch() { if (invokeInstruction.opcode != Opcode.IPUT_OBJECT) return@forEachIndexed // create proxied method, make sure to not re-resolve() the current class - if (mutableClass == null) mutableClass = data.proxy(classDef).resolve() + if (mutableClass == null) mutableClass = context.proxy(classDef).mutableClass if (mutableMethod == null) mutableMethod = mutableClass!!.findMutableMethodOf(method) @@ -280,7 +280,7 @@ class GeneralBytecodeAdsPatch : BytecodePatch() { if (invokeInstruction.opcode != Opcode.INVOKE_DIRECT) return@forEachIndexed // create proxied method, make sure to not re-resolve() the current class - if (mutableClass == null) mutableClass = data.proxy(classDef).resolve() + if (mutableClass == null) mutableClass = context.proxy(classDef).mutableClass if (mutableMethod == null) mutableMethod = mutableClass!!.findMutableMethodOf(method) @@ -302,7 +302,7 @@ class GeneralBytecodeAdsPatch : BytecodePatch() { if (stringInstruction.opcode == Opcode.CONST_STRING) return@forEachIndexed // create proxied method, make sure to not re-resolve() the current class - if (mutableClass == null) mutableClass = data.proxy(classDef).resolve() + if (mutableClass == null) mutableClass = context.proxy(classDef).mutableClass if (mutableMethod == null) mutableMethod = mutableClass!!.findMutableMethodOf(method) @@ -319,8 +319,8 @@ class GeneralBytecodeAdsPatch : BytecodePatch() { } stringReferences[2] -> { // Litho ads - val proxy = data.proxy(classDef) - val proxiedClass = proxy.resolve() + val proxy = context.proxy(classDef) + val proxiedClass = proxy.mutableClass val lithoMethod = getLithoMethod(proxiedClass) ?: return PatchResultError("Could not find required Litho method to patch.") @@ -347,7 +347,7 @@ class GeneralBytecodeAdsPatch : BytecodePatch() { ) {} val pathBuilderScanResult = pathBuilderAnchorFingerprint.also { - it.resolve(data, lithoMethod, classDef) + it.resolve(context, lithoMethod, classDef) }.result!!.scanResult.patternScanResult!! val clobberedRegister = diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsFingerprint.kt index a6e9bc3e9..44a544909 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsFingerprint.kt @@ -4,13 +4,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.ad.infocardsuggestions.annotations.HideInfocardSuggestionsCompatibility import org.jf.dexlib2.AccessFlags @Name("hide-infocard-suggestions-fingerprint") -@MatchingMethod("Liff;", "i") @FuzzyPatternScanMethod(2) @HideInfocardSuggestionsCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsParentFingerprint.kt index 4964f90ae..034eb3018 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsParentFingerprint.kt @@ -4,13 +4,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.ad.infocardsuggestions.annotations.HideInfocardSuggestionsCompatibility import org.jf.dexlib2.AccessFlags @Name("hide-infocard-suggestions-parent-fingerprint") -@MatchingMethod("Liff;", "lE") @FuzzyPatternScanMethod(2) @HideInfocardSuggestionsCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/patch/HideInfocardSuggestionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/patch/HideInfocardSuggestionsPatch.kt index 7a3e62ada..a5b0fed07 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/patch/HideInfocardSuggestionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/patch/HideInfocardSuggestionsPatch.kt @@ -3,15 +3,15 @@ package app.revanced.patches.youtube.ad.infocardsuggestions.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.ad.infocardsuggestions.annotations.HideInfocardSuggestionsCompatibility import app.revanced.patches.youtube.ad.infocardsuggestions.fingerprints.HideInfocardSuggestionsFingerprint import app.revanced.patches.youtube.ad.infocardsuggestions.fingerprints.HideInfocardSuggestionsParentFingerprint @@ -32,7 +32,7 @@ class HideInfocardSuggestionsPatch : BytecodePatch( HideInfocardSuggestionsParentFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.ADS.addPreferences( SwitchPreference( "revanced_info_cards_enabled", @@ -47,7 +47,7 @@ class HideInfocardSuggestionsPatch : BytecodePatch( ?: return PatchResultError("Parent fingerprint not resolved!") - HideInfocardSuggestionsFingerprint.resolve(data, parentResult.classDef) + HideInfocardSuggestionsFingerprint.resolve(context, parentResult.classDef) val result = HideInfocardSuggestionsFingerprint.result ?: return PatchResultError("Required parent method could not be found.") diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsConstructorFingerprint.kt index 009379a6b..418f5c1d2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsConstructorFingerprint.kt @@ -3,18 +3,13 @@ package app.revanced.patches.youtube.ad.video.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("show-video-ads-constructor-fingerprint") -@MatchingMethod( - "Laair", - "", -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @VideoAdsCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsFingerprint.kt index 4219e8f81..2d1c09cfc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsFingerprint.kt @@ -3,17 +3,13 @@ package app.revanced.patches.youtube.ad.video.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility import org.jf.dexlib2.AccessFlags @Name("show-video-ads-method-fingerprint") -@MatchingMethod( - definingClass = "zai" -) -@DirectPatternScanMethod + @VideoAdsCompatibility @Version("0.0.1") object ShowVideoAdsFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt index cda422408..fbeb1fe9f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt @@ -3,14 +3,14 @@ package app.revanced.patches.youtube.ad.video.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility import app.revanced.patches.youtube.ad.video.fingerprints.ShowVideoAdsConstructorFingerprint import app.revanced.patches.youtube.ad.video.fingerprints.ShowVideoAdsFingerprint @@ -30,7 +30,7 @@ class VideoAdsPatch : BytecodePatch( ShowVideoAdsConstructorFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.ADS.addPreferences( SwitchPreference( "revanced_video_ads_removal", @@ -42,7 +42,7 @@ class VideoAdsPatch : BytecodePatch( ) ShowVideoAdsFingerprint.resolve( - data, ShowVideoAdsConstructorFingerprint.result!!.classDef + context, ShowVideoAdsConstructorFingerprint.result!!.classDef ) // Override the parameter by calling shouldShowAds and setting the parameter to the result diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/DownloadsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/DownloadsBytecodePatch.kt index 57db4d2bb..2b9de008d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/DownloadsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/bytecode/patch/DownloadsBytecodePatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.youtube.interaction.downloads.bytecode.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.interaction.downloads.annotation.DownloadsCompatibility import app.revanced.patches.youtube.interaction.downloads.resource.patch.DownloadsResourcePatch import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch @@ -21,7 +21,7 @@ import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch @DownloadsCompatibility @Version("0.0.1") class DownloadsBytecodePatch : BytecodePatch() { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val integrationsPackage = "app/revanced/integrations" val classDescriptor = "L$integrationsPackage/videoplayer/DownloadButton;" diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt index 072ffa158..9c59df08e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/resource/patch/DownloadsResourcePatch.kt @@ -3,11 +3,11 @@ package app.revanced.patches.youtube.interaction.downloads.resource.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.interaction.downloads.annotation.DownloadsCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.playercontrols.resource.patch.BottomControlsResourcePatch @@ -22,8 +22,8 @@ import app.revanced.util.resources.ResourceUtils.copyResources @Description("Makes necessary changes to resources for the download button.") @DownloadsCompatibility @Version("0.0.1") -class DownloadsResourcePatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { +class DownloadsResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( PreferenceScreen( "revanced_downloads", @@ -53,13 +53,13 @@ class DownloadsResourcePatch : ResourcePatch() { * Copy strings */ - data.mergeStrings("downloads/host/values/strings.xml") + context.mergeStrings("downloads/host/values/strings.xml") /* * Copy resources */ - data.copyResources("downloads", ResourceUtils.ResourceGroup("drawable", "revanced_yt_download_button.xml")) + context.copyResources("downloads", ResourceUtils.ResourceGroup("drawable", "revanced_yt_download_button.xml")) /* * Add download button node diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt index c26c7a524..42117f869 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt @@ -3,15 +3,13 @@ package app.revanced.patches.youtube.interaction.seekbar.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("enable-seekbar-tapping-fingerprint") -@MatchingMethod("Lfbl;", "onTouchEvent") @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @SeekbarTappingCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt index f2d467090..a0c4a234b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt @@ -3,15 +3,13 @@ package app.revanced.patches.youtube.interaction.seekbar.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("enable-seekbar-tapping-parent-fingerprint") -@MatchingMethod("Lzmx;", "I") @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @SeekbarTappingCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt index b1c5a4d55..0fb295aa8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt @@ -3,14 +3,14 @@ package app.revanced.patches.youtube.interaction.seekbar.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingFingerprint import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingParentFingerprint @@ -35,7 +35,7 @@ class EnableSeekbarTappingPatch : BytecodePatch( SeekbarTappingParentFingerprint, SeekbarTappingFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( SwitchPreference( "revanced_enable_tap_seeking", diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/SwipeControlsHostActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/SwipeControlsHostActivityFingerprint.kt index 014977fc2..3a03066db 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/SwipeControlsHostActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/SwipeControlsHostActivityFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.youtube.interaction.swipecontrols.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility @Name("swipe-controls-host-activity-fingerprint") -@MatchingMethod( - "Lapp/revanced/integrations/swipecontrols/SwipeControlsHostActivity;", "" -) -@DirectPatternScanMethod + @SwipeControlsCompatibility @Version("0.0.1") object SwipeControlsHostActivityFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/WatchWhileActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/WatchWhileActivityFingerprint.kt index 7704951b2..d587cffb1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/WatchWhileActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/fingerprints/WatchWhileActivityFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.youtube.interaction.swipecontrols.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility @Name("watch-while-activity-fingerprint") -@MatchingMethod( - "LWatchWhileActivity;", "" -) -@DirectPatternScanMethod + @SwipeControlsCompatibility @Version("0.0.1") object WatchWhileActivityFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/bytecode/SwipeControlsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/bytecode/SwipeControlsBytecodePatch.kt index e7cbd1ad3..19522ed95 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/bytecode/SwipeControlsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/bytecode/SwipeControlsBytecodePatch.kt @@ -5,12 +5,12 @@ import app.revanced.extensions.traverseClassHierarchy import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility import app.revanced.patches.youtube.interaction.swipecontrols.fingerprints.SwipeControlsHostActivityFingerprint @@ -39,7 +39,7 @@ class SwipeControlsBytecodePatch : BytecodePatch( SwipeControlsHostActivityFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val wrapperClass = SwipeControlsHostActivityFingerprint.result!!.mutableClass val targetClass = WatchWhileActivityFingerprint.result!!.mutableClass @@ -48,7 +48,7 @@ class SwipeControlsBytecodePatch : BytecodePatch( targetClass.setSuperClass(wrapperClass.type) // ensure all classes and methods in the hierarchy are non-final, so we can override them in integrations - data.traverseClassHierarchy(targetClass) { + context.traverseClassHierarchy(targetClass) { accessFlags = accessFlags and AccessFlags.FINAL.value.inv() transformMethods { ImmutableMethod( diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/resource/SwipeControlsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/resource/SwipeControlsResourcePatch.kt index 7db15e2ce..665345294 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/resource/SwipeControlsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/resource/SwipeControlsResourcePatch.kt @@ -2,11 +2,11 @@ package app.revanced.patches.youtube.interaction.swipecontrols.patch.resource import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.* @@ -17,8 +17,8 @@ import app.revanced.util.resources.ResourceUtils.copyResources @DependsOn([SettingsPatch::class]) @SwipeControlsCompatibility @Version("0.0.1") -class SwipeControlsResourcePatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { +class SwipeControlsResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( PreferenceScreen( "revanced_swipe_controls", StringResource("revanced_swipe_controls_title", "Swipe controls"), listOf( @@ -92,7 +92,7 @@ class SwipeControlsResourcePatch : ResourcePatch() { ) ) - data.copyResources( + context.copyResources( "swipecontrols", ResourceUtils.ResourceGroup( "drawable", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/StartVideoInformerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/StartVideoInformerFingerprint.kt index 590b2839e..265302619 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/StartVideoInformerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/StartVideoInformerFingerprint.kt @@ -4,14 +4,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.autocaptions.annotations.AutoCaptionsCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("start-video-informer-fingerprint") -@MatchingMethod("Laaxf;", "d") @FuzzyPatternScanMethod(3) @AutoCaptionsCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt index fec6f6c4b..49923e305 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt @@ -3,14 +3,12 @@ package app.revanced.patches.youtube.layout.autocaptions.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.autocaptions.annotations.AutoCaptionsCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("subtitle-button-controller-fingerprint") -@MatchingMethod("Lcom/google/android/apps/youtube/app/player/overlay/SubtitleButtonController;", "E") @AutoCaptionsCompatibility @Version("0.0.1") object SubtitleButtonControllerFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleTrackFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleTrackFingerprint.kt index a61000355..9a27b1d8f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleTrackFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleTrackFingerprint.kt @@ -3,14 +3,12 @@ package app.revanced.patches.youtube.layout.autocaptions.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.autocaptions.annotations.AutoCaptionsCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("subtitle-track-fingerprint") -@MatchingMethod("Lcom/google/android/libraries/youtube/player/subtitles/model/SubtitleTrack;", "t") @AutoCaptionsCompatibility @Version("0.0.1") object SubtitleTrackFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/patch/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/patch/AutoCaptionsPatch.kt index 9f5012cdb..9990da999 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/patch/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/patch/AutoCaptionsPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.autocaptions.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.autocaptions.annotations.AutoCaptionsCompatibility import app.revanced.patches.youtube.layout.autocaptions.fingerprints.StartVideoInformerFingerprint import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleButtonControllerFingerprint @@ -30,7 +30,7 @@ class AutoCaptionsPatch : BytecodePatch( StartVideoInformerFingerprint, SubtitleButtonControllerFingerprint, SubtitleTrackFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_autocaptions_enabled", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/fingerprints/AutoNavInformerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/fingerprints/AutoNavInformerFingerprint.kt index 3191a00bd..f11329271 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/fingerprints/AutoNavInformerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/fingerprints/AutoNavInformerFingerprint.kt @@ -3,16 +3,12 @@ package app.revanced.patches.youtube.layout.autoplaybutton.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.autoplaybutton.annotations.AutoplayButtonCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("autonav-informer-fingerprint") -@MatchingMethod( - "LWillAutonavInformer;", "k" -) @AutoplayButtonCompatibility @Version("0.0.1") object AutoNavInformerFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/fingerprints/LayoutConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/fingerprints/LayoutConstructorFingerprint.kt index ab1797cb4..4b96c8712 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/fingerprints/LayoutConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/fingerprints/LayoutConstructorFingerprint.kt @@ -2,14 +2,10 @@ package app.revanced.patches.youtube.layout.autoplaybutton.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.autoplaybutton.annotations.AutoplayButtonCompatibility @Name("layout-constructor-fingerprint") -@MatchingMethod( - "LYouTubeControlsOverlay;", "F" -) @AutoplayButtonCompatibility @Version("0.0.1") object LayoutConstructorFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/patch/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/patch/HideAutoplayButtonPatch.kt index 71c72e8d4..b3860c207 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/patch/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autoplaybutton/patch/HideAutoplayButtonPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.autoplaybutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.layout.autoplaybutton.annotations.AutoplayButtonCompatibility import app.revanced.patches.youtube.layout.autoplaybutton.fingerprints.AutoNavInformerFingerprint @@ -35,7 +35,7 @@ class HideAutoplayButtonPatch : BytecodePatch( LayoutConstructorFingerprint, AutoNavInformerFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_autoplay_button_enabled", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/patch/PremiumHeadingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/patch/PremiumHeadingPatch.kt index 431ab923f..83eca468f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/patch/PremiumHeadingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/patch/PremiumHeadingPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.branding.header.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.layout.branding.header.annotations.PremiumHeadingCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import java.nio.file.Files @@ -22,9 +22,9 @@ import kotlin.io.path.exists @Description("Shows premium branding on the home screen.") @PremiumHeadingCompatibility @Version("0.0.1") -class PremiumHeadingPatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { - val resDirectory = data["res"] +class PremiumHeadingPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + val resDirectory = context["res"] if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.") val (original, replacement) = "yt_premium_wordmark_header" to "yt_wordmark_header" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt index 3e3ad9872..847593b25 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt @@ -3,11 +3,10 @@ package app.revanced.patches.youtube.layout.branding.icon.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.* import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.layout.branding.icon.annotations.CustomBrandingCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import java.io.File @@ -21,9 +20,9 @@ import java.nio.file.Files @Description("Changes the YouTube launcher icon and name to your choice (defaults to ReVanced).") @CustomBrandingCompatibility @Version("0.0.1") -class CustomBrandingPatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { - val resDirectory = data["res"] +class CustomBrandingPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + val resDirectory = context["res"] if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.") // Icon branding @@ -53,7 +52,7 @@ class CustomBrandingPatch : ResourcePatch() { } // Name branding - val manifest = data["AndroidManifest.xml"] + val manifest = context["AndroidManifest.xml"] manifest.writeText( manifest.readText() .replace( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/patch/HideButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/patch/HideButtonsPatch.kt index 97fe0ffc4..335e848ca 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/patch/HideButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/patch/HideButtonsPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.youtube.layout.buttons.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch import app.revanced.patches.youtube.layout.buttons.annotations.HideButtonsCompatibility import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch @@ -23,8 +23,8 @@ import app.revanced.patches.youtube.misc.settings.framework.components.impl.Swit @Description("Adds options to hide action buttons under a video.") @HideButtonsCompatibility @Version("0.0.1") -class HideButtonsPatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { +class HideButtonsPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( PreferenceScreen( "revanced_hide_buttons", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt index 635e8c930..c37d2c5a8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.castbutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch @@ -23,7 +23,7 @@ import app.revanced.patches.youtube.misc.settings.framework.components.impl.Swit @CastButtonCompatibility @Version("0.0.1") class HideCastButtonPatch : BytecodePatch() { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_cast_button_enabled", @@ -34,11 +34,11 @@ class HideCastButtonPatch : BytecodePatch() { ) ) - data.classes.forEach { classDef -> + context.classes.forEach { classDef -> classDef.methods.forEach { method -> if (classDef.type.endsWith("MediaRouteButton;") && method.name == "setVisibility") { val setVisibilityMethod = - data.proxy(classDef).resolve().methods.first { it.name == "setVisibility" } + context.proxy(classDef).mutableClass.methods.first { it.name == "setVisibility" } setVisibilityMethod.addInstructions( 0, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt index 91937674b..d9770badb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt @@ -2,17 +2,12 @@ package app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.annotations.ShortsButtonCompatibility import org.jf.dexlib2.Opcode @Name("fullscreen-view-adder-fingerprint") -@MatchingMethod( - "LFullscreenEngagementPanelOverlay;", "e" -) -@DirectPatternScanMethod @ShortsButtonCompatibility @Version("0.0.1") object FullscreenViewAdderFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderParentFingerprint.kt index eaee7d91c..fae2675c4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderParentFingerprint.kt @@ -2,17 +2,12 @@ package app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.annotations.ShortsButtonCompatibility import org.jf.dexlib2.Opcode @Name("fullscreen-view-adder-parent-fingerprint") -@MatchingMethod( - "LFullscreenEngagementPanelOverlay;", "e" -) -@DirectPatternScanMethod @ShortsButtonCompatibility @Version("0.0.1") object FullscreenViewAdderParentFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt index 1cbe85f5b..b73d2404d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt @@ -3,16 +3,16 @@ package app.revanced.patches.youtube.layout.fullscreenpanels.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.fullscreenpanels.annotations.FullscreenPanelsCompatibility import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.FullscreenViewAdderParentFingerprint @@ -32,7 +32,7 @@ class FullscreenPanelsRemoverPatch : BytecodePatch( FullscreenViewAdderParentFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_fullscreen_panels_enabled", @@ -44,7 +44,7 @@ class FullscreenPanelsRemoverPatch : BytecodePatch( ) val parentResult = FullscreenViewAdderParentFingerprint.result!! - FullscreenViewAdderFingerprint.resolve(data, parentResult.method, parentResult.classDef) + FullscreenViewAdderFingerprint.resolve(context, parentResult.method, parentResult.classDef) val result = FullscreenViewAdderParentFingerprint.result ?: return PatchResultError("Fingerprint not resolved!") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hidetimeandseekbar/fingerprints/TimeCounterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hidetimeandseekbar/fingerprints/TimeCounterFingerprint.kt index c0a7a3c29..a619addf4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hidetimeandseekbar/fingerprints/TimeCounterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hidetimeandseekbar/fingerprints/TimeCounterFingerprint.kt @@ -4,14 +4,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.hidetimeandseekbar.annotations.HideTimeAndSeekbarCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("time-counter-fingerprint") -@MatchingMethod("Lfga", "pk") @FuzzyPatternScanMethod(3) @HideTimeAndSeekbarCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hidetimeandseekbar/patch/HideTimeAndSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hidetimeandseekbar/patch/HideTimeAndSeekbarPatch.kt index 87fd7cedc..09a221e76 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hidetimeandseekbar/patch/HideTimeAndSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hidetimeandseekbar/patch/HideTimeAndSeekbarPatch.kt @@ -3,15 +3,15 @@ package app.revanced.patches.youtube.layout.hidetimeandseekbar.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch -import app.revanced.patches.youtube.layout.hidetimeandseekbar.fingerprints.TimeCounterFingerprint import app.revanced.patches.youtube.layout.hidetimeandseekbar.annotations.HideTimeAndSeekbarCompatibility +import app.revanced.patches.youtube.layout.hidetimeandseekbar.fingerprints.TimeCounterFingerprint import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.CreateVideoPlayerSeekbarFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch @@ -29,7 +29,7 @@ class HideTimeAndSeekbarPatch : BytecodePatch( CreateVideoPlayerSeekbarFingerprint, TimeCounterFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_hide_time_and_seekbar", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt index 538307e5b..aa6ccdf83 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt @@ -3,14 +3,12 @@ package app.revanced.patches.youtube.layout.oldqualitylayout.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.oldqualitylayout.annotations.OldQualityLayoutCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("quality-menu-view-inflate-fingerprint") -@MatchingMethod("Lkhp;", "K") @OldQualityLayoutCompatibility @Version("0.0.1") object QualityMenuViewInflateFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt index a1d2090fe..2cb2fa7a6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.oldqualitylayout.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.oldqualitylayout.annotations.OldQualityLayoutCompatibility import app.revanced.patches.youtube.layout.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch @@ -27,7 +27,7 @@ import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction class OldQualityLayoutPatch : BytecodePatch( listOf(QualityMenuViewInflateFingerprint) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_use_old_style_quality_settings", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt index ec6e5e2ae..dc680d960 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt @@ -4,14 +4,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.personalinformation.annotations.HideEmailAddressCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("account-switcher-accessibility-label-fingerprint") -@MatchingMethod("Lqvs;", "mH") @FuzzyPatternScanMethod(3) @HideEmailAddressCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/personalinformation/patch/HideEmailAddressPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/personalinformation/patch/HideEmailAddressPatch.kt index 7772d249b..26a0e362d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/personalinformation/patch/HideEmailAddressPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/personalinformation/patch/HideEmailAddressPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.personalinformation.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.personalinformation.annotations.HideEmailAddressCompatibility import app.revanced.patches.youtube.layout.personalinformation.fingerprints.AccountSwitcherAccessibilityLabelFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch @@ -17,11 +17,8 @@ import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePa import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference -import org.jf.dexlib2.Opcode -import org.jf.dexlib2.builder.instruction.BuilderInstruction35c import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.WideLiteralInstruction -import org.jf.dexlib2.iface.reference.MethodReference @Patch @DependsOn([IntegrationsPatch::class, SettingsPatch::class, ResourceMappingResourcePatch::class]) @@ -34,7 +31,7 @@ class HideEmailAddressPatch : BytecodePatch( AccountSwitcherAccessibilityLabelFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_hide_email_address", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/fingerprints/PivotBarCreateButtonViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/fingerprints/PivotBarCreateButtonViewFingerprint.kt index 9279e5af9..6f0720d65 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/fingerprints/PivotBarCreateButtonViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/fingerprints/PivotBarCreateButtonViewFingerprint.kt @@ -2,15 +2,11 @@ package app.revanced.patches.youtube.layout.pivotbar.createbutton.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.pivotbar.createbutton.annotations.CreateButtonCompatibility import org.jf.dexlib2.Opcode @Name("pivot-bar-create-button-view-fingerprint") -@MatchingMethod( - "Lknw", "z" -) @CreateButtonCompatibility @Version("0.0.1") object PivotBarCreateButtonViewFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt index aec686358..d493745c8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt @@ -3,20 +3,20 @@ package app.revanced.patches.youtube.layout.pivotbar.createbutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.MethodFingerprintExtensions.name import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch -import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT -import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.injectHook import app.revanced.patches.youtube.layout.pivotbar.createbutton.annotations.CreateButtonCompatibility import app.revanced.patches.youtube.layout.pivotbar.createbutton.fingerprints.PivotBarCreateButtonViewFingerprint import app.revanced.patches.youtube.layout.pivotbar.fingerprints.PivotBarFingerprint +import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT +import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.injectHook import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch @@ -34,7 +34,7 @@ class CreateButtonRemoverPatch : BytecodePatch( PivotBarFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_create_button_enabled", @@ -51,7 +51,7 @@ class CreateButtonRemoverPatch : BytecodePatch( val pivotBarResult = PivotBarFingerprint.result ?: return PatchResultError("PivotBarFingerprint failed") - if (!PivotBarCreateButtonViewFingerprint.resolve(data, pivotBarResult.method, pivotBarResult.classDef)) + if (!PivotBarCreateButtonViewFingerprint.resolve(context, pivotBarResult.method, pivotBarResult.classDef)) return PatchResultError("${PivotBarCreateButtonViewFingerprint.name} failed") val createButtonResult = PivotBarCreateButtonViewFingerprint.result!! diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/fingerprints/PivotBarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/fingerprints/PivotBarFingerprint.kt index 9bfe7ceab..f7cfb5fdc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/fingerprints/PivotBarFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/fingerprints/PivotBarFingerprint.kt @@ -4,15 +4,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("pivot-bar-fingerprint") -@MatchingMethod( - "Lknw", "z" -) @FuzzyPatternScanMethod(2) // TODO: This fingerprint is used in multiple patches, so technically two compatibilities are needed // @CreateButtonCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/fingerprints/PivotBarEnumFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/fingerprints/PivotBarEnumFingerprint.kt index d538acc58..8c0225ac3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/fingerprints/PivotBarEnumFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/fingerprints/PivotBarEnumFingerprint.kt @@ -2,15 +2,11 @@ package app.revanced.patches.youtube.layout.pivotbar.shortsbutton.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.annotations.ShortsButtonCompatibility import org.jf.dexlib2.Opcode @Name("pivot-bar-enum-fingerprint") -@MatchingMethod( - "Lknw", "z" -) @ShortsButtonCompatibility @Version("0.0.1") object PivotBarEnumFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/fingerprints/PivotBarShortsButtonViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/fingerprints/PivotBarShortsButtonViewFingerprint.kt index 99570bb82..ed7d93e86 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/fingerprints/PivotBarShortsButtonViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/fingerprints/PivotBarShortsButtonViewFingerprint.kt @@ -2,15 +2,11 @@ package app.revanced.patches.youtube.layout.pivotbar.shortsbutton.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.annotations.ShortsButtonCompatibility import org.jf.dexlib2.Opcode @Name("pivot-bar-shorts-button-view-fingerprint") -@MatchingMethod( - "Lknw", "z" -) @ShortsButtonCompatibility @Version("0.0.1") object PivotBarShortsButtonViewFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt index a795c26d3..09c7d311b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt @@ -3,21 +3,21 @@ package app.revanced.patches.youtube.layout.pivotbar.shortsbutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.MethodFingerprintExtensions.name import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch -import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT -import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.injectHook import app.revanced.patches.youtube.layout.pivotbar.fingerprints.PivotBarFingerprint import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.annotations.ShortsButtonCompatibility import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.fingerprints.PivotBarEnumFingerprint import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.fingerprints.PivotBarShortsButtonViewFingerprint +import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT +import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.injectHook import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource @@ -32,7 +32,7 @@ import app.revanced.patches.youtube.misc.settings.framework.components.impl.Swit class ShortsButtonRemoverPatch : BytecodePatch( listOf(PivotBarFingerprint) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_shorts_button_enabled", @@ -51,7 +51,7 @@ class ShortsButtonRemoverPatch : BytecodePatch( val fingerprintResults = arrayOf(PivotBarEnumFingerprint, PivotBarShortsButtonViewFingerprint) .onEach { val resolutionSucceeded = it.resolve( - data, + context, pivotBarResult.method, pivotBarResult.classDef ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/playerpopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/playerpopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt index 721dc74d6..efc3ecd67 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/playerpopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/playerpopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt @@ -4,14 +4,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.playerpopuppanels.annotations.PlayerPopupPanelsCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("engagement-player-controller-fingerprint") -@MatchingMethod("Lucf;", "L") @FuzzyPatternScanMethod(3) @PlayerPopupPanelsCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/playerpopuppanels/patch/PlayerPopupPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/playerpopuppanels/patch/PlayerPopupPanelsPatch.kt index 874d65818..8cce12f6c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/playerpopuppanels/patch/PlayerPopupPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/playerpopuppanels/patch/PlayerPopupPanelsPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.playerpopuppanels.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.playerpopuppanels.annotations.PlayerPopupPanelsCompatibility import app.revanced.patches.youtube.layout.playerpopuppanels.fingerprints.EngagementPanelControllerFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch @@ -28,7 +28,7 @@ class PlayerPopupPanelsPatch : BytecodePatch( EngagementPanelControllerFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_player_popup_panels_enabled", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/reels/fingerprints/HideReelsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/reels/fingerprints/HideReelsFingerprint.kt index fc6ab8a21..986c215e6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/reels/fingerprints/HideReelsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/reels/fingerprints/HideReelsFingerprint.kt @@ -3,17 +3,11 @@ package app.revanced.patches.youtube.layout.reels.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility import org.jf.dexlib2.AccessFlags @Name("hide-reels-fingerprint") -@MatchingMethod( - "Ljvy", "" -) -@FuzzyPatternScanMethod(3) // FIXME: Test this threshold and find the best value. @HideReelsCompatibility @Version("0.0.1") object HideReelsFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt index fd5c2370b..8ffba7742 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt @@ -2,13 +2,13 @@ package app.revanced.patches.youtube.layout.reels.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name -import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility import app.revanced.patches.youtube.layout.reels.fingerprints.HideReelsFingerprint import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch @@ -26,7 +26,7 @@ class HideReelsPatch : BytecodePatch( HideReelsFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_reel_button_enabled", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/DislikeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/DislikeFingerprint.kt index 0f5038579..df1bf114f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/DislikeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/DislikeFingerprint.kt @@ -3,17 +3,11 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility import org.jf.dexlib2.AccessFlags @Name("dislike-fingerprint") -@MatchingMethod( - "Luqs;", "" -) -@FuzzyPatternScanMethod(2) @ReturnYouTubeDislikeCompatibility @Version("0.0.2") object DislikeFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/LikeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/LikeFingerprint.kt index fcca8f428..f4e794e39 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/LikeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/LikeFingerprint.kt @@ -4,15 +4,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility import org.jf.dexlib2.AccessFlags @Name("like-fingerprint") -@MatchingMethod( - "Luqt;", "" -) @FuzzyPatternScanMethod(2) @ReturnYouTubeDislikeCompatibility @Version("0.0.2") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RemoveLikeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RemoveLikeFingerprint.kt index ce98f1cb5..f613c3340 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RemoveLikeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RemoveLikeFingerprint.kt @@ -3,17 +3,11 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility import org.jf.dexlib2.AccessFlags @Name("remove-like-fingerprint") -@MatchingMethod( - "Luqw;", "" -) -@FuzzyPatternScanMethod(2) @ReturnYouTubeDislikeCompatibility @Version("0.0.2") object RemoveLikeFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentSpecParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentSpecParentFingerprint.kt index 40030d049..614961483 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentSpecParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentSpecParentFingerprint.kt @@ -2,16 +2,11 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility @Name("text-component-spec-parent-fingerprint") -@MatchingMethod( - "Lnvy;", "e" -) -@DirectPatternScanMethod @ReturnYouTubeDislikeCompatibility @Version("0.0.1") object TextComponentSpecParentFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt index 4acceb9b0..80b22da0e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt @@ -3,14 +3,14 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility import app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints.DislikeFingerprint import app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints.LikeFingerprint @@ -31,7 +31,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch( TextComponentSpecParentFingerprint, LikeFingerprint, DislikeFingerprint, RemoveLikeFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { LikeFingerprint.result!!.mutableMethod.addInstructions( 0, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/resource/patch/ReturnYouTubeDislikeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/resource/patch/ReturnYouTubeDislikeResourcePatch.kt index 220dd657b..79bd00e01 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/resource/patch/ReturnYouTubeDislikeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/resource/patch/ReturnYouTubeDislikeResourcePatch.kt @@ -3,11 +3,11 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.resource.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch @@ -20,8 +20,8 @@ import app.revanced.util.resources.ResourceUtils.Settings.mergeStrings @Description("Adds the preferences for Return YouTube Dislike.") @ReturnYouTubeDislikeCompatibility @Version("0.0.1") -class ReturnYouTubeDislikeResourcePatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { +class ReturnYouTubeDislikeResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { val youtubePackage = "com.google.android.youtube" SettingsPatch.addPreference( Preference( @@ -35,7 +35,7 @@ class ReturnYouTubeDislikeResourcePatch : ResourcePatch() { ) ) // merge strings - data.mergeStrings("returnyoutubedislike/host/values/strings.xml") + context.mergeStrings("returnyoutubedislike/host/values/strings.xml") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/AppendTimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/AppendTimeFingerprint.kt index 5faa9c1b1..e4b90d9da 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/AppendTimeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/AppendTimeFingerprint.kt @@ -3,18 +3,13 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("append-time-fingerprint") -@MatchingMethod( - "Liet;", "e" -) -@DirectPatternScanMethod @SponsorBlockCompatibility @Version("0.0.1") object AppendTimeFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/CreateVideoPlayerSeekbarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/CreateVideoPlayerSeekbarFingerprint.kt index 28ab1a8d6..d895e2065 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/CreateVideoPlayerSeekbarFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/CreateVideoPlayerSeekbarFingerprint.kt @@ -2,16 +2,11 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility @Name("create-video-player-seekbar-fingerprint") -@MatchingMethod( - "Lfcm;", "onDraw" -) -@DirectPatternScanMethod @SponsorBlockCompatibility @Version("0.0.1") object CreateVideoPlayerSeekbarFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/NextGenWatchLayoutFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/NextGenWatchLayoutFingerprint.kt index 84cb58d2f..6a2183525 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/NextGenWatchLayoutFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/NextGenWatchLayoutFingerprint.kt @@ -2,17 +2,13 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import org.jf.dexlib2.util.MethodUtil @Name("next-gen-watch-layout-fingerprint") -@MatchingMethod( - "LNextGenWatchLayout;", "" -) -@DirectPatternScanMethod + @SponsorBlockCompatibility @Version("0.0.1") object NextGenWatchLayoutFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerControllerSetTimeReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerControllerSetTimeReferenceFingerprint.kt index 8b3a11a1a..fa47a3f78 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerControllerSetTimeReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerControllerSetTimeReferenceFingerprint.kt @@ -2,17 +2,13 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import org.jf.dexlib2.Opcode @Name("player-controller-set-time-reference-fingerprint") -@MatchingMethod( - "Lxqm;", "" -) -@DirectPatternScanMethod + @SponsorBlockCompatibility @Version("0.0.1") object PlayerControllerSetTimeReferenceFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerInitFingerprint.kt index c775dc9c3..4ddc5c722 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerInitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerInitFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility @Name("player-init-fingerprint") -@MatchingMethod( - "Laajv;", "aG" -) -@DirectPatternScanMethod + @SponsorBlockCompatibility @Version("0.0.1") object PlayerInitFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerOverlaysLayoutInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerOverlaysLayoutInitFingerprint.kt index 255f48a97..fe6de06a9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerOverlaysLayoutInitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/PlayerOverlaysLayoutInitFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility @Name("player-overlays-layout-init-fingerprint") -@MatchingMethod( - "Lihh;", "u" -) -@DirectPatternScanMethod + @SponsorBlockCompatibility @Version("0.0.1") object PlayerOverlaysLayoutInitFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/RectangleFieldInvalidatorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/RectangleFieldInvalidatorFingerprint.kt index ccfa4b76f..c9bdfff28 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/RectangleFieldInvalidatorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/RectangleFieldInvalidatorFingerprint.kt @@ -2,18 +2,13 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.reference.MethodReference @Name("rectangle-field-invalidator-fingerprint") -@MatchingMethod( - "Lfcm;", "kY" -) -@DirectPatternScanMethod @SponsorBlockCompatibility @Version("0.0.1") object RectangleFieldInvalidatorFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/SeekFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/SeekFingerprint.kt index 3029a26f5..6513e4608 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/SeekFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/SeekFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility @Name("seek-fingerprint") -@MatchingMethod( - "Laajv;", "af" -) -@DirectPatternScanMethod + @SponsorBlockCompatibility @Version("0.0.1") object SeekFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/ShortsPlayerConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/ShortsPlayerConstructorFingerprint.kt index 0b5d91841..ccb39c5b5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/ShortsPlayerConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/ShortsPlayerConstructorFingerprint.kt @@ -4,7 +4,6 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch @@ -13,7 +12,6 @@ import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.WideLiteralInstruction @Name("shorts-player-constructor-fingerprint") -@MatchingMethod("Lhgp;", "") @FuzzyPatternScanMethod(3) @SponsorBlockCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/VideoLengthFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/VideoLengthFingerprint.kt index 91c243d02..5bf3b461c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/VideoLengthFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/VideoLengthFingerprint.kt @@ -2,17 +2,13 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import org.jf.dexlib2.Opcode @Name("video-length-fingerprint") -@MatchingMethod( - "Lyfh;", "z" -) -@DirectPatternScanMethod + @SponsorBlockCompatibility @Version("0.0.1") object VideoLengthFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/VideoTimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/VideoTimeFingerprint.kt index 8183ce670..d50b23a3c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/VideoTimeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/VideoTimeFingerprint.kt @@ -2,16 +2,11 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility @Name("video-time-fingerprint") -@MatchingMethod( - "Lwyh;", "" -) -@DirectPatternScanMethod @SponsorBlockCompatibility @Version("0.0.1") object VideoTimeFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index 3e7580ada..7838a58f2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -3,21 +3,22 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData -import app.revanced.patcher.data.impl.toMethodWalker +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.toMethodWalker import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable +import app.revanced.patches.youtube.layout.autocaptions.fingerprints.StartVideoInformerFingerprint import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.* import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch @@ -25,7 +26,6 @@ import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch -import app.revanced.patches.youtube.layout.autocaptions.fingerprints.StartVideoInformerFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.MutableMethodImplementation @@ -59,12 +59,13 @@ class SponsorBlockBytecodePatch : BytecodePatch( StartVideoInformerFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult {/* + override fun execute(context: BytecodeContext): PatchResult {/* Set current video time */ val referenceResult = PlayerControllerSetTimeReferenceFingerprint.result!! val playerControllerSetTimeMethod = - data.toMethodWalker(referenceResult.method).nextMethod(referenceResult.scanResult.patternScanResult!!.startIndex, true) + context.toMethodWalker(referenceResult.method) + .nextMethod(referenceResult.scanResult.patternScanResult!!.startIndex, true) .getMethod() as MutableMethod playerControllerSetTimeMethod.addInstruction( 2, @@ -76,7 +77,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( */ val constructorFingerprint = object : MethodFingerprint("V", null, listOf("J", "J", "J", "J", "I", "L"), null) {} - constructorFingerprint.resolve(data, VideoTimeFingerprint.result!!.classDef) + constructorFingerprint.resolve(context, VideoTimeFingerprint.result!!.classDef) val constructor = constructorFingerprint.result!!.mutableMethod constructor.addInstruction( @@ -162,7 +163,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( /* Set video length */ - VideoLengthFingerprint.resolve(data, seekbarSignatureResult.classDef) + VideoLengthFingerprint.resolve(context, seekbarSignatureResult.classDef) val videoLengthMethodResult = VideoLengthFingerprint.result!! val videoLengthMethod = videoLengthMethodResult.mutableMethod val videoLengthMethodInstructions = videoLengthMethod.implementation!!.instructions @@ -210,7 +211,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( zoomOverlayResourceId -> { val invertVisibilityMethod = - data.toMethodWalker(method).nextMethod(index - 6, true).getMethod() as MutableMethod + context.toMethodWalker(method).nextMethod(index - 6, true).getMethod() as MutableMethod // change visibility of the buttons invertVisibilityMethod.addInstructions( 0, """ @@ -264,7 +265,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( // lastly create hooks for the player controller // get original seek method - SeekFingerprint.resolve(data, initFingerprintResult.classDef) + SeekFingerprint.resolve(context, initFingerprintResult.classDef) val seekFingerprintResultMethod = SeekFingerprint.result!!.method // get enum type for the seek helper method val seekSourceEnumType = seekFingerprintResultMethod.parameterTypes[1].toString() @@ -295,7 +296,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( initFingerprintResult.mutableClass.methods.add(seekHelperMethod) // get rectangle field name - RectangleFieldInvalidatorFingerprint.resolve(data, seekbarSignatureResult.classDef) + RectangleFieldInvalidatorFingerprint.resolve(context, seekbarSignatureResult.classDef) val rectangleFieldInvalidatorInstructions = RectangleFieldInvalidatorFingerprint.result!!.method.implementation!!.instructions val rectangleFieldName = @@ -303,7 +304,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( // get the player controller class from the integrations val playerControllerMethods = - data.proxy(data.classes.first { it.type.endsWith("PlayerController;") }).resolve().methods + context.proxy(context.classes.first { it.type.endsWith("PlayerController;") }).mutableClass.methods // get the method which contain the "replaceMe" strings val replaceMeMethods = diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt index 4956b7e5c..425bee6c8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt @@ -2,11 +2,11 @@ package app.revanced.patches.youtube.layout.sponsorblock.resource.patch import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch @@ -22,12 +22,12 @@ import app.revanced.util.resources.ResourceUtils.copyXmlNode @SponsorBlockCompatibility @DependsOn([FixLocaleConfigErrorPatch::class, SettingsPatch::class, ResourceMappingResourcePatch::class]) @Version("0.0.1") -class SponsorBlockResourcePatch : ResourcePatch() { +class SponsorBlockResourcePatch : ResourcePatch { companion object { internal var reelButtonGroupResourceId: Long = 0 } - override fun execute(data: ResourceData): PatchResult { + override fun execute(context: ResourceContext): PatchResult { val youtubePackage = "com.google.android.youtube" SettingsPatch.addPreference( Preference( @@ -45,7 +45,7 @@ class SponsorBlockResourcePatch : ResourcePatch() { /* merge SponsorBlock strings to main strings */ - data.mergeStrings("sponsorblock/host/values/strings.xml") + context.mergeStrings("sponsorblock/host/values/strings.xml") /* merge SponsorBlock drawables to main drawables @@ -73,7 +73,7 @@ class SponsorBlockResourcePatch : ResourcePatch() { "drawable-xxxhdpi", "quantum_ic_skip_next_white_24.png" ) ).forEach { resourceGroup -> - data.copyResources("sponsorblock", resourceGroup) + context.copyResources("sponsorblock", resourceGroup) } /* @@ -84,9 +84,9 @@ class SponsorBlockResourcePatch : ResourcePatch() { val hostingResourceStream = classLoader.getResourceAsStream("sponsorblock/host/layout/youtube_controls_layout.xml")!! - val targetXmlEditor = data.xmlEditor["res/layout/youtube_controls_layout.xml"] + val targetXmlEditor = context.xmlEditor["res/layout/youtube_controls_layout.xml"] "RelativeLayout".copyXmlNode( - data.xmlEditor[hostingResourceStream], + context.xmlEditor[hostingResourceStream], targetXmlEditor ).also { val children = targetXmlEditor.file.getElementsByTagName("RelativeLayout").item(0).childNodes diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt index 2132bdcb1..a90a038bc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt @@ -4,14 +4,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.startupshortsreset.annotations.StartupShortsResetCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("user-was-in-shorts-fingerprint") -@MatchingMethod("Lkzb;", "e") @FuzzyPatternScanMethod(3) @StartupShortsResetCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt index 9ae9bf9d5..0398cca0a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt @@ -3,20 +3,19 @@ package app.revanced.patches.youtube.layout.startupshortsreset.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.startupshortsreset.annotations.StartupShortsResetCompatibility import app.revanced.patches.youtube.layout.startupshortsreset.fingerprints.UserWasInShortsFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference -import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Patch @DependsOn([IntegrationsPatch::class, SettingsPatch::class]) @@ -29,7 +28,7 @@ class DisableShortsOnStartupPatch : BytecodePatch( UserWasInShortsFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_startup_shorts_player_enabled", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt index 53113d33b..3529cdcd0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt @@ -4,16 +4,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.tabletminiplayer.annotations.TabletMiniPlayerCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("mini-player-dimensions-calculator-fingerprint") -@MatchingMethod( - "Lkkr;", "pM" -) @FuzzyPatternScanMethod(2) // TODO: Find a good threshold value @TabletMiniPlayerCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt index 2077eda26..4dabce928 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt @@ -3,16 +3,12 @@ package app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.tabletminiplayer.annotations.TabletMiniPlayerCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("mini-player-override-fingerprint") -@MatchingMethod( - "Lkkr;", "j" -) @TabletMiniPlayerCompatibility @Version("0.0.1") object MiniPlayerOverrideFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt index ef89570a8..055a047c1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt @@ -3,16 +3,12 @@ package app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.tabletminiplayer.annotations.TabletMiniPlayerCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("mini-player-override-no-context-fingerprint") -@MatchingMethod( - "Lkkr;", "k" -) @TabletMiniPlayerCompatibility @Version("0.0.1") object MiniPlayerOverrideNoContextFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt index 7e6cd45a5..ee88adaeb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt @@ -3,16 +3,12 @@ package app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.tabletminiplayer.annotations.TabletMiniPlayerCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("mini-player-response-model-size-check-fingerprint") -@MatchingMethod( - "Lenv;", "a" -) @TabletMiniPlayerCompatibility @Version("0.0.1") object MiniPlayerResponseModelSizeCheckFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt index 58d03157d..ffb494868 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt @@ -3,15 +3,15 @@ package app.revanced.patches.youtube.layout.tabletminiplayer.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.youtube.layout.tabletminiplayer.annotations.TabletMiniPlayerCompatibility import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerDimensionsCalculatorFingerprint @@ -36,14 +36,16 @@ class TabletMiniPlayerPatch : BytecodePatch( MiniPlayerResponseModelSizeCheckFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference( - "revanced_tablet_miniplayer", - StringResource("revanced_tablet_miniplayer_title", "Enable the tablet Mini-player"), - false, - StringResource("revanced_tablet_miniplayer_summary_on", "Tablet Mini-player is enabled"), - StringResource("revanced_tablet_miniplayer_summary_off", "Tablet Mini-player is disabled") - )) + override fun execute(context: BytecodeContext): PatchResult { + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + SwitchPreference( + "revanced_tablet_miniplayer", + StringResource("revanced_tablet_miniplayer_title", "Enable the tablet Mini-player"), + false, + StringResource("revanced_tablet_miniplayer_summary_on", "Tablet Mini-player is enabled"), + StringResource("revanced_tablet_miniplayer_summary_off", "Tablet Mini-player is disabled") + ) + ) // first resolve the fingerprints via the parent fingerprint val miniPlayerClass = MiniPlayerDimensionsCalculatorFingerprint.result!!.classDef @@ -51,7 +53,7 @@ class TabletMiniPlayerPatch : BytecodePatch( /* * no context parameter method */ - MiniPlayerOverrideNoContextFingerprint.resolve(data, miniPlayerClass) + MiniPlayerOverrideNoContextFingerprint.resolve(context, miniPlayerClass) val (method, _, parameterRegister) = MiniPlayerOverrideNoContextFingerprint.addProxyCall() // - 1 means to insert before the return instruction val secondInsertIndex = method.implementation!!.instructions.size - 1 @@ -60,7 +62,7 @@ class TabletMiniPlayerPatch : BytecodePatch( /* * method with context parameter */ - MiniPlayerOverrideFingerprint.resolve(data, miniPlayerClass) + MiniPlayerOverrideFingerprint.resolve(context, miniPlayerClass) val (_, _, _) = MiniPlayerOverrideFingerprint.addProxyCall() /* diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt index 5989624dc..6fe8e198f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt @@ -3,14 +3,10 @@ package app.revanced.patches.youtube.layout.theme.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData -import app.revanced.patcher.patch.OptionsContainer -import app.revanced.patcher.patch.PatchOption -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.* import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.layout.theme.annotations.ThemeCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import org.w3c.dom.Element @@ -21,12 +17,12 @@ import org.w3c.dom.Element @Description("Applies a custom theme.") @ThemeCompatibility @Version("0.0.1") -class ThemePatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { +class ThemePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { val darkThemeBackgroundColor = darkThemeBackgroundColor!! val lightThemeBackgroundColor = lightThemeBackgroundColor!! - data.xmlEditor["res/values/colors.xml"].use { editor -> + context.xmlEditor["res/values/colors.xml"].use { editor -> val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element for (i in 0 until resourcesNode.childNodes.length) { @@ -36,7 +32,7 @@ class ThemePatch : ResourcePatch() { "yt_black1", "yt_black1_opacity95", "yt_black2", "yt_black3", "yt_black4", "yt_status_bar_background_dark" -> darkThemeBackgroundColor - "yt_white1", "yt_white1_opacity95", "yt_white2", "yt_white3", + "yt_white1", "yt_white1_opacity95", "yt_white2", "yt_white3", "yt_white4" -> lightThemeBackgroundColor else -> continue diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/fingerprints/HideWatermarkFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/fingerprints/HideWatermarkFingerprint.kt index 2360866c1..b880c4932 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/fingerprints/HideWatermarkFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/fingerprints/HideWatermarkFingerprint.kt @@ -3,17 +3,11 @@ package app.revanced.patches.youtube.layout.watermark.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.watermark.annotations.HideWatermarkCompatibility import org.jf.dexlib2.AccessFlags @Name("hide-watermark-signature") -@MatchingMethod( - "Ljvy;", "" -) -@FuzzyPatternScanMethod(3) @HideWatermarkCompatibility @Version("0.0.1") object HideWatermarkFingerprint : MethodFingerprint ( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/fingerprints/HideWatermarkParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/fingerprints/HideWatermarkParentFingerprint.kt index 16660b557..7cc41e5d8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/fingerprints/HideWatermarkParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/fingerprints/HideWatermarkParentFingerprint.kt @@ -3,17 +3,11 @@ package app.revanced.patches.youtube.layout.watermark.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.watermark.annotations.HideWatermarkCompatibility import org.jf.dexlib2.AccessFlags @Name("hide-watermark-parent-signature") -@MatchingMethod( - "Ljvy;", "" -) -@FuzzyPatternScanMethod(3) @HideWatermarkCompatibility @Version("0.0.1") object HideWatermarkParentFingerprint : MethodFingerprint ( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/patch/HideWatermarkPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/patch/HideWatermarkPatch.kt index 8518ad76f..4009355cc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/patch/HideWatermarkPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/patch/HideWatermarkPatch.kt @@ -3,19 +3,19 @@ package app.revanced.patches.youtube.layout.watermark.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.watermark.annotations.HideWatermarkCompatibility -import app.revanced.patches.youtube.layout.watermark.fingerprints.HideWatermarkParentFingerprint import app.revanced.patches.youtube.layout.watermark.fingerprints.HideWatermarkFingerprint +import app.revanced.patches.youtube.layout.watermark.fingerprints.HideWatermarkParentFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource @@ -32,7 +32,7 @@ class HideWatermarkPatch : BytecodePatch( HideWatermarkParentFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_branding_watermark_enabled", @@ -43,7 +43,7 @@ class HideWatermarkPatch : BytecodePatch( ) ) - HideWatermarkFingerprint.resolve(data, HideWatermarkParentFingerprint.result!!.classDef) + HideWatermarkFingerprint.resolve(context, HideWatermarkParentFingerprint.result!!.classDef) val result = HideWatermarkFingerprint.result ?: return PatchResultError("Required parent method could not be found.") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarOneFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarOneFingerprint.kt index 2826060fa..0a8547eed 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarOneFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarOneFingerprint.kt @@ -3,18 +3,13 @@ package app.revanced.patches.youtube.layout.widesearchbar.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.widesearchbar.annotations.WideSearchbarCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("wide-searchbar-methodone-fingerprint") -@MatchingMethod( - "Ljkg;", "i" -) -@DirectPatternScanMethod @WideSearchbarCompatibility @Version("0.0.1") object WideSearchbarOneFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarOneParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarOneParentFingerprint.kt index b3183a845..12db3e54a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarOneParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarOneParentFingerprint.kt @@ -3,17 +3,11 @@ package app.revanced.patches.youtube.layout.widesearchbar.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.widesearchbar.annotations.WideSearchbarCompatibility import org.jf.dexlib2.AccessFlags @Name("wide-searchbar-methodone-parent-fingerprint") -@MatchingMethod( - "Ljkg;", "l" -) -@FuzzyPatternScanMethod(3) @WideSearchbarCompatibility @Version("0.0.1") object WideSearchbarOneParentFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarTwoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarTwoFingerprint.kt index 31c94a84a..9a2b912e2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarTwoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarTwoFingerprint.kt @@ -3,18 +3,13 @@ package app.revanced.patches.youtube.layout.widesearchbar.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.widesearchbar.annotations.WideSearchbarCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("wide-searchbar-methodtwo-fingerprint") -@MatchingMethod( - "Lkrf;", "h" -) -@DirectPatternScanMethod @WideSearchbarCompatibility @Version("0.0.1") object WideSearchbarTwoFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarTwoParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarTwoParentFingerprint.kt index 4c33d7086..bcd1ba04d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarTwoParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/fingerprints/WideSearchbarTwoParentFingerprint.kt @@ -3,15 +3,11 @@ package app.revanced.patches.youtube.layout.widesearchbar.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.widesearchbar.annotations.WideSearchbarCompatibility import org.jf.dexlib2.AccessFlags @Name("wide-searchbar-methodtwo-parent-fingerprint") -@MatchingMethod( - "Lkrf;", "i" -) @WideSearchbarCompatibility @Version("0.0.1") object WideSearchbarTwoParentFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/patch/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/patch/WideSearchbarPatch.kt index bdd6ca83c..20b1e5ca5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/patch/WideSearchbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/patch/WideSearchbarPatch.kt @@ -3,15 +3,15 @@ package app.revanced.patches.youtube.layout.widesearchbar.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData -import app.revanced.patcher.data.impl.toMethodWalker +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.toMethodWalker import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.youtube.layout.widesearchbar.annotations.WideSearchbarCompatibility import app.revanced.patches.youtube.layout.widesearchbar.fingerprints.WideSearchbarOneFingerprint @@ -34,7 +34,7 @@ class WideSearchbarPatch : BytecodePatch( WideSearchbarOneParentFingerprint, WideSearchbarTwoParentFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( SwitchPreference( "revanced_wide_searchbar", @@ -45,14 +45,15 @@ class WideSearchbarPatch : BytecodePatch( ) ) - WideSearchbarOneFingerprint.resolve(data, WideSearchbarOneParentFingerprint.result!!.classDef) - WideSearchbarTwoFingerprint.resolve(data, WideSearchbarTwoParentFingerprint.result!!.classDef) + WideSearchbarOneFingerprint.resolve(context, WideSearchbarOneParentFingerprint.result!!.classDef) + WideSearchbarTwoFingerprint.resolve(context, WideSearchbarTwoParentFingerprint.result!!.classDef) val resultOne = WideSearchbarOneFingerprint.result //This should be the method aF in class fbn val targetMethodOne = - data.toMethodWalker(resultOne!!.method).nextMethod(resultOne.scanResult.patternScanResult!!.endIndex, true).getMethod() as MutableMethod + context.toMethodWalker(resultOne!!.method) + .nextMethod(resultOne.scanResult.patternScanResult!!.endIndex, true).getMethod() as MutableMethod //Since both methods have the same smali code, inject instructions using a method. addInstructions(targetMethodOne) @@ -61,7 +62,8 @@ class WideSearchbarPatch : BytecodePatch( //This should be the method aB in class fbn val targetMethodTwo = - data.toMethodWalker(resultTwo!!.method).nextMethod(resultTwo.scanResult.patternScanResult!!.startIndex, true).getMethod() as MutableMethod + context.toMethodWalker(resultTwo!!.method) + .nextMethod(resultTwo.scanResult.patternScanResult!!.startIndex, true).getMethod() as MutableMethod //Since both methods have the same smali code, inject instructions using a method. addInstructions(targetMethodTwo) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/fingerprints/AutoRepeatFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/fingerprints/AutoRepeatFingerprint.kt index da3340f51..c5208c97b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/fingerprints/AutoRepeatFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/fingerprints/AutoRepeatFingerprint.kt @@ -3,25 +3,13 @@ package app.revanced.patches.youtube.misc.autorepeat.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.autorepeat.annotations.AutoRepeatCompatibility import org.jf.dexlib2.AccessFlags @Name("auto-repeat-fingerprint") -@MatchingMethod( - "Laamp;", "ae" -) -@FuzzyPatternScanMethod(2) @AutoRepeatCompatibility @Version("0.0.1") -//Finds method: -/* -public final void ae() { - aq(aabj.ENDED); - } - */ object AutoRepeatFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/fingerprints/AutoRepeatParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/fingerprints/AutoRepeatParentFingerprint.kt index 461eb7c2a..9f1213669 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/fingerprints/AutoRepeatParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/fingerprints/AutoRepeatParentFingerprint.kt @@ -3,17 +3,11 @@ package app.revanced.patches.youtube.misc.autorepeat.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.autorepeat.annotations.AutoRepeatCompatibility import org.jf.dexlib2.AccessFlags @Name("auto-repeat-parent-fingerprint") -@MatchingMethod( - "Laamp;", "E" -) -@FuzzyPatternScanMethod(2) @AutoRepeatCompatibility @Version("0.0.1") object AutoRepeatParentFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/patch/AutoRepeatPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/patch/AutoRepeatPatch.kt index e229e95d6..7de04e2b4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/patch/AutoRepeatPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/patch/AutoRepeatPatch.kt @@ -3,16 +3,16 @@ package app.revanced.patches.youtube.misc.autorepeat.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.misc.autorepeat.annotations.AutoRepeatCompatibility import app.revanced.patches.youtube.misc.autorepeat.fingerprints.AutoRepeatFingerprint import app.revanced.patches.youtube.misc.autorepeat.fingerprints.AutoRepeatParentFingerprint @@ -32,7 +32,7 @@ class AutoRepeatPatch : BytecodePatch( AutoRepeatParentFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.MISC.addPreferences( SwitchPreference( "revanced_pref_auto_repeat", @@ -49,7 +49,7 @@ class AutoRepeatPatch : BytecodePatch( //this one needs to be called when app/revanced/integrations/patches/AutoRepeatPatch;->shouldAutoRepeat() returns true val playMethod = parentResult.mutableMethod - AutoRepeatFingerprint.resolve(data, parentResult.classDef) + AutoRepeatFingerprint.resolve(context, parentResult.classDef) //String is: Laamp;->E()V val methodToCall = playMethod.definingClass + "->" + playMethod.name + "()V"; diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt index bf216b350..743f64099 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt @@ -2,14 +2,14 @@ package app.revanced.patches.youtube.misc.clientspoof.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.clientspoof.annotations.ClientSpoofCompatibility import org.jf.dexlib2.Opcode @Name("user-agent-header-builder-fingerprint") @ClientSpoofCompatibility -@DirectPatternScanMethod + @Version("0.0.1") object UserAgentHeaderBuilderFingerprint : MethodFingerprint( parameters = listOf("L", "L", "L"), diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt index 52dc1962e..2a76d7805 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.misc.clientspoof.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.misc.clientspoof.annotations.ClientSpoofCompatibility import app.revanced.patches.youtube.misc.clientspoof.fingerprints.UserAgentHeaderBuilderFingerprint import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction @@ -22,7 +22,7 @@ import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction class ClientSpoofPatch : BytecodePatch( listOf(UserAgentHeaderBuilderFingerprint) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { val result = UserAgentHeaderBuilderFingerprint.result!! val method = result.mutableMethod diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt index cb8e23ac7..610171899 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt @@ -4,16 +4,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.customplaybackspeed.annotations.CustomPlaybackSpeedCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("speed-array-generator-fingerprint") -@MatchingMethod( - "Lzdj;", "d" -) @FuzzyPatternScanMethod(2) @CustomPlaybackSpeedCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/SpeedLimiterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/SpeedLimiterFingerprint.kt index c46ce9323..c60cce997 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/SpeedLimiterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/SpeedLimiterFingerprint.kt @@ -3,18 +3,14 @@ package app.revanced.patches.youtube.misc.customplaybackspeed.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.customplaybackspeed.annotations.CustomPlaybackSpeedCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("speed-limiter-fingerprint") -@MatchingMethod( - "Lxgy;", "y" -) -@FuzzyPatternScanMethod(2) +@FuzzyPatternScanMethod(2) @CustomPlaybackSpeedCompatibility @Version("0.0.1") object SpeedLimiterFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/VideoSpeedPatchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/VideoSpeedPatchFingerprint.kt index b6e212ab8..e4fad32b8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/VideoSpeedPatchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/fingerprints/VideoSpeedPatchFingerprint.kt @@ -2,15 +2,11 @@ package app.revanced.patches.youtube.misc.customplaybackspeed.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.customplaybackspeed.annotations.CustomPlaybackSpeedCompatibility import org.jf.dexlib2.Opcode @Name("video-speed-patch-fingerprint") -@MatchingMethod( - "Lapp/revanced/integrations/patches/VideoSpeedPatch;", "" -) @CustomPlaybackSpeedCompatibility @Version("0.0.1") object VideoSpeedPatchFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/patch/CustomPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/patch/CustomPlaybackSpeedPatch.kt index 3020baee5..518e34720 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/patch/CustomPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/customplaybackspeed/patch/CustomPlaybackSpeedPatch.kt @@ -3,13 +3,12 @@ package app.revanced.patches.youtube.misc.customplaybackspeed.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.* import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.misc.customplaybackspeed.annotations.CustomPlaybackSpeedCompatibility import app.revanced.patches.youtube.misc.customplaybackspeed.fingerprints.SpeedArrayGeneratorFingerprint import app.revanced.patches.youtube.misc.customplaybackspeed.fingerprints.SpeedLimiterFingerprint @@ -37,7 +36,7 @@ class CustomPlaybackSpeedPatch : BytecodePatch( ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { //TODO: include setting to skip remembering the new speed val speedLimitMin = minVideoSpeed!!.toFloat() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/enabledebugging/patch/EnableDebuggingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/enabledebugging/patch/EnableDebuggingPatch.kt index 9bf03cce1..94fff3cb1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/enabledebugging/patch/EnableDebuggingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/enabledebugging/patch/EnableDebuggingPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.youtube.misc.enabledebugging.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.misc.enabledebugging.annotations.EnableDebuggingCompatibility import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch @@ -22,8 +22,8 @@ import org.w3c.dom.Element @Description("Enables app debugging by patching the manifest file.") @EnableDebuggingCompatibility @Version("0.0.1") -class EnableDebuggingPatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { +class EnableDebuggingPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { SettingsPatch.PreferenceScreen.MISC.addPreferences( SwitchPreference( "revanced_debug_enabled", @@ -35,7 +35,7 @@ class EnableDebuggingPatch : ResourcePatch() { ) // create an xml editor instance - data.xmlEditor["AndroidManifest.xml"].use { dom -> + context.xmlEditor["AndroidManifest.xml"].use { dom -> // get the application node val applicationNode = dom .file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/hdrbrightness/fingerprints/HDRBrightnessFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/hdrbrightness/fingerprints/HDRBrightnessFingerprint.kt index 1a8619d3a..a8f434857 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/hdrbrightness/fingerprints/HDRBrightnessFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/hdrbrightness/fingerprints/HDRBrightnessFingerprint.kt @@ -2,15 +2,11 @@ package app.revanced.patches.youtube.misc.hdrbrightness.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.hdrbrightness.annotations.HDRBrightnessCompatibility import org.jf.dexlib2.Opcode @Name("hdr-brightness-fingerprint") -@MatchingMethod( - "Lyls;", "c" -) @HDRBrightnessCompatibility @Version("0.0.1") object HDRBrightnessFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/hdrbrightness/patch/HDRBrightnessPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/hdrbrightness/patch/HDRBrightnessPatch.kt index de45669d3..24f18d281 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/hdrbrightness/patch/HDRBrightnessPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/hdrbrightness/patch/HDRBrightnessPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.misc.hdrbrightness.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.misc.hdrbrightness.annotations.HDRBrightnessCompatibility import app.revanced.patches.youtube.misc.hdrbrightness.fingerprints.HDRBrightnessFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch @@ -29,7 +29,7 @@ import org.jf.dexlib2.iface.reference.FieldReference class HDRBrightnessPatch : BytecodePatch( listOf(HDRBrightnessFingerprint) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.MISC.addPreferences( SwitchPreference( "revanced_pref_hdr_autobrightness", diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/InitFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/InitFingerprint.kt index d832a9809..66b874def 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/InitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/InitFingerprint.kt @@ -2,14 +2,10 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.integrations.annotations.IntegrationsCompatibility @Name("init-fingerprint") -@MatchingMethod( - "Lacuu", "onCreate" -) @IntegrationsCompatibility @Version("0.0.1") object InitFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt index afad662e5..6f4ddd164 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.misc.integrations.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.or +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.youtube.misc.integrations.annotations.IntegrationsCompatibility @@ -27,8 +27,8 @@ class IntegrationsPatch : BytecodePatch( InitFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { - if (data.findClass("Lapp/revanced/integrations/utils/ReVancedUtils") == null) + override fun execute(context: BytecodeContext): PatchResult { + if (context.findClass("Lapp/revanced/integrations/utils/ReVancedUtils") == null) return PatchResultError("Integrations have not been merged yet. This patch can not succeed without the integrations.") val result = InitFingerprint.result!! diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/manifest/patch/FixLocaleConfigErrorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/manifest/patch/FixLocaleConfigErrorPatch.kt index 30ed3f3ed..801e444d3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/manifest/patch/FixLocaleConfigErrorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/manifest/patch/FixLocaleConfigErrorPatch.kt @@ -3,10 +3,10 @@ package app.revanced.patches.youtube.misc.manifest.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patches.youtube.misc.manifest.annotations.FixLocaleConfigErrorCompatibility import org.w3c.dom.Element @@ -14,10 +14,10 @@ import org.w3c.dom.Element @Description("Fixes an error when building the resources by patching the manifest file.") @FixLocaleConfigErrorCompatibility @Version("0.0.1") -class FixLocaleConfigErrorPatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { +class FixLocaleConfigErrorPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { // create an xml editor instance - data.xmlEditor["AndroidManifest.xml"].use { + context.xmlEditor["AndroidManifest.xml"].use { // edit the application nodes attribute... val applicationNode = it .file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/mapping/patch/ResourceMappingResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/mapping/patch/ResourceMappingResourcePatch.kt index 099b19fdd..7e08d4bee 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/mapping/patch/ResourceMappingResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/mapping/patch/ResourceMappingResourcePatch.kt @@ -3,10 +3,10 @@ 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.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.ResourcePatch import org.w3c.dom.Element import java.util.* import java.util.concurrent.Executors @@ -16,7 +16,7 @@ import java.util.concurrent.TimeUnit @Name("resource-mapping") @Description("Creates a map of public resources.") @Version("0.0.1") -class ResourceMappingResourcePatch : ResourcePatch() { +class ResourceMappingResourcePatch : ResourcePatch { companion object { internal lateinit var resourceMappings: List private set @@ -25,16 +25,16 @@ class ResourceMappingResourcePatch : ResourcePatch() { private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT) } - override fun execute(data: ResourceData): PatchResult { + override fun execute(context: ResourceContext): PatchResult { // save the file in memory to concurrently read from - val resourceXmlFile = data["res/values/public.xml"].readBytes() + val resourceXmlFile = context["res/values/public.xml"].readBytes() // create a synchronized list to store the resource mappings val mappings = Collections.synchronizedList(mutableListOf()) for (threadIndex in 0 until THREAD_COUNT) { threadPoolExecutor.execute thread@{ - data.xmlEditor[resourceXmlFile.inputStream()].use { editor -> + context.xmlEditor[resourceXmlFile.inputStream()].use { editor -> val resources = editor.file.documentElement.childNodes val resourcesLength = resources.length val jobSize = resourcesLength / THREAD_COUNT diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastContextFetchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastContextFetchFingerprint.kt index 1d579e83c..46040553e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastContextFetchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastContextFetchFingerprint.kt @@ -2,16 +2,11 @@ package app.revanced.patches.youtube.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility @Name("cast-context-fetch-fingerprint") -@MatchingMethod( - "Lvvz;", "a" -) -@DirectPatternScanMethod @MicroGPatchCompatibility @Version("0.0.1") object CastContextFetchFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt index 9dbccbbf6..22b9b9388 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt @@ -2,16 +2,11 @@ package app.revanced.patches.youtube.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility @Name("cast-module-fingerprint") -@MatchingMethod( - "Llqh;", "c" -) -@DirectPatternScanMethod @MicroGPatchCompatibility @Version("0.0.1") object CastDynamiteModuleFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt index d6ae5d4c9..a2af64045 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt @@ -2,16 +2,11 @@ package app.revanced.patches.youtube.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility @Name("cast-context-fetch-fingerprint") -@MatchingMethod( - "Lmcf;", "c" -) -@DirectPatternScanMethod @MicroGPatchCompatibility @Version("0.0.1") object CastDynamiteModuleV2Fingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt index dee3155fc..58232d656 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt @@ -3,17 +3,11 @@ package app.revanced.patches.youtube.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import org.jf.dexlib2.AccessFlags @Name("google-play-utility-fingerprint") -@MatchingMethod( - "Lmco;", "b" -) -@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MicroGPatchCompatibility @Version("0.0.1") object GooglePlayUtilityFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/IntegrityCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/IntegrityCheckFingerprint.kt index 19a77f9a7..c57f780b9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/IntegrityCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/IntegrityCheckFingerprint.kt @@ -3,17 +3,11 @@ package app.revanced.patches.youtube.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import org.jf.dexlib2.AccessFlags @Name("google-play-sig-check-fingerprint") -@MatchingMethod( - "Leae;", "d" -) -@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MicroGPatchCompatibility @Version("0.0.1") object IntegrityCheckFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/PrimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/PrimeFingerprint.kt index 639e6d47f..b94fbd2f0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/PrimeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/PrimeFingerprint.kt @@ -2,16 +2,11 @@ package app.revanced.patches.youtube.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility @Name("google-play-prime-fingerprint") -@MatchingMethod( - "Lpag;", "d" -) -@DirectPatternScanMethod @MicroGPatchCompatibility @Version("0.0.1") object PrimeFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/ServiceCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/ServiceCheckFingerprint.kt index 8a069a43d..4a7908aca 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/ServiceCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/ServiceCheckFingerprint.kt @@ -3,17 +3,11 @@ package app.revanced.patches.youtube.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import org.jf.dexlib2.AccessFlags @Name("google-play-service-checker-fingerprint") -@MatchingMethod( - "Lmco;", "d" -) -@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MicroGPatchCompatibility @Version("0.0.1") object ServiceCheckFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt index db91e9b8b..41cf0a838 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt @@ -3,11 +3,11 @@ package app.revanced.patches.youtube.misc.microg.patch.bytecode import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.castbutton.patch.HideCastButtonPatch import app.revanced.patches.youtube.misc.clientspoof.patch.ClientSpoofPatch import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility @@ -40,10 +40,10 @@ class MicroGBytecodePatch : BytecodePatch( PrimeFingerprint, ) ) { - override fun execute(data: BytecodeData) = + override fun execute(context: BytecodeContext) = // apply common microG patch MicroGBytecodeHelper.patchBytecode( - data, arrayOf( + context, arrayOf( MicroGBytecodeHelper.packageNameTransform( PACKAGE_NAME, REVANCED_PACKAGE_NAME diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt index ea4a1e681..feb3fc59b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt @@ -3,12 +3,11 @@ package app.revanced.patches.youtube.misc.microg.patch.resource import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.ResourcePatch -import app.revanced.patches.music.misc.microg.shared.Constants import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import app.revanced.patches.youtube.misc.microg.shared.Constants.PACKAGE_NAME @@ -29,8 +28,8 @@ import app.revanced.util.microg.MicroGResourceHelper @Description("Resource patch to allow YouTube ReVanced to run without root and under a different package name.") @MicroGPatchCompatibility @Version("0.0.1") -class MicroGResourcePatch : ResourcePatch() { - override fun execute(data: ResourceData): PatchResult { +class MicroGResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { SettingsPatch.addPreference( Preference( StringResource("microg_settings", "MicroG Settings"), @@ -42,7 +41,7 @@ class MicroGResourcePatch : ResourcePatch() { // update manifest MicroGResourceHelper.patchManifest( - data, + context, PACKAGE_NAME, REVANCED_PACKAGE_NAME, REVANCED_APP_NAME @@ -50,7 +49,7 @@ class MicroGResourcePatch : ResourcePatch() { // add metadata to manifest MicroGManifestHelper.addSpoofingMetadata( - data, + context, SPOOFED_PACKAGE_NAME, SPOOFED_PACKAGE_SIGNATURE ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackKidsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackKidsFingerprint.kt index 7557753cb..0d5ad0519 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackKidsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackKidsFingerprint.kt @@ -3,16 +3,12 @@ package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.minimizedplayback.annotations.MinimizedPlaybackCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("minimized-playback-kids-fingerprint") -@MatchingMethod( - "LMinimizedPlaybackPolicyController;", "k" -) @MinimizedPlaybackCompatibility @Version("0.0.1") object MinimizedPlaybackKidsFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt index 5bf64a58f..eca6d9b84 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt @@ -3,17 +3,13 @@ package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.minimizedplayback.annotations.MinimizedPlaybackCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("minimized-playback-manager-fingerprint") -@MatchingMethod( - "Lyuf", "n" -) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MinimizedPlaybackCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt index 65b90778d..17184324e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt @@ -4,16 +4,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.minimizedplayback.annotations.MinimizedPlaybackCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("minimized-playback-manager-fingerprint") -@MatchingMethod( - "Ladj", "w" -) @FuzzyPatternScanMethod(2) @MinimizedPlaybackCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt index ddb309382..bf3b630cb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -3,20 +3,20 @@ package app.revanced.patches.youtube.misc.minimizedplayback.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData -import app.revanced.patcher.data.impl.toMethodWalker +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.toMethodWalker import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod +import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.minimizedplayback.annotations.MinimizedPlaybackCompatibility import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackKidsFingerprint import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackSettingsFingerprint -import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference @@ -35,7 +35,7 @@ class MinimizedPlaybackPatch : BytecodePatch( MinimizedPlaybackKidsFingerprint, MinimizedPlaybackManagerFingerprint, MinimizedPlaybackSettingsFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.MISC.addPreferences( SwitchPreference( "revanced_enable_minimized_playback", @@ -62,7 +62,7 @@ class MinimizedPlaybackPatch : BytecodePatch( val settingsBooleanIndex = booleanCalls.elementAt(1).index val settingsBooleanMethod = - data.toMethodWalker(method).nextMethod(settingsBooleanIndex, true).getMethod() as MutableMethod + context.toMethodWalker(method).nextMethod(settingsBooleanIndex, true).getMethod() as MutableMethod settingsBooleanMethod.addInstructions( 0, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt index 5575b6f2e..d21e6cea5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt @@ -3,14 +3,14 @@ package app.revanced.patches.youtube.misc.playercontrols.bytecode.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch import app.revanced.patches.youtube.misc.playercontrols.annotation.PlayerControlsCompatibility import app.revanced.patches.youtube.misc.playercontrols.fingerprints.BottomControlsInflateFingerprint @@ -25,7 +25,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction class PlayerControlsBytecodePatch : BytecodePatch( listOf(PlayerControlsVisibilityFingerprint) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { showPlayerControlsFingerprintResult = PlayerControlsVisibilityFingerprint.result!! bottomUiContainerResourceId = ResourceMappingResourcePatch @@ -33,7 +33,7 @@ class PlayerControlsBytecodePatch : BytecodePatch( .single { it.type == "id" && it.name == "bottom_ui_container_stub" }.id // TODO: another solution is required, this is hacky - listOf(BottomControlsInflateFingerprint).resolve(data, data.classes) + listOf(BottomControlsInflateFingerprint).resolve(context, context.classes) inflateFingerprintResult = BottomControlsInflateFingerprint.result!! return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt index 066de6918..08cd78ab0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt @@ -2,8 +2,7 @@ package app.revanced.patches.youtube.misc.playercontrols.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.playercontrols.annotation.PlayerControlsCompatibility import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch @@ -11,10 +10,6 @@ import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.WideLiteralInstruction @Name("bottom-controls-inflate-fingerprint") -@MatchingMethod( - "Lknf;", "a" -) -@DirectPatternScanMethod @PlayerControlsCompatibility @Version("0.0.1") object BottomControlsInflateFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt index ddb4d00f6..d2f0b1f10 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt @@ -2,16 +2,11 @@ package app.revanced.patches.youtube.misc.playercontrols.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.playercontrols.annotation.PlayerControlsCompatibility @Name("player-controls-visibility-fingerprint") -@MatchingMethod( - "LYouTubeControlsOverlay;", "ag" -) -@DirectPatternScanMethod @PlayerControlsCompatibility @Version("0.0.1") object PlayerControlsVisibilityFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/resource/patch/BottomControlsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/resource/patch/BottomControlsResourcePatch.kt index b6a51c8d6..fbba6efd3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/resource/patch/BottomControlsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/resource/patch/BottomControlsResourcePatch.kt @@ -3,25 +3,24 @@ package app.revanced.patches.youtube.misc.playercontrols.resource.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.DomFileEditor -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.DomFileEditor +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.playercontrols.annotation.PlayerControlsCompatibility -import java.io.Closeable @Name("bottom-controls-resource-patch") @DependsOn([FixLocaleConfigErrorPatch::class]) @Description("Manages the resources for the bottom controls of the YouTube player.") @PlayerControlsCompatibility @Version("0.0.1") -class BottomControlsResourcePatch : ResourcePatch(), Closeable { - override fun execute(data: ResourceData): PatchResult { - resourceData = data - targetXmlEditor = data.xmlEditor[TARGET_RESOURCE] +class BottomControlsResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + resourceContext = context + targetXmlEditor = context.xmlEditor[TARGET_RESOURCE] return PatchResultSuccess() } @@ -30,7 +29,7 @@ class BottomControlsResourcePatch : ResourcePatch(), Closeable { internal const val TARGET_RESOURCE_NAME = "youtube_controls_bottom_ui_container.xml" private const val TARGET_RESOURCE = "res/layout/$TARGET_RESOURCE_NAME" - private lateinit var resourceData: ResourceData + private lateinit var resourceContext: ResourceContext private lateinit var targetXmlEditor: DomFileEditor // The element to which to add the new elements to @@ -44,7 +43,7 @@ class BottomControlsResourcePatch : ResourcePatch(), Closeable { */ internal fun addControls(hostYouTubeControlsBottomUiResourceName: String) { val sourceXmlEditor = - resourceData.xmlEditor[this::class.java.classLoader.getResourceAsStream( + resourceContext.xmlEditor[this::class.java.classLoader.getResourceAsStream( hostYouTubeControlsBottomUiResourceName )!!] diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt index a468346b8..f8391163a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt @@ -2,16 +2,11 @@ package app.revanced.patches.youtube.misc.playeroverlay.fingerprint import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.playeroverlay.annotation.PlayerOverlaysHookCompatibility @Name("player-overlays-onFinishInflate-fingerprint") -@MatchingMethod( - "LYouTubePlayerOverlaysLayout;", "onFinishInflate" -) -@DirectPatternScanMethod @PlayerOverlaysHookCompatibility @Version("0.0.1") object PlayerOverlaysOnFinishInflateFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt index 3e99bd394..9b1c95bc4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.youtube.misc.playeroverlay.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.playeroverlay.annotation.PlayerOverlaysHookCompatibility import app.revanced.patches.youtube.misc.playeroverlay.fingerprint.PlayerOverlaysOnFinishInflateFingerprint @@ -23,7 +23,7 @@ class PlayerOverlaysHookPatch : BytecodePatch( PlayerOverlaysOnFinishInflateFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { // hook YouTubePlayerOverlaysLayout.onFinishInflate() val method = PlayerOverlaysOnFinishInflateFingerprint.result!!.mutableMethod method.addInstruction( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/fingerprint/UpdatePlayerTypeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/fingerprint/UpdatePlayerTypeFingerprint.kt index 55c98af9f..34d0becbb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/fingerprint/UpdatePlayerTypeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/fingerprint/UpdatePlayerTypeFingerprint.kt @@ -4,7 +4,6 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility import org.jf.dexlib2.AccessFlags @@ -12,10 +11,6 @@ import org.jf.dexlib2.Opcode //TODO constrain to only match in YoutubePlayerOverlaysLayout? @Name("update-player-type-fingerprint") -@MatchingMethod( - "LYoutubePlayerOverlaysLayout;", - "nM" -) @FuzzyPatternScanMethod(2) @SwipeControlsCompatibility @Version("0.0.1") diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt index 5fede4d53..75e722072 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.youtube.misc.playertype.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.playertype.annotation.PlayerTypeHookCompatibility import app.revanced.patches.youtube.misc.playertype.fingerprint.UpdatePlayerTypeFingerprint @@ -23,7 +23,7 @@ class PlayerTypeHookPatch : BytecodePatch( UpdatePlayerTypeFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { // hook YouTubePlayerOverlaysLayout.updatePlayerLayout() UpdatePlayerTypeFingerprint.result!!.mutableMethod.addInstruction( 0, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoQualityReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoQualityReferenceFingerprint.kt index 0a9c3236d..0bfc31ee6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoQualityReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoQualityReferenceFingerprint.kt @@ -4,14 +4,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.misc.quality.annotations.DefaultVideoQualityCompatibility -import org.jf.dexlib2.Opcode import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + @Name("video-quality-reference-fingerprint") -@MatchingMethod("Lkec;", "b") -@DirectPatternScanMethod @DefaultVideoQualityCompatibility @Version("0.0.1") object VideoQualityReferenceFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoQualitySetterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoQualitySetterFingerprint.kt index 8a235fb43..ffa0711ff 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoQualitySetterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoQualitySetterFingerprint.kt @@ -4,18 +4,13 @@ package app.revanced.patches.youtube.misc.quality.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.quality.annotations.DefaultVideoQualityCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("video-quality-setter-fingerprint") -@MatchingMethod( - "Lkec;", "a" -) -@DirectPatternScanMethod @DefaultVideoQualityCompatibility @Version("0.0.1") object VideoQualitySetterFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoUserQualityChangeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoUserQualityChangeFingerprint.kt index a211df1d2..292c409f9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoUserQualityChangeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/fingerprints/VideoUserQualityChangeFingerprint.kt @@ -5,15 +5,12 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patches.youtube.misc.quality.annotations.DefaultVideoQualityCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("video-user-quality-change-fingerprint") -@MatchingMethod("Lkec;", "onItemClick") -@DirectPatternScanMethod @DefaultVideoQualityCompatibility @Version("0.0.1") object VideoUserQualityChangeFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/RememberVideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/RememberVideoQualityPatch.kt index bdbdce845..4fbfe0878 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/RememberVideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/RememberVideoQualityPatch.kt @@ -3,15 +3,15 @@ package app.revanced.patches.youtube.misc.quality.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.quality.annotations.DefaultVideoQualityCompatibility import app.revanced.patches.youtube.misc.quality.fingerprints.VideoQualityReferenceFingerprint @@ -20,10 +20,8 @@ import app.revanced.patches.youtube.misc.quality.fingerprints.VideoUserQualityCh import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsResourcePatch import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch import org.jf.dexlib2.iface.instruction.ReferenceInstruction -import org.jf.dexlib2.iface.instruction.SwitchPayload import org.jf.dexlib2.iface.reference.FieldReference @Patch @@ -37,23 +35,29 @@ class RememberVideoQualityPatch : BytecodePatch( VideoQualitySetterFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.MISC.addPreferences( SwitchPreference( "revanced_remember_video_quality_selection", StringResource("revanced_remember_video_quality_selection_title", "Remember current video quality"), true, - StringResource("revanced_remember_video_quality_selection_summary_on", "The current video quality will not change"), - StringResource("revanced_remember_video_quality_selection_summary_off", "Video quality will be remembered until a new quality is chosen") + StringResource( + "revanced_remember_video_quality_selection_summary_on", + "The current video quality will not change" + ), + StringResource( + "revanced_remember_video_quality_selection_summary_off", + "Video quality will be remembered until a new quality is chosen" + ) ) ) val setterMethod = VideoQualitySetterFingerprint.result!! - VideoUserQualityChangeFingerprint.resolve(data, setterMethod.classDef) + VideoUserQualityChangeFingerprint.resolve(context, setterMethod.classDef) val userQualityMethod = VideoUserQualityChangeFingerprint.result!! - VideoQualityReferenceFingerprint.resolve(data, setterMethod.classDef) + VideoQualityReferenceFingerprint.resolve(context, setterMethod.classDef) val qualityFieldReference = VideoQualityReferenceFingerprint.result!!.method.let { method -> (method.implementation!!.instructions.elementAt(0) as ReferenceInstruction).reference as FieldReference @@ -62,7 +66,7 @@ class RememberVideoQualityPatch : BytecodePatch( VideoIdPatch.injectCall("Lapp/revanced/integrations/patches/VideoQualityPatch;->newVideoStarted(Ljava/lang/String;)V") val qIndexMethodName = - data.classes.single { it.type == qualityFieldReference.type }.methods.single { it.parameterTypes.first() == "I" }.name + context.classes.single { it.type == qualityFieldReference.type }.methods.single { it.parameterTypes.first() == "I" }.name setterMethod.mutableMethod.addInstructions( 0, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/LicenseActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/LicenseActivityFingerprint.kt index 90f06116a..3770e867f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/LicenseActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/LicenseActivityFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility // TODO: This is more of a class fingerprint than a method fingerprint. // Convert to a class fingerprint whenever possible. @Name("license-activity-fingerprint") -@MatchingMethod( - "Lcom/google/android/libraries/social/licenses/LicenseActivity;", "onCreate" -) @SettingsCompatibility @Version("0.0.1") object LicenseActivityFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ReVancedSettingsActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ReVancedSettingsActivityFingerprint.kt index c557ae3e2..5ca32c8c2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ReVancedSettingsActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ReVancedSettingsActivityFingerprint.kt @@ -2,16 +2,12 @@ package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility // TODO: This is more of a class fingerprint than a method fingerprint. // Convert to a class fingerprint whenever possible. @Name("revanced-settings-activity-fingerprint") -@MatchingMethod( - "Lapp/revanced/integrations/settingsmenu/ReVancedSettingActivity;", "initializeSettings" -) @SettingsCompatibility @Version("0.0.1") object ReVancedSettingsActivityFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ThemeSetterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ThemeSetterFingerprint.kt index 252a18a98..b1ffa601b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ThemeSetterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ThemeSetterFingerprint.kt @@ -2,7 +2,6 @@ package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch @@ -10,9 +9,6 @@ import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.WideLiteralInstruction @Name("theme-setter-fingerprint") -@MatchingMethod( - "Lfyq;", "a" -) @SettingsCompatibility @Version("0.0.1") object ThemeSetterFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt index 006213c35..1cf7833b0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt @@ -3,14 +3,14 @@ package app.revanced.patches.youtube.misc.settings.bytecode.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.smali.toInstruction import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch @@ -40,8 +40,8 @@ import java.io.Closeable @Version("0.0.1") class SettingsPatch : BytecodePatch( listOf(LicenseActivityFingerprint, ReVancedSettingsActivityFingerprint, ThemeSetterFingerprint) -), Closeable { - override fun execute(data: BytecodeData): PatchResult { +) { + override fun execute(context: BytecodeContext): PatchResult { val licenseActivityResult = LicenseActivityFingerprint.result!! val settingsResult = ReVancedSettingsActivityFingerprint.result!! val themeSetterResult = ThemeSetterFingerprint.result!! diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsResourcePatch.kt index 80ad798f8..93177c2b7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsResourcePatch.kt @@ -2,12 +2,12 @@ package app.revanced.patches.youtube.misc.settings.resource.patch import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.DomFileEditor -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.DomFileEditor +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility @@ -18,19 +18,18 @@ import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources import org.w3c.dom.Element import org.w3c.dom.Node -import java.io.Closeable @Name("settings-resource-patch") @SettingsCompatibility @DependsOn([FixLocaleConfigErrorPatch::class, ResourceMappingResourcePatch::class]) @Version("0.0.1") -class SettingsResourcePatch : ResourcePatch(), Closeable { +class SettingsResourcePatch : ResourcePatch { - override fun execute(data: ResourceData): PatchResult { + override fun execute(context: ResourceContext): PatchResult { /* * create missing directory for the resources */ - data["res/drawable-ldrtl-xxxhdpi"].mkdirs() + context["res/drawable-ldrtl-xxxhdpi"].mkdirs() /* * copy layout resources @@ -51,10 +50,10 @@ class SettingsResourcePatch : ResourcePatch(), Closeable { "drawable-ldrtl-xxxhdpi", "quantum_ic_arrow_back_white_24.png" ) ).forEach { resourceGroup -> - data.copyResources("settings", resourceGroup) + context.copyResources("settings", resourceGroup) } - data.xmlEditor["AndroidManifest.xml"].use { editor -> + context.xmlEditor["AndroidManifest.xml"].use { editor -> editor.file.getElementsByTagName("manifest").item(0).also { it.appendChild(it.ownerDocument.createElement("uses-permission").also { element -> element.setAttribute("android:name", "android.permission.SCHEDULE_EXACT_ALARM") @@ -62,11 +61,11 @@ class SettingsResourcePatch : ResourcePatch(), Closeable { } } - revancedPreferencesEditor = data.xmlEditor["res/xml/revanced_prefs.xml"] - preferencesEditor = data.xmlEditor["res/xml/settings_fragment.xml"] + revancedPreferencesEditor = context.xmlEditor["res/xml/revanced_prefs.xml"] + preferencesEditor = context.xmlEditor["res/xml/settings_fragment.xml"] - stringsEditor = data.xmlEditor["res/values/strings.xml"] - arraysEditor = data.xmlEditor["res/values/arrays.xml"] + stringsEditor = context.xmlEditor["res/values/strings.xml"] + arraysEditor = context.xmlEditor["res/values/arrays.xml"] // Add the ReVanced settings to the YouTube settings val youtubePackage = "com.google.android.youtube" diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/MaxBufferFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/MaxBufferFingerprint.kt index 284bfacc7..81e8972d6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/MaxBufferFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/MaxBufferFingerprint.kt @@ -3,8 +3,7 @@ package app.revanced.patches.youtube.misc.videobuffer.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.videobuffer.annotations.CustomVideoBufferCompatibility import org.jf.dexlib2.AccessFlags @@ -12,10 +11,6 @@ import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction @Name("maxbuffer-fingerprint") -@MatchingMethod( - "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;", "r" -) -@DirectPatternScanMethod @CustomVideoBufferCompatibility @Version("0.0.1") object MaxBufferFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/PlaybackBufferFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/PlaybackBufferFingerprint.kt index 23618b661..a080e1990 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/PlaybackBufferFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/PlaybackBufferFingerprint.kt @@ -3,8 +3,7 @@ package app.revanced.patches.youtube.misc.videobuffer.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.videobuffer.annotations.CustomVideoBufferCompatibility import org.jf.dexlib2.AccessFlags @@ -12,10 +11,6 @@ import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction @Name("playbackbuffer-fingerprint") -@MatchingMethod( - "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;", "p" -) -@DirectPatternScanMethod @CustomVideoBufferCompatibility @Version("0.0.1") object PlaybackBufferFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/ReBufferFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/ReBufferFingerprint.kt index b6401af0c..3ca083f28 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/ReBufferFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/fingerprints/ReBufferFingerprint.kt @@ -3,8 +3,7 @@ package app.revanced.patches.youtube.misc.videobuffer.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.videobuffer.annotations.CustomVideoBufferCompatibility import org.jf.dexlib2.AccessFlags @@ -12,10 +11,6 @@ import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction @Name("playbackbuffer-fingerprint") -@MatchingMethod( - "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;", "t" -) -@DirectPatternScanMethod @CustomVideoBufferCompatibility @Version("0.0.1") object ReBufferFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt index ef1f37188..18587ebf9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt @@ -3,15 +3,15 @@ package app.revanced.patches.youtube.misc.videobuffer.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.instruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.InputType @@ -35,7 +35,7 @@ class CustomVideoBufferPatch : BytecodePatch( MaxBufferFingerprint, PlaybackBufferFingerprint, ReBufferFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { SettingsPatch.PreferenceScreen.MISC.addPreferences( PreferenceScreen( "revanced_custom_video_buffer", diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/fingerprint/VideoIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/fingerprint/VideoIdFingerprint.kt index 13e7e18e9..aa78b715c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/fingerprint/VideoIdFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/fingerprint/VideoIdFingerprint.kt @@ -3,18 +3,13 @@ package app.revanced.patches.youtube.misc.videoid.fingerprint import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod + import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.videoid.annotation.VideoIdCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @Name("video-id-fingerprint") -@MatchingMethod( - "Lcom/google/android/apps/youtube/app/common/player/PlaybackLifecycleMonitor;", "l" -) -@DirectPatternScanMethod @VideoIdCompatibility @Version("0.0.1") object VideoIdFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt index 4ca4a14ef..5b03992ee 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.misc.videoid.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.videoid.annotation.VideoIdCompatibility @@ -26,7 +26,7 @@ class VideoIdPatch : BytecodePatch( VideoIdFingerprint ) ) { - override fun execute(data: BytecodeData): PatchResult { + override fun execute(context: BytecodeContext): PatchResult { result = VideoIdFingerprint.result!! insertMethod = result.mutableMethod diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt index 60ab5b42d..6b7d68d41 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt @@ -1,6 +1,6 @@ package app.revanced.util.microg -import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint @@ -78,13 +78,13 @@ internal object MicroGBytecodeHelper { * Note: this only handles string constants to gms (intent actions, authorities, ...). * If the app employs additional checks to validate the installed gms package, you'll have to handle those in the app- specific patch * - * @param data Bytecode data instance. + * @param context The context. * @param additionalStringTransforms Additional transformations applied to all const-string references. * @param primeMethodTransformationData Data to patch the prime method. * @param earlyReturns List of [MethodFingerprint] to return the resolved methods early. */ fun patchBytecode( - data: BytecodeData, + context: BytecodeContext, additionalStringTransforms: Array<(str: String) -> String?>, primeMethodTransformationData: PrimeMethodTransformationData, earlyReturns: List @@ -99,7 +99,7 @@ internal object MicroGBytecodeHelper { ) // transform all strings using all provided transforms, first match wins - data.transformStringReferences transform@{ + context.transformStringReferences transform@{ for (transformFn in allTransforms) { val s = transformFn(it) if (s != null) return@transform s @@ -160,7 +160,7 @@ internal object MicroGBytecodeHelper { * * @param transformFn string transformation function. if null, string is not changed. */ - private fun BytecodeData.transformStringReferences(transformFn: (str: String) -> String?) { + private fun BytecodeContext.transformStringReferences(transformFn: (str: String) -> String?) { classes.forEach { classDef -> var mutableClass: MutableClass? = null @@ -179,7 +179,7 @@ internal object MicroGBytecodeHelper { val transformedStr = transformFn(str) if (transformedStr != null) { // make class and method mutable, if not already - mutableClass = mutableClass ?: proxy(classDef).resolve() + mutableClass = mutableClass ?: proxy(classDef).mutableClass mutableMethod = mutableMethod ?: mutableClass!!.methods.first { it.name == methodDef.name && it.parameterTypes.containsAll(methodDef.parameterTypes) } diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGManifestHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGManifestHelper.kt index c2e87889b..003fa00e3 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGManifestHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGManifestHelper.kt @@ -1,6 +1,6 @@ package app.revanced.util.microg -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext import app.revanced.util.microg.Constants.META_GMS_PACKAGE_NAME import app.revanced.util.microg.Constants.META_SPOOFED_PACKAGE_NAME import app.revanced.util.microg.Constants.META_SPOOFED_PACKAGE_SIGNATURE @@ -17,16 +17,16 @@ internal object MicroGManifestHelper { * Add manifest entries needed for package and signature spoofing when using MicroG. * Note: this only adds metadata entries for signature spoofing, other changes may still be required to make a microG patch work. * - * @param data Resource data. + * @param context Resource context. * @param spoofedPackage The package to spoof. * @param spoofedSignature The signature to spoof. */ fun addSpoofingMetadata( - data: ResourceData, + context: ResourceContext, spoofedPackage: String, spoofedSignature: String ) { - data.xmlEditor["AndroidManifest.xml"].use { + context.xmlEditor["AndroidManifest.xml"].use { val applicationNode = it .file .getElementsByTagName("application") diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt index 4d218686d..f3ab36f6d 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt @@ -1,6 +1,6 @@ package app.revanced.util.microg -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.ResourceContext /** * Helper class for applying resource patches needed for the microg-support patches. @@ -9,19 +9,19 @@ internal object MicroGResourceHelper { /** * Patch the manifest to work with MicroG. * - * @param data Bytecode data instance. + * @param context Bytecode context. * @param fromPackageName Original package name. * @param toPackageName The package name to accept. * @param toName The new name of the app. */ fun patchManifest( - data: ResourceData, + context: ResourceContext, fromPackageName: String, toPackageName: String, toName: String ) { - val manifest = data["AndroidManifest.xml"].readText() - data["AndroidManifest.xml"].writeText( + val manifest = context["AndroidManifest.xml"].readText() + context["AndroidManifest.xml"].writeText( manifest.replace( "package=\"$fromPackageName", "package=\"$toPackageName" diff --git a/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt b/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt index 167375a18..c160e788e 100644 --- a/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt @@ -1,7 +1,7 @@ package app.revanced.util.resources -import app.revanced.patcher.data.impl.DomFileEditor -import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.data.DomFileEditor +import app.revanced.patcher.data.ResourceContext import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource import org.w3c.dom.Node @@ -18,7 +18,7 @@ internal object ResourceUtils { * Merge strings. This handles [StringResource]s automatically. * @param host The hosting xml resource. Needs to be a valid strings.xml resource. */ - internal fun ResourceData.mergeStrings(host: String) { + internal fun ResourceContext.mergeStrings(host: String) { this.iterateXmlNodeChildren(host, "resources") { // TODO: figure out why this is needed if (!it.hasAttributes()) return@iterateXmlNodeChildren @@ -39,7 +39,7 @@ internal object ResourceUtils { * @param sourceResourceDirectory The source resource directory name. * @param resources The resources to copy. */ - internal fun ResourceData.copyResources(sourceResourceDirectory: String, vararg resources: ResourceGroup) { + internal fun ResourceContext.copyResources(sourceResourceDirectory: String, vararg resources: ResourceGroup) { val classLoader = ResourceUtils.javaClass.classLoader val targetResourceDirectory = this["res"] @@ -67,7 +67,11 @@ internal object ResourceUtils { * @param targetTag The target xml node. * @param callback The callback to call when iterating over the nodes. */ - internal fun ResourceData.iterateXmlNodeChildren(resource: String, targetTag: String, callback: (node: Node) -> Unit) = + internal fun ResourceContext.iterateXmlNodeChildren( + resource: String, + targetTag: String, + callback: (node: Node) -> Unit + ) = xmlEditor[ResourceUtils.javaClass.classLoader.getResourceAsStream(resource)!!].use { val stringsNode = it.file.getElementsByTagName(targetTag).item(0).childNodes for (i in 1 until stringsNode.length - 1) callback(stringsNode.item(i))