diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/annotations/DefaultVideoQualityCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/annotations/DefaultVideoQualityCompatibility.kt index 79118f27..d3a085b6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/annotations/DefaultVideoQualityCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/annotations/DefaultVideoQualityCompatibility.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package @Compatibility( [Package( - "com.google.android.youtube", arrayOf("17.22.36", "17.24.35", "17.26.35", "17.27.39") + "com.google.android.youtube", arrayOf("17.22.36", "17.24.35", "17.26.35", "17.27.39", "17.28.34", "17.29.34") )] ) @Target(AnnotationTarget.CLASS) 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 5a180fb1..8a235fb4 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,18 @@ 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.impl.MethodFingerprint -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +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" + "Lkec;", "a" ) -@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. +@DirectPatternScanMethod @DefaultVideoQualityCompatibility @Version("0.0.1") object VideoQualitySetterFingerprint : MethodFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/DefaultVideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/DefaultVideoQualityPatch.kt index e70915e7..f325aab0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/DefaultVideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/DefaultVideoQualityPatch.kt @@ -17,26 +17,22 @@ import app.revanced.patches.youtube.misc.quality.annotations.DefaultVideoQuality import app.revanced.patches.youtube.misc.quality.fingerprints.VideoQualityReferenceFingerprint import app.revanced.patches.youtube.misc.quality.fingerprints.VideoQualitySetterFingerprint import app.revanced.patches.youtube.misc.quality.fingerprints.VideoUserQualityChangeFingerprint -import app.revanced.patches.youtube.misc.videoid.fingerprint.VideoIdFingerprint +import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.reference.FieldReference -@Dependencies( - dependencies = [IntegrationsPatch::class] -) +@Patch +@Dependencies([IntegrationsPatch::class, VideoIdPatch::class]) @Name("default-video-quality") @Description("Adds the ability to select preferred video quality.") @DefaultVideoQualityCompatibility @Version("0.0.1") class DefaultVideoQualityPatch : BytecodePatch( listOf( - VideoQualitySetterFingerprint, - VideoIdFingerprint + VideoQualitySetterFingerprint ) - ) { override fun execute(data: BytecodeData): PatchResult { - val offset = 4 val setterMethod = VideoQualitySetterFingerprint.result!! VideoUserQualityChangeFingerprint.resolve(data, setterMethod.classDef) @@ -48,6 +44,8 @@ class DefaultVideoQualityPatch : BytecodePatch( (method.implementation!!.instructions.elementAt(0) as ReferenceInstruction).reference as FieldReference } + 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 @@ -61,15 +59,6 @@ class DefaultVideoQualityPatch : BytecodePatch( """, ) - val newVideoMethod = VideoIdFingerprint.result!! - val newVideoIndex = newVideoMethod.patternScanResult!!.endIndex + offset - newVideoMethod.mutableMethod.addInstructions( - newVideoIndex, """ - const/4 v6, 0x1 - invoke-static {v6}, Lapp/revanced/integrations/utils/ReVancedUtils;->setNewVideo(Z)V - """ - ) - userQualityMethod.mutableMethod.addInstruction( 0, "invoke-static {p3}, Lapp/revanced/integrations/patches/VideoQualityPatch;->userChangedQuality(I)V"