From 8a43d75e2db63c47bb9ad1b75027df0868c094e5 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 7 May 2023 20:27:35 +0400 Subject: [PATCH] fix(youtube/integrations): allow playback of embedded videos (#2092) Co-authored-by: oSumAtrIX --- .../patch/AbstractIntegrationsPatch.kt | 14 +++++++++++++- .../EmbeddedPlayerControlsOverlayFingerprint.kt | 15 +++++++++++++++ .../misc/integrations/patch/IntegrationsPatch.kt | 3 ++- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/shared/integrations/patch/AbstractIntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/integrations/patch/AbstractIntegrationsPatch.kt index 2ef2e48d..018d2f14 100644 --- a/src/main/kotlin/app/revanced/patches/shared/integrations/patch/AbstractIntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/integrations/patch/AbstractIntegrationsPatch.kt @@ -9,6 +9,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess +import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.Method @Description("Applies mandatory patches to implement the ReVanced integrations into the application.") @@ -24,10 +25,21 @@ abstract class AbstractIntegrationsPatch( * @see MethodFingerprint */ abstract class IntegrationsFingerprint( + returnType: String? = null, + access: Int? = null, + parameters: Iterable? = null, + opcodes: Iterable? = null, strings: Iterable? = null, customFingerprint: ((methodDef: Method) -> Boolean)? = null, private val contextRegisterResolver: (Method) -> Int = object : RegisterResolver {} - ) : MethodFingerprint(strings = strings, customFingerprint = customFingerprint) { + ) : MethodFingerprint( + returnType, + access, + parameters, + opcodes, + strings, + customFingerprint + ) { fun invoke(integrationsDescriptor: String): PatchResult { result?.mutableMethod?.let { method -> val contextRegister = contextRegisterResolver(method) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt new file mode 100644 index 00000000..6b103165 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.youtube.misc.integrations.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint +import org.jf.dexlib2.AccessFlags + +object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint( + access = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR, + returnType = "V", + parameters = listOf("L", "L", "L"), + customFingerprint = { methodDef -> + methodDef.definingClass.startsWith("Lcom/google/android/apps/youtube/embeddedplayer/service/ui/overlays/controlsoverlay/remoteloaded/") + }, + contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt index 6fb114ba..10a9dc93 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt @@ -5,6 +5,7 @@ import app.revanced.patcher.patch.annotations.RequiresIntegrations import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch import app.revanced.patches.youtube.misc.integrations.annotations.IntegrationsCompatibility import app.revanced.patches.youtube.misc.integrations.fingerprints.InitFingerprint +import app.revanced.patches.youtube.misc.integrations.fingerprints.EmbeddedPlayerControlsOverlayFingerprint import app.revanced.patches.youtube.misc.integrations.fingerprints.ServiceFingerprint import app.revanced.patches.youtube.misc.integrations.fingerprints.StandalonePlayerFingerprint @@ -13,5 +14,5 @@ import app.revanced.patches.youtube.misc.integrations.fingerprints.StandalonePla @RequiresIntegrations class IntegrationsPatch : AbstractIntegrationsPatch( "Lapp/revanced/integrations/utils/ReVancedUtils;", - listOf(InitFingerprint, StandalonePlayerFingerprint, ServiceFingerprint), + listOf(InitFingerprint, StandalonePlayerFingerprint, ServiceFingerprint, EmbeddedPlayerControlsOverlayFingerprint), ) \ No newline at end of file