fix(YouTube/Overlay buttons): chang the patch to be applied only in PiP mode

This commit is contained in:
inotia00 2023-10-17 15:26:27 +09:00
parent 72d09eb988
commit 22c54c42f4
5 changed files with 63 additions and 4 deletions

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.overlaybutton.downloadbuttonhook
package app.revanced.patches.youtube.overlaybutton.download.hook
import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext
@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.overlaybutton.downloadbuttonhook.fingerprints.DownloadActionsFingerprint
import app.revanced.patches.youtube.overlaybutton.download.hook.fingerprints.DownloadActionsFingerprint
import app.revanced.util.integrations.Constants.UTILS_PATH
object DownloadButtonHookPatch : BytecodePatch(

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.overlaybutton.downloadbuttonhook.fingerprints
package app.revanced.patches.youtube.overlaybutton.download.hook.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -0,0 +1,38 @@
package app.revanced.patches.youtube.overlaybutton.download.pip
import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.youtube.overlaybutton.download.pip.fingerprints.PiPPlaybackFingerprint
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
/**
* Temporarily disable PiP when the external download button is clicked.
* This patch works independently of the MinimizedPlayback patch.
*/
object DisablePiPPatch : BytecodePatch(
setOf(PiPPlaybackFingerprint)
) {
private const val INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR =
"$INTEGRATIONS_PATH/utils/VideoHelpers;"
override fun execute(context: BytecodeContext) {
PiPPlaybackFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
addInstructions(
insertIndex, """
invoke-static {v$insertRegister}, $INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR->isPiPAvailable(Z)Z
move-result v$insertRegister
"""
)
}
} ?: throw PiPPlaybackFingerprint.exception
}
}

View File

@ -0,0 +1,19 @@
package app.revanced.patches.youtube.overlaybutton.download.pip.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object PiPPlaybackFingerprint : MethodFingerprint(
returnType = "Z",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("Lcom/google/android/libraries/youtube/innertube/model/player/PlayerResponseModel;"),
opcodes = listOf(
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
Opcode.IF_NEZ
)
)

View File

@ -6,7 +6,8 @@ import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.overlaybutton.alwaysrepeat.AlwaysRepeatPatch
import app.revanced.patches.youtube.overlaybutton.downloadbuttonhook.DownloadButtonHookPatch
import app.revanced.patches.youtube.overlaybutton.download.hook.DownloadButtonHookPatch
import app.revanced.patches.youtube.overlaybutton.download.pip.DisablePiPPatch
import app.revanced.patches.youtube.utils.overridespeed.OverrideSpeedHookPatch
import app.revanced.patches.youtube.utils.playerbutton.PlayerButtonHookPatch
import app.revanced.patches.youtube.utils.playercontrols.PlayerControlsPatch
@ -24,6 +25,7 @@ import org.w3c.dom.Element
description = "Add overlay buttons to the player.",
dependencies = [
AlwaysRepeatPatch::class,
DisablePiPPatch::class,
DownloadButtonHookPatch::class,
OverrideSpeedHookPatch::class,
PlayerButtonHookPatch::class,