mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 05:10:20 +02:00
fix(YouTube): do not crash if root installation opens a video in the Play store
This commit is contained in:
parent
dafaa60087
commit
1a43c2b57e
@ -3,7 +3,6 @@ package app.revanced.patches.music.utils.integrations.fingerprints
|
|||||||
import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint
|
import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
internal object InitFingerprint : IntegrationsFingerprint(
|
internal object InitFingerprint : IntegrationsFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
parameters = emptyList(),
|
parameters = emptyList(),
|
||||||
|
@ -2,7 +2,6 @@ package app.revanced.patches.reddit.utils.integrations.fingerprints
|
|||||||
|
|
||||||
import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint
|
import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
internal object InitFingerprint : IntegrationsFingerprint(
|
internal object InitFingerprint : IntegrationsFingerprint(
|
||||||
customFingerprint = { methodDef, _ ->
|
customFingerprint = { methodDef, _ ->
|
||||||
methodDef.definingClass.endsWith("/FrontpageApplication;") &&
|
methodDef.definingClass.endsWith("/FrontpageApplication;") &&
|
||||||
|
@ -16,16 +16,6 @@ abstract class BaseIntegrationsPatch(
|
|||||||
private val hooks: Set<IntegrationsFingerprint>,
|
private val hooks: Set<IntegrationsFingerprint>,
|
||||||
) : BytecodePatch(hooks) {
|
) : BytecodePatch(hooks) {
|
||||||
|
|
||||||
@Deprecated(
|
|
||||||
"Use the constructor without the integrationsDescriptor parameter",
|
|
||||||
ReplaceWith("BaseIntegrationsPatch(hooks)"),
|
|
||||||
)
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
|
||||||
constructor(
|
|
||||||
integrationsDescriptor: String,
|
|
||||||
hooks: Set<IntegrationsFingerprint>,
|
|
||||||
) : this(hooks)
|
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
if (context.findClass(INTEGRATIONS_UTILS_CLASS_DESCRIPTOR) == null) {
|
if (context.findClass(INTEGRATIONS_UTILS_CLASS_DESCRIPTOR) == null) {
|
||||||
throw PatchException(
|
throw PatchException(
|
||||||
@ -52,7 +42,7 @@ abstract class BaseIntegrationsPatch(
|
|||||||
strings: Iterable<String>? = null,
|
strings: Iterable<String>? = null,
|
||||||
customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null,
|
customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null,
|
||||||
private val insertIndexResolver: ((Method) -> Int) = object : IHookInsertIndexResolver {},
|
private val insertIndexResolver: ((Method) -> Int) = object : IHookInsertIndexResolver {},
|
||||||
private val contextRegisterResolver: (Method) -> Int = object : IRegisterResolver {}
|
private val contextRegisterResolver: (Method) -> String = object : IRegisterResolver {},
|
||||||
) : MethodFingerprint(
|
) : MethodFingerprint(
|
||||||
returnType,
|
returnType,
|
||||||
accessFlags,
|
accessFlags,
|
||||||
@ -61,27 +51,6 @@ abstract class BaseIntegrationsPatch(
|
|||||||
strings,
|
strings,
|
||||||
customFingerprint,
|
customFingerprint,
|
||||||
) {
|
) {
|
||||||
@Deprecated("Previous constructor that is missing the insert index." +
|
|
||||||
"Here only for binary compatibility, " +
|
|
||||||
"and this can be removed after the next major version update.")
|
|
||||||
constructor(
|
|
||||||
returnType: String? = null,
|
|
||||||
accessFlags: Int? = null,
|
|
||||||
parameters: Iterable<String>? = null,
|
|
||||||
opcodes: Iterable<Opcode?>? = null,
|
|
||||||
strings: Iterable<String>? = null,
|
|
||||||
customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null,
|
|
||||||
contextRegisterResolver: (Method) -> Int = object : IRegisterResolver {}
|
|
||||||
) : this(
|
|
||||||
returnType,
|
|
||||||
accessFlags,
|
|
||||||
parameters,
|
|
||||||
opcodes,
|
|
||||||
strings,
|
|
||||||
customFingerprint,
|
|
||||||
object : IHookInsertIndexResolver {},
|
|
||||||
contextRegisterResolver
|
|
||||||
)
|
|
||||||
|
|
||||||
fun invoke(integrationsDescriptor: String) {
|
fun invoke(integrationsDescriptor: String) {
|
||||||
resultOrThrow().mutableMethod.let { method ->
|
resultOrThrow().mutableMethod.let { method ->
|
||||||
@ -90,7 +59,7 @@ abstract class BaseIntegrationsPatch(
|
|||||||
|
|
||||||
method.addInstruction(
|
method.addInstruction(
|
||||||
insertIndex,
|
insertIndex,
|
||||||
"invoke-static/range { v$contextRegister .. v$contextRegister }, " +
|
"invoke-static/range { $contextRegister .. $contextRegister }, " +
|
||||||
"$integrationsDescriptor->setContext(Landroid/content/Context;)V",
|
"$integrationsDescriptor->setContext(Landroid/content/Context;)V",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -100,8 +69,8 @@ abstract class BaseIntegrationsPatch(
|
|||||||
override operator fun invoke(method: Method) = 0
|
override operator fun invoke(method: Method) = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IRegisterResolver : (Method) -> Int {
|
interface IRegisterResolver : (Method) -> String {
|
||||||
override operator fun invoke(method: Method) = method.implementation!!.registerCount - 1
|
override operator fun invoke(method: Method) = "p0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,10 +9,8 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
|||||||
* It appears this hook may no longer be needed as one of the constructor parameters is the already hooked
|
* It appears this hook may no longer be needed as one of the constructor parameters is the already hooked
|
||||||
* [EmbeddedPlayerControlsOverlayFingerprint]
|
* [EmbeddedPlayerControlsOverlayFingerprint]
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
internal object APIPlayerServiceFingerprint : IntegrationsFingerprint(
|
internal object APIPlayerServiceFingerprint : IntegrationsFingerprint(
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/service/jar/ApiPlayerService;" },
|
customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/service/jar/ApiPlayerService;" },
|
||||||
// Integrations context is the first method parameter.
|
contextRegisterResolver = { "p1" }
|
||||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size }
|
|
||||||
)
|
)
|
@ -5,7 +5,6 @@ import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.Integratio
|
|||||||
/**
|
/**
|
||||||
* Hooks the context when the app is launched as a regular application (and is not an embedded video playback).
|
* Hooks the context when the app is launched as a regular application (and is not an embedded video playback).
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
internal object ApplicationInitFingerprint : IntegrationsFingerprint(
|
internal object ApplicationInitFingerprint : IntegrationsFingerprint(
|
||||||
strings = listOf("Application creation", "Application.onCreate"),
|
strings = listOf("Application creation", "Application.onCreate"),
|
||||||
// Integrations context is the Activity itself.
|
// Integrations context is the Activity itself.
|
||||||
|
@ -10,7 +10,6 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
|||||||
* Note: this fingerprint may no longer be needed, as it appears
|
* Note: this fingerprint may no longer be needed, as it appears
|
||||||
* [RemoteEmbedFragmentFingerprint] may be set before this hook is called.
|
* [RemoteEmbedFragmentFingerprint] may be set before this hook is called.
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
internal object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint(
|
internal object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint(
|
||||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
@ -18,6 +17,5 @@ internal object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerpri
|
|||||||
customFingerprint = { methodDef, _ ->
|
customFingerprint = { methodDef, _ ->
|
||||||
methodDef.definingClass.startsWith("Lcom/google/android/apps/youtube/embeddedplayer/service/ui/overlays/controlsoverlay/remoteloaded/")
|
methodDef.definingClass.startsWith("Lcom/google/android/apps/youtube/embeddedplayer/service/ui/overlays/controlsoverlay/remoteloaded/")
|
||||||
},
|
},
|
||||||
// Integrations context is the first method parameter.
|
contextRegisterResolver = { "p1" }
|
||||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size }
|
|
||||||
)
|
)
|
@ -10,12 +10,10 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
|||||||
* Note: this fingerprint may or may not be needed, as
|
* Note: this fingerprint may or may not be needed, as
|
||||||
* [RemoteEmbedFragmentFingerprint] might be set before this is called.
|
* [RemoteEmbedFragmentFingerprint] might be set before this is called.
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
internal object EmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
internal object EmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||||
returnType = "L",
|
returnType = "L",
|
||||||
parameters = listOf("L", "L", "Landroid/content/Context;"),
|
parameters = listOf("L", "L", "Landroid/content/Context;"),
|
||||||
strings = listOf("android.hardware.type.television"), // String is also found in other classes
|
strings = listOf("android.hardware.type.television"), // String is also found in other classes
|
||||||
// Integrations context is the third method parameter.
|
contextRegisterResolver = { "p2" }
|
||||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size + 2 }
|
|
||||||
)
|
)
|
@ -7,7 +7,6 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
|||||||
/**
|
/**
|
||||||
* For embedded playback. Likely covers Google Play store and other Google products.
|
* For embedded playback. Likely covers Google Play store and other Google products.
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
internal object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint(
|
internal object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint(
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
@ -15,6 +14,5 @@ internal object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint(
|
|||||||
customFingerprint = { methodDef, _ ->
|
customFingerprint = { methodDef, _ ->
|
||||||
methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/jar/client/RemoteEmbedFragment;"
|
methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/jar/client/RemoteEmbedFragment;"
|
||||||
},
|
},
|
||||||
// Integrations context is the first method parameter.
|
contextRegisterResolver = { "p1" }
|
||||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size }
|
|
||||||
)
|
)
|
@ -7,7 +7,6 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
|||||||
/**
|
/**
|
||||||
* For embedded playback inside 3rd party android app (such as 3rd party Reddit apps).
|
* For embedded playback inside 3rd party android app (such as 3rd party Reddit apps).
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
internal object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
internal object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
||||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
@ -15,6 +14,5 @@ internal object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
|||||||
customFingerprint = { methodDef, _ ->
|
customFingerprint = { methodDef, _ ->
|
||||||
methodDef.definingClass == "Lcom/google/android/youtube/api/jar/client/RemoteEmbeddedPlayer;"
|
methodDef.definingClass == "Lcom/google/android/youtube/api/jar/client/RemoteEmbeddedPlayer;"
|
||||||
},
|
},
|
||||||
// Integrations context is the first method parameter.
|
contextRegisterResolver = { "p1" }
|
||||||
contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size }
|
|
||||||
)
|
)
|
@ -9,7 +9,6 @@ import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.Integratio
|
|||||||
* but this may still be used by older apps:
|
* but this may still be used by older apps:
|
||||||
* https://developers.google.com/youtube/android/player
|
* https://developers.google.com/youtube/android/player
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
internal object StandalonePlayerActivityFingerprint : IntegrationsFingerprint(
|
internal object StandalonePlayerActivityFingerprint : IntegrationsFingerprint(
|
||||||
customFingerprint = { methodDef, _ ->
|
customFingerprint = { methodDef, _ ->
|
||||||
methodDef.definingClass == "Lcom/google/android/youtube/api/StandalonePlayerActivity;"
|
methodDef.definingClass == "Lcom/google/android/youtube/api/StandalonePlayerActivity;"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user