refactor(default-video-quality): improve the patch method

This commit is contained in:
inotia00 2023-03-06 12:15:04 +09:00
parent a4ca3b8ca9
commit e2a4d02acf
2 changed files with 5 additions and 3 deletions

View File

@ -10,8 +10,8 @@ object VideoQualitySettingsParentFingerprint : MethodFingerprint(
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("[L", "I", "Z"),
opcodes = listOf(
Opcode.IF_EQZ,
Opcode.IF_EQ,
Opcode.IF_NE,
Opcode.IGET,
Opcode.IF_EQ
),
strings = listOf("menu_item_video_quality")

View File

@ -6,6 +6,7 @@ import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
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
@ -51,6 +52,7 @@ class VideoQualityBytecodePatch : BytecodePatch(
relayFieldReference = (it.implementation!!.instructions.elementAt(0) as ReferenceInstruction).reference as FieldReference
} ?: return VideoQualitySettingsFingerprint.toErrorResult()
parentResult.mutableMethod.removeInstruction(parentResult.scanResult.patternScanResult!!.endIndex)
parentResult.mutableMethod.addInstructions(
0, """
iget-object v0, p0, ${parentResult.classDef.type}->${relayFieldReference.name}:${relayFieldReference.type}
@ -61,7 +63,7 @@ class VideoQualityBytecodePatch : BytecodePatch(
"""
)
LegacyVideoIdPatch.qualityOffSet = 5
LegacyVideoIdPatch.qualityOffSet = 4
} ?: return VideoQualitySettingsParentFingerprint.toErrorResult()
LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")