mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-02 18:12:57 +01:00
fix: default-video-quality
patch crashing (#227)
This commit is contained in:
parent
2b774ac3f5
commit
379327a6b2
@ -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)
|
||||
|
@ -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(
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user