drop support for old YouTube versions

This commit is contained in:
inotia00 2023-05-03 21:53:27 +09:00
parent bd1428fc34
commit b086822adb
4 changed files with 18 additions and 67 deletions

View File

@ -6,17 +6,10 @@ import app.revanced.patcher.annotation.Package
@Compatibility(
[Package(
"com.google.android.youtube", arrayOf(
"18.06.41",
"18.07.35",
"18.08.39",
"18.09.39",
"18.10.37",
"18.11.36",
"18.12.35",
"18.13.38",
"18.14.41",
"18.15.40",
"18.16.37",
"18.16.39"
)
)]

View File

@ -47,8 +47,6 @@ class ButtonContainerPatch : ResourcePatch {
"""
with(LithoFilterPatch.lithoMethod) {
if (LithoFilterPatch.bufferFingerprintResolved) {
// 18.11.36+
addInstructions(
0, """
move-object/from16 v10, p3
@ -58,15 +56,6 @@ class ButtonContainerPatch : ResourcePatch {
iget-object v10, v10, ${LithoFilterPatch.bufferReference}->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0)))
)
} else {
val secondParameter = LithoFilterPatch.lithoMethod.parameters[2]
LithoFilterPatch.lithoMethod.addInstructions(
0, """
move-object/from16 v10, p3
iget-object v10, v10, $secondParameter->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0)))
)
}
}
/*

View File

@ -47,8 +47,6 @@ class QuickActionsPatch : ResourcePatch {
"""
with(LithoFilterPatch.lithoMethod) {
if (LithoFilterPatch.bufferFingerprintResolved) {
// 18.11.36+
addInstructions(
0, """
move-object/from16 v10, p3
@ -58,15 +56,6 @@ class QuickActionsPatch : ResourcePatch {
iget-object v10, v10, ${LithoFilterPatch.bufferReference}->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0)))
)
} else {
val secondParameter = LithoFilterPatch.lithoMethod.parameters[2]
LithoFilterPatch.lithoMethod.addInstructions(
0, """
move-object/from16 v10, p3
iget-object v10, v10, $secondParameter->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0)))
)
}
}
/*

View File

@ -47,15 +47,10 @@ class LithoFilterPatch : BytecodePatch(
) {
override fun execute(context: BytecodeContext): PatchResult {
try {
with (LithoBufferFingerprint.result!!) {
val startIndex = this.scanResult.patternScanResult!!.startIndex
bufferReference = (this.mutableMethod.instruction(startIndex) as BuilderInstruction21c).reference.toString()
}
bufferFingerprintResolved = true
} catch (_: Exception) {
bufferFingerprintResolved = false
}
LithoObjectFingerprint.result?.let {
val endIndex = it.scanResult.patternScanResult!!.endIndex
@ -67,14 +62,12 @@ class LithoFilterPatch : BytecodePatch(
lithoMethod = result.mutableMethod
with (lithoMethod.implementation!!.instructions) {
// 18.06.41+
val bufferIndex = indexOfFirst {
it.opcode == Opcode.CONST &&
(it as Instruction31i).narrowLiteral == 168777401
}
val bufferRegister = (lithoMethod.instruction(bufferIndex) as Instruction31i).registerA
// 18.06.41+
val targetIndex = indexOfFirst {
it.opcode == Opcode.CONST_STRING &&
(it as BuilderInstruction21c).reference.toString() == "Element missing type extension"
@ -103,8 +96,6 @@ class LithoFilterPatch : BytecodePatch(
return-object v0
"""
if (bufferFingerprintResolved) {
// 18.11.36+
val objectIndex = indexOfFirst {
it.opcode == Opcode.CONST_STRING &&
(it as BuilderInstruction21c).reference.toString() == ""
@ -120,16 +111,6 @@ class LithoFilterPatch : BytecodePatch(
iget-object v$bufferRegister, v$bufferRegister, $bufferReference->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("not_an_ad", lithoMethod.instruction(insertIndex + 1)))
)
} else {
val secondParameter = lithoMethod.parameters[2]
lithoMethod.addInstructions(
insertIndex + 1,
"""
move-object/from16 v$bufferRegister, p3
iget-object v$bufferRegister, v$bufferRegister, $secondParameter->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("not_an_ad", lithoMethod.instruction(insertIndex + 1)))
)
}
}
}
} ?: return LithoFingerprint.toErrorResult()
@ -140,7 +121,6 @@ class LithoFilterPatch : BytecodePatch(
}
internal companion object {
var objectRegister by Delegates.notNull<Int>()
var bufferFingerprintResolved by Delegates.notNull<Boolean>()
lateinit var lithoMethod: MutableMethod
lateinit var bufferReference: String