mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
fix(YouTube): do not crash if root installation opens a video in the Play store
This commit is contained in:
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user