mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-02 15:44:37 +02:00
fix(YouTube/Overlay buttons): Always repeat
button doesn't work when the video is minimized https://github.com/inotia00/ReVanced_Extended/issues/2293
This commit is contained in:
parent
1b73a5a444
commit
ecd96f252d
@ -4,98 +4,21 @@ import app.revanced.patcher.data.BytecodeContext
|
|||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchException
|
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
import app.revanced.patches.youtube.player.overlaybuttons.fingerprints.PlayerButtonConstructorFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||||
import app.revanced.util.addFieldAndInstructions
|
|
||||||
import app.revanced.util.getReference
|
|
||||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
|
||||||
import app.revanced.util.indexOfFirstInstruction
|
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
|
||||||
import app.revanced.util.resultOrThrow
|
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
|
||||||
|
|
||||||
@Patch(dependencies = [VideoInformationPatch::class])
|
@Patch(dependencies = [VideoInformationPatch::class])
|
||||||
object OverlayButtonsBytecodePatch : BytecodePatch(
|
object OverlayButtonsBytecodePatch : BytecodePatch(
|
||||||
setOf(PlayerButtonConstructorFingerprint)
|
emptySet()
|
||||||
) {
|
) {
|
||||||
private const val INTEGRATIONS_ALWAYS_REPEAT_CLASS_DESCRIPTOR =
|
private const val INTEGRATIONS_ALWAYS_REPEAT_CLASS_DESCRIPTOR =
|
||||||
"$UTILS_PATH/AlwaysRepeatPatch;"
|
"$UTILS_PATH/AlwaysRepeatPatch;"
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
// region patch for always repeat and pause
|
// region patch for always repeat
|
||||||
|
|
||||||
PlayerButtonConstructorFingerprint.resultOrThrow().mutableMethod.apply {
|
|
||||||
val registerResolver = implementation!!.registerCount - parameters.size - 1 + 6 // p6
|
|
||||||
|
|
||||||
var invokerObjectIndex = indexOfFirstInstruction {
|
|
||||||
opcode == Opcode.IPUT_OBJECT
|
|
||||||
&& getReference<FieldReference>()?.definingClass == definingClass
|
|
||||||
&& (this as TwoRegisterInstruction).registerA == registerResolver
|
|
||||||
}
|
|
||||||
if (invokerObjectIndex < 0) {
|
|
||||||
val moveObjectIndex = indexOfFirstInstructionOrThrow {
|
|
||||||
(this as? TwoRegisterInstruction)?.registerB == registerResolver
|
|
||||||
}
|
|
||||||
val moveObjectRegister =
|
|
||||||
getInstruction<TwoRegisterInstruction>(moveObjectIndex).registerA
|
|
||||||
invokerObjectIndex = indexOfFirstInstructionOrThrow(moveObjectIndex) {
|
|
||||||
opcode == Opcode.IPUT_OBJECT
|
|
||||||
&& getReference<FieldReference>()?.definingClass == definingClass
|
|
||||||
&& (this as TwoRegisterInstruction).registerA == moveObjectRegister
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val invokerObjectReference =
|
|
||||||
getInstruction<ReferenceInstruction>(invokerObjectIndex).reference
|
|
||||||
|
|
||||||
val onClickListenerReferenceIndex =
|
|
||||||
getTargetIndexWithReferenceOrThrow("<init>(Ljava/lang/Object;I[B)V")
|
|
||||||
val onClickListenerReference =
|
|
||||||
getInstruction<ReferenceInstruction>(onClickListenerReferenceIndex).reference
|
|
||||||
val onClickListenerClass =
|
|
||||||
context.findClass((onClickListenerReference as MethodReference).definingClass)!!.mutableClass
|
|
||||||
|
|
||||||
var invokeInterfaceReference = ""
|
|
||||||
onClickListenerClass.methods.find { method -> method.name == "onClick" }
|
|
||||||
?.apply {
|
|
||||||
val invokeInterfaceIndex =
|
|
||||||
getTargetIndexWithReferenceOrThrow(invokerObjectReference.toString()) + 1
|
|
||||||
if (getInstruction(invokeInterfaceIndex).opcode != Opcode.INVOKE_INTERFACE)
|
|
||||||
throw PatchException("Opcode does not match")
|
|
||||||
invokeInterfaceReference =
|
|
||||||
getInstruction<ReferenceInstruction>(invokeInterfaceIndex).reference.toString()
|
|
||||||
} ?: throw PatchException("Could not find onClick method")
|
|
||||||
|
|
||||||
val alwaysRepeatMutableClass =
|
|
||||||
context.findClass(INTEGRATIONS_ALWAYS_REPEAT_CLASS_DESCRIPTOR)!!.mutableClass
|
|
||||||
|
|
||||||
val smaliInstructions =
|
|
||||||
"""
|
|
||||||
if-eqz v0, :ignore
|
|
||||||
iget-object v1, v0, $invokerObjectReference
|
|
||||||
if-eqz v1, :ignore
|
|
||||||
invoke-interface {v1}, $invokeInterfaceReference
|
|
||||||
:ignore
|
|
||||||
return-void
|
|
||||||
"""
|
|
||||||
|
|
||||||
alwaysRepeatMutableClass.addFieldAndInstructions(
|
|
||||||
context,
|
|
||||||
"pauseVideo",
|
|
||||||
"pauseButtonClass",
|
|
||||||
definingClass,
|
|
||||||
smaliInstructions,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoInformationPatch.videoEndMethod.apply {
|
VideoInformationPatch.videoEndMethod.apply {
|
||||||
addInstructionsWithLabels(
|
addInstructionsWithLabels(
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.player.overlaybuttons.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.SingleLoopEduSnackBarText
|
|
||||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
|
||||||
|
|
||||||
internal object PlayerButtonConstructorFingerprint : LiteralValueFingerprint(
|
|
||||||
returnType = "V",
|
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
|
||||||
literalSupplier = { SingleLoopEduSnackBarText }
|
|
||||||
)
|
|
@ -99,7 +99,6 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
var Scrubbing = -1L
|
var Scrubbing = -1L
|
||||||
var SeekEasyHorizontalTouchOffsetToStartScrubbing = -1L
|
var SeekEasyHorizontalTouchOffsetToStartScrubbing = -1L
|
||||||
var SeekUndoEduOverlayStub = -1L
|
var SeekUndoEduOverlayStub = -1L
|
||||||
var SingleLoopEduSnackBarText = -1L
|
|
||||||
var SlidingDialogAnimation = -1L
|
var SlidingDialogAnimation = -1L
|
||||||
var SubtitleMenuSettingsFooterInfo = -1L
|
var SubtitleMenuSettingsFooterInfo = -1L
|
||||||
var SuggestedAction = -1L
|
var SuggestedAction = -1L
|
||||||
@ -208,7 +207,6 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
SeekEasyHorizontalTouchOffsetToStartScrubbing =
|
SeekEasyHorizontalTouchOffsetToStartScrubbing =
|
||||||
getId(DIMEN, "seek_easy_horizontal_touch_offset_to_start_scrubbing")
|
getId(DIMEN, "seek_easy_horizontal_touch_offset_to_start_scrubbing")
|
||||||
SeekUndoEduOverlayStub = getId(ID, "seek_undo_edu_overlay_stub")
|
SeekUndoEduOverlayStub = getId(ID, "seek_undo_edu_overlay_stub")
|
||||||
SingleLoopEduSnackBarText = getId(STRING, "single_loop_edu_snackbar_text")
|
|
||||||
SlidingDialogAnimation = getId(STYLE, "SlidingDialogAnimation")
|
SlidingDialogAnimation = getId(STYLE, "SlidingDialogAnimation")
|
||||||
SubtitleMenuSettingsFooterInfo = getId(STRING, "subtitle_menu_settings_footer_info")
|
SubtitleMenuSettingsFooterInfo = getId(STRING, "subtitle_menu_settings_footer_info")
|
||||||
SuggestedAction = getId(LAYOUT, "suggested_action")
|
SuggestedAction = getId(LAYOUT, "suggested_action")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user