mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-16 14:27:18 +02:00
refactor(enable-old-quality-layout): improve the patch method
This commit is contained in:
parent
6aefd9bd87
commit
a4ca3b8ca9
@ -6,7 +6,22 @@ import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object QualityMenuViewInflateFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(Opcode.INVOKE_SUPER),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_SUPER,
|
||||
Opcode.CONST,
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CONST_16,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST
|
||||
),
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any {
|
||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
|
@ -0,0 +1,18 @@
|
||||
package app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object VideoQualitySettingsFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("[L", "I", "Z"),
|
||||
opcodes = listOf(
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.IF_EQ,
|
||||
Opcode.IF_EQ
|
||||
),
|
||||
strings = listOf("menu_item_video_quality")
|
||||
)
|
@ -7,18 +7,18 @@ 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.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.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint
|
||||
import app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.fingerprints.*
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch
|
||||
import app.revanced.patches.youtube.video.quality.bytecode.fingerprints.VideoQualitySettingsParentFingerprint
|
||||
import app.revanced.util.integrations.Constants.FLYOUT_PANEL_LAYOUT
|
||||
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@ -27,7 +27,8 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@DependsOn(
|
||||
[
|
||||
LegacyVideoIdPatch::class,
|
||||
SettingsPatch::class
|
||||
SettingsPatch::class,
|
||||
SharedResourcdIdPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@ -35,24 +36,23 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
class OldQualityLayoutPatch : BytecodePatch(
|
||||
listOf(
|
||||
QualityMenuViewInflateFingerprint,
|
||||
VideoQualitySettingsParentFingerprint
|
||||
VideoQualitySettingsFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
QualityMenuViewInflateFingerprint.result?.mutableMethod?.let {
|
||||
with (it.implementation!!.instructions) {
|
||||
val insertIndex = this.size - 1 - 1
|
||||
val register = (this[insertIndex] as FiveRegisterInstruction).registerC
|
||||
|
||||
it.addInstruction(
|
||||
insertIndex + 1,
|
||||
QualityMenuViewInflateFingerprint.result?.let {
|
||||
with (it.mutableMethod) {
|
||||
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val register = (instruction(endIndex) as OneRegisterInstruction).registerA
|
||||
addInstruction(
|
||||
endIndex + 1,
|
||||
"invoke-static { v$register }, $FLYOUT_PANEL_LAYOUT->enableOldQualityMenu(Landroid/widget/ListView;)V"
|
||||
)
|
||||
}
|
||||
} ?: return QualityMenuViewInflateFingerprint.toErrorResult()
|
||||
|
||||
VideoQualitySettingsParentFingerprint.result?.let {
|
||||
VideoQualitySettingsFingerprint.result?.let {
|
||||
with (it.mutableMethod) {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex + LegacyVideoIdPatch.qualityOffSet
|
||||
val register = (this.implementation!!.instructions[insertIndex] as OneRegisterInstruction).registerA
|
||||
@ -63,7 +63,7 @@ class OldQualityLayoutPatch : BytecodePatch(
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return VideoQualitySettingsParentFingerprint.toErrorResult()
|
||||
} ?: return VideoQualitySettingsFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
|
Loading…
x
Reference in New Issue
Block a user