fix(youtube/enable-old-quality-layout): not working in new player flyout panel

This commit is contained in:
inotia00 2023-07-03 20:13:00 +09:00
parent 25e460f6d6
commit f3aa092371
4 changed files with 50 additions and 5 deletions

View File

@ -0,0 +1,14 @@
package app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.BottomSheetMargins
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
object NewQualityLayoutBuilderFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
returnType = "Landroid/widget/LinearLayout;",
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(BottomSheetMargins) }
)

View File

@ -1,11 +1,16 @@
package app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.VideoQualityBottomSheet
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object QualityMenuViewInflateFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L", "L", "L"),
returnType = "L",
opcodes = listOf(
Opcode.INVOKE_SUPER,
Opcode.CONST,

View File

@ -12,9 +12,11 @@ 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.youtube.flyoutpanel.oldqualitylayout.fingerprints.NewQualityLayoutBuilderFingerprint
import app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint
import app.revanced.patches.youtube.utils.alertdialog.patch.NewLayoutAlertDialogPatch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
@ -27,6 +29,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@DependsOn(
[
NewLayoutAlertDialogPatch::class,
LithoFilterPatch::class,
SettingsPatch::class,
SharedResourceIdPatch::class
]
@ -34,22 +37,43 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class OldQualityLayoutPatch : BytecodePatch(
listOf(QualityMenuViewInflateFingerprint)
listOf(
NewQualityLayoutBuilderFingerprint,
QualityMenuViewInflateFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
/**
* For old player flyout panels
*/
QualityMenuViewInflateFingerprint.result?.let {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val register = getInstruction<OneRegisterInstruction>(endIndex).registerA
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
addInstruction(
endIndex + 1,
"invoke-static { v$register }, $FLYOUT_PANEL->enableOldQualityMenu(Landroid/widget/ListView;)V"
insertIndex + 1,
"invoke-static { v$insertRegister }, $FLYOUT_PANEL->enableOldQualityMenu(Landroid/widget/ListView;)V"
)
}
} ?: return QualityMenuViewInflateFingerprint.toErrorResult()
/**
* For new player flyout panels
*/
NewQualityLayoutBuilderFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
addInstruction(
insertIndex,
"invoke-static { v$insertRegister }, $FLYOUT_PANEL->enableOldQualityMenu(Landroid/widget/LinearLayout;)V"
)
}
} ?: return NewQualityLayoutBuilderFingerprint.toErrorResult()
context.updatePatchStatus("OldQualityLayout")
/**

View File

@ -36,6 +36,7 @@ class SharedResourceIdPatch : ResourcePatch {
var BackgroundCategory: Long = -1
var BarContainerHeight: Long = -1
var BottomPanelOverlayText: Long = -1
var BottomSheetMargins: Long = -1
var BottomSheetRecyclerView: Long = -1
var BottomUiContainerStub: Long = -1
var ChannelListSubMenu: Long = -1
@ -105,6 +106,7 @@ class SharedResourceIdPatch : ResourcePatch {
BackgroundCategory = find(STRING, "pref_background_and_offline_category")
BarContainerHeight = find(DIMEN, "bar_container_height")
BottomPanelOverlayText = find(ID, "bottom_panel_overlay_text")
BottomSheetMargins = find(DIMEN, "bottom_sheet_margins")
BottomSheetRecyclerView = find(LAYOUT, "bottom_sheet_recycler_view")
BottomUiContainerStub = find(ID, "bottom_ui_container_stub")
ChannelListSubMenu = find(LAYOUT, "channel_list_sub_menu")