mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-16 22:37:17 +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
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
object QualityMenuViewInflateFingerprint : MethodFingerprint(
|
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 ->
|
customFingerprint = { methodDef ->
|
||||||
methodDef.implementation?.instructions?.any {
|
methodDef.implementation?.instructions?.any {
|
||||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
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.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.addInstruction
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.instruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
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.settings.resource.patch.SettingsPatch
|
||||||
import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch
|
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 app.revanced.util.integrations.Constants.FLYOUT_PANEL_LAYOUT
|
||||||
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@ -27,7 +27,8 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
@DependsOn(
|
@DependsOn(
|
||||||
[
|
[
|
||||||
LegacyVideoIdPatch::class,
|
LegacyVideoIdPatch::class,
|
||||||
SettingsPatch::class
|
SettingsPatch::class,
|
||||||
|
SharedResourcdIdPatch::class
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@YouTubeCompatibility
|
@YouTubeCompatibility
|
||||||
@ -35,24 +36,23 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
class OldQualityLayoutPatch : BytecodePatch(
|
class OldQualityLayoutPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
QualityMenuViewInflateFingerprint,
|
QualityMenuViewInflateFingerprint,
|
||||||
VideoQualitySettingsParentFingerprint
|
VideoQualitySettingsFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
QualityMenuViewInflateFingerprint.result?.mutableMethod?.let {
|
QualityMenuViewInflateFingerprint.result?.let {
|
||||||
with (it.implementation!!.instructions) {
|
with (it.mutableMethod) {
|
||||||
val insertIndex = this.size - 1 - 1
|
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
val register = (this[insertIndex] as FiveRegisterInstruction).registerC
|
val register = (instruction(endIndex) as OneRegisterInstruction).registerA
|
||||||
|
addInstruction(
|
||||||
it.addInstruction(
|
endIndex + 1,
|
||||||
insertIndex + 1,
|
|
||||||
"invoke-static { v$register }, $FLYOUT_PANEL_LAYOUT->enableOldQualityMenu(Landroid/widget/ListView;)V"
|
"invoke-static { v$register }, $FLYOUT_PANEL_LAYOUT->enableOldQualityMenu(Landroid/widget/ListView;)V"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: return QualityMenuViewInflateFingerprint.toErrorResult()
|
} ?: return QualityMenuViewInflateFingerprint.toErrorResult()
|
||||||
|
|
||||||
VideoQualitySettingsParentFingerprint.result?.let {
|
VideoQualitySettingsFingerprint.result?.let {
|
||||||
with (it.mutableMethod) {
|
with (it.mutableMethod) {
|
||||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex + LegacyVideoIdPatch.qualityOffSet
|
val insertIndex = it.scanResult.patternScanResult!!.startIndex + LegacyVideoIdPatch.qualityOffSet
|
||||||
val register = (this.implementation!!.instructions[insertIndex] as OneRegisterInstruction).registerA
|
val register = (this.implementation!!.instructions[insertIndex] as OneRegisterInstruction).registerA
|
||||||
@ -63,7 +63,7 @@ class OldQualityLayoutPatch : BytecodePatch(
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: return VideoQualitySettingsParentFingerprint.toErrorResult()
|
} ?: return VideoQualitySettingsFingerprint.toErrorResult()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add settings
|
* Add settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user