mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-28 04:40:19 +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 com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
internal object InitFingerprint : IntegrationsFingerprint(
|
||||
returnType = "V",
|
||||
parameters = emptyList(),
|
||||
|
@ -2,7 +2,6 @@ package app.revanced.patches.reddit.utils.integrations.fingerprints
|
||||
|
||||
import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
internal object InitFingerprint : IntegrationsFingerprint(
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass.endsWith("/FrontpageApplication;") &&
|
||||
|
@ -16,16 +16,6 @@ abstract class BaseIntegrationsPatch(
|
||||
private val hooks: Set<IntegrationsFingerprint>,
|
||||
) : 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) {
|
||||
if (context.findClass(INTEGRATIONS_UTILS_CLASS_DESCRIPTOR) == null) {
|
||||
throw PatchException(
|
||||
@ -52,7 +42,7 @@ abstract class BaseIntegrationsPatch(
|
||||
strings: Iterable<String>? = null,
|
||||
customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null,
|
||||
private val insertIndexResolver: ((Method) -> Int) = object : IHookInsertIndexResolver {},
|
||||
private val contextRegisterResolver: (Method) -> Int = object : IRegisterResolver {}
|
||||
private val contextRegisterResolver: (Method) -> String = object : IRegisterResolver {},
|
||||
) : MethodFingerprint(
|
||||
returnType,
|
||||
accessFlags,
|
||||
@ -61,27 +51,6 @@ abstract class BaseIntegrationsPatch(
|
||||
strings,
|
||||
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) {
|
||||
resultOrThrow().mutableMethod.let { method ->
|
||||
@ -90,7 +59,7 @@ abstract class BaseIntegrationsPatch(
|
||||
|
||||
method.addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static/range { v$contextRegister .. v$contextRegister }, " +
|
||||
"invoke-static/range { $contextRegister .. $contextRegister }, " +
|
||||
"$integrationsDescriptor->setContext(Landroid/content/Context;)V",
|
||||
)
|
||||
}
|
||||
@ -100,8 +69,8 @@ abstract class BaseIntegrationsPatch(
|
||||
override operator fun invoke(method: Method) = 0
|
||||
}
|
||||
|
||||
interface IRegisterResolver : (Method) -> Int {
|
||||
override operator fun invoke(method: Method) = method.implementation!!.registerCount - 1
|
||||
interface IRegisterResolver : (Method) -> String {
|
||||
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
|
||||
* [EmbeddedPlayerControlsOverlayFingerprint]
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
internal 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 }
|
||||
contextRegisterResolver = { "p1" }
|
||||
)
|
@ -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).
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
internal object ApplicationInitFingerprint : IntegrationsFingerprint(
|
||||
strings = listOf("Application creation", "Application.onCreate"),
|
||||
// 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
|
||||
* [RemoteEmbedFragmentFingerprint] may be set before this hook is called.
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
internal object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint(
|
||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
||||
returnType = "V",
|
||||
@ -18,6 +17,5 @@ internal object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerpri
|
||||
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 }
|
||||
contextRegisterResolver = { "p1" }
|
||||
)
|
@ -10,12 +10,10 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
||||
* Note: this fingerprint may or may not be needed, as
|
||||
* [RemoteEmbedFragmentFingerprint] might be set before this is called.
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
internal 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 }
|
||||
contextRegisterResolver = { "p2" }
|
||||
)
|
@ -7,7 +7,6 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
||||
/**
|
||||
* For embedded playback. Likely covers Google Play store and other Google products.
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
internal object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
returnType = "V",
|
||||
@ -15,6 +14,5 @@ internal object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint(
|
||||
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 }
|
||||
contextRegisterResolver = { "p1" }
|
||||
)
|
@ -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).
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
internal object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
||||
returnType = "V",
|
||||
@ -15,6 +14,5 @@ internal object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
||||
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 }
|
||||
contextRegisterResolver = { "p1" }
|
||||
)
|
@ -9,7 +9,6 @@ import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.Integratio
|
||||
* but this may still be used by older apps:
|
||||
* https://developers.google.com/youtube/android/player
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
internal object StandalonePlayerActivityFingerprint : IntegrationsFingerprint(
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass == "Lcom/google/android/youtube/api/StandalonePlayerActivity;"
|
||||
|
Loading…
x
Reference in New Issue
Block a user