fix(youtube/integrations): fix playback of embedded videos (#2304)
This commit is contained in:
parent
2669f881fc
commit
1dffbaf0aa
|
@ -0,0 +1,17 @@
|
|||
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
|
||||
|
||||
/**
|
||||
* For embedded playback.
|
||||
* It appears this hook may no longer be needed as one of the constructor parameters is the already hooked
|
||||
* [EmbeddedPlayerControlsOverlayFingerprint]
|
||||
*/
|
||||
object APIPlayerServiceFingerprint : IntegrationsFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/service/jar/ApiPlayerService;" },
|
||||
// Integrations context is the first method parameter.
|
||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size }
|
||||
)
|
|
@ -2,6 +2,10 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints
|
|||
|
||||
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
|
||||
|
||||
object InitFingerprint : IntegrationsFingerprint(
|
||||
/**
|
||||
* Hooks the context when the app is launched as a regular application (and is not an embedded video playback).
|
||||
*/
|
||||
object ApplicationInitFingerprint : IntegrationsFingerprint(
|
||||
strings = listOf("Application creation", "Application.onCreate"),
|
||||
// Integrations context is the Activity itself.
|
||||
)
|
|
@ -4,12 +4,19 @@ import app.revanced.patcher.extensions.or
|
|||
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
/**
|
||||
* For embedded playback inside Google Play store (and probably other situations as well).
|
||||
*
|
||||
* Note: this fingerprint may no longer be needed, as it appears
|
||||
* [RemoteEmbedFragmentFingerprint] may be set before this hook is called.
|
||||
*/
|
||||
object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint(
|
||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
||||
returnType = "V",
|
||||
parameters = listOf("L", "L", "L"),
|
||||
parameters = listOf("Landroid/content/Context;", "L", "L"),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass.startsWith("Lcom/google/android/apps/youtube/embeddedplayer/service/ui/overlays/controlsoverlay/remoteloaded/")
|
||||
},
|
||||
// Integrations context is the first method parameter.
|
||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size }
|
||||
)
|
|
@ -0,0 +1,20 @@
|
|||
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
|
||||
|
||||
/**
|
||||
* For embedded playback inside the Google app (such as the in app 'discover' tab).
|
||||
*
|
||||
* Note: this fingerprint may or may not be needed, as
|
||||
* [RemoteEmbedFragmentFingerprint] might be set before this is called.
|
||||
*/
|
||||
object EmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
returnType = "L",
|
||||
parameters = listOf("L", "L", "Landroid/content/Context;"),
|
||||
strings = listOf("android.hardware.type.television"), // String is also found in other classes
|
||||
// Integrations context is the third method parameter.
|
||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size + 2 }
|
||||
)
|
|
@ -0,0 +1,19 @@
|
|||
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
|
||||
|
||||
/**
|
||||
* For embedded playback. Likely covers Google Play store and other Google products.
|
||||
*/
|
||||
object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
returnType = "V",
|
||||
parameters = listOf("Landroid/content/Context;", "L", "L"),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/jar/client/RemoteEmbedFragment;"
|
||||
},
|
||||
// Integrations context is the first method parameter.
|
||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size }
|
||||
)
|
|
@ -0,0 +1,19 @@
|
|||
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
|
||||
|
||||
/**
|
||||
* For embedded playback inside 3rd party android app (such as 3rd party Reddit apps).
|
||||
*/
|
||||
object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
||||
returnType = "V",
|
||||
parameters = listOf("Landroid/content/Context;", "L", "L", "Z"),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass == "Lcom/google/android/youtube/api/jar/client/RemoteEmbeddedPlayer;"
|
||||
},
|
||||
// Integrations context is the first method parameter.
|
||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size }
|
||||
)
|
|
@ -1,8 +0,0 @@
|
|||
package app.revanced.patches.youtube.misc.integrations.fingerprints
|
||||
|
||||
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
|
||||
|
||||
object ServiceFingerprint : IntegrationsFingerprint(
|
||||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("ApiPlayerService;") && methodDef.name == "<init>" },
|
||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size }
|
||||
)
|
|
@ -0,0 +1,18 @@
|
|||
package app.revanced.patches.youtube.misc.integrations.fingerprints
|
||||
|
||||
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
|
||||
|
||||
/**
|
||||
* Old API activity to embed YouTube into 3rd party Android apps.
|
||||
*
|
||||
* In 2023 supported was ended and is no longer available,
|
||||
* but this may still be used by older apps:
|
||||
* https://developers.google.com/youtube/android/player
|
||||
*/
|
||||
object StandalonePlayerActivityFingerprint : IntegrationsFingerprint(
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass == "Lcom/google/android/youtube/api/StandalonePlayerActivity;"
|
||||
&& methodDef.name == "onCreate"
|
||||
},
|
||||
// Integrations context is the Activity itself.
|
||||
)
|
|
@ -1,10 +0,0 @@
|
|||
package app.revanced.patches.youtube.misc.integrations.fingerprints
|
||||
|
||||
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
|
||||
|
||||
object StandalonePlayerFingerprint : IntegrationsFingerprint(
|
||||
strings = listOf(
|
||||
"Invalid PlaybackStartDescriptor. Returning the instance itself.",
|
||||
"com.google.android.music",
|
||||
),
|
||||
)
|
|
@ -4,15 +4,26 @@ import app.revanced.patcher.annotation.Name
|
|||
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
|
||||
import app.revanced.patches.youtube.misc.integrations.fingerprints.EmbeddedPlayerFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.fingerprints.ApplicationInitFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.fingerprints.RemoteEmbedFragmentFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.fingerprints.RemoteEmbeddedPlayerFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.fingerprints.APIPlayerServiceFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.fingerprints.StandalonePlayerActivityFingerprint
|
||||
|
||||
@Name("integrations")
|
||||
@IntegrationsCompatibility
|
||||
@RequiresIntegrations
|
||||
class IntegrationsPatch : AbstractIntegrationsPatch(
|
||||
"Lapp/revanced/integrations/utils/ReVancedUtils;",
|
||||
listOf(InitFingerprint, StandalonePlayerFingerprint, ServiceFingerprint, EmbeddedPlayerControlsOverlayFingerprint),
|
||||
listOf(
|
||||
ApplicationInitFingerprint,
|
||||
StandalonePlayerActivityFingerprint,
|
||||
RemoteEmbeddedPlayerFingerprint,
|
||||
RemoteEmbedFragmentFingerprint,
|
||||
EmbeddedPlayerControlsOverlayFingerprint,
|
||||
EmbeddedPlayerFingerprint,
|
||||
APIPlayerServiceFingerprint,
|
||||
),
|
||||
)
|
Loading…
Reference in a new issue