From 3de7307a95af320f73b6197ddf6a3e0f5572ee09 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sun, 14 Jul 2024 14:35:37 +0900 Subject: [PATCH] feat(YouTube): add support version `19.26.42` --- .../youtube/utils/compatibility/Constants.kt | 2 +- .../utils/fingerprints/VideoEndFingerprint.kt | 16 +++------ .../BottomSheetRecyclerViewPatch.kt | 36 +++++++++++-------- .../RecyclerViewTreeObserverFingerprint.kt | 9 ----- 4 files changed, 26 insertions(+), 37 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/compatibility/Constants.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/compatibility/Constants.kt index 4b4ec9305..d2f787b64 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/compatibility/Constants.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/compatibility/Constants.kt @@ -13,7 +13,7 @@ object Constants { "18.48.39", // This is the last version that do not use Rolling Number. "19.05.36", // This is the last version with the least YouTube experimental flag. "19.16.39", // This is the last version that supports the 'Restore old seekbar thumbnails' setting. - "19.25.39", // This is the latest version supported by the RVX patch. + "19.26.42", // This is the latest version supported by the RVX patch. ) ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/VideoEndFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/VideoEndFingerprint.kt index fea4ffb05..2f52a0d27 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/VideoEndFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/VideoEndFingerprint.kt @@ -1,16 +1,8 @@ package app.revanced.patches.youtube.utils.fingerprints -import app.revanced.patcher.fingerprint.MethodFingerprint -import com.android.tools.smali.dexlib2.Opcode +import app.revanced.util.fingerprint.LiteralValueFingerprint -internal object VideoEndFingerprint : MethodFingerprint( - opcodes = listOf( - Opcode.INVOKE_VIRTUAL, - Opcode.INVOKE_VIRTUAL_RANGE, - Opcode.IGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.CHECK_CAST, - Opcode.CONST_WIDE_32 - ), - strings = listOf("Attempting to seek during an ad") +internal object VideoEndFingerprint : LiteralValueFingerprint( + strings = listOf("Attempting to seek during an ad"), + literalSupplier = { 45368273 } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/recyclerview/BottomSheetRecyclerViewPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/recyclerview/BottomSheetRecyclerViewPatch.kt index 47cad01e1..514d22838 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/recyclerview/BottomSheetRecyclerViewPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/recyclerview/BottomSheetRecyclerViewPatch.kt @@ -3,13 +3,18 @@ package app.revanced.patches.youtube.utils.recyclerview import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.youtube.utils.recyclerview.fingerprints.BottomSheetRecyclerViewBuilderFingerprint import app.revanced.patches.youtube.utils.recyclerview.fingerprints.RecyclerViewTreeObserverFingerprint +import app.revanced.util.getReference +import app.revanced.util.getTargetIndexReversedOrThrow import app.revanced.util.getWideLiteralInstructionIndex +import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.resultOrThrow +import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import com.android.tools.smali.dexlib2.iface.reference.FieldReference object BottomSheetRecyclerViewPatch : BytecodePatch( setOf( @@ -17,7 +22,9 @@ object BottomSheetRecyclerViewPatch : BytecodePatch( RecyclerViewTreeObserverFingerprint ) ) { - private lateinit var recyclerViewTreeObserverResult: MethodFingerprintResult + private lateinit var recyclerViewTreeObserverMutableMethod: MutableMethod + + private var recyclerViewTreeObserverInsertIndex = 0 override fun execute(context: BytecodeContext) { @@ -39,22 +46,21 @@ object BottomSheetRecyclerViewPatch : BytecodePatch( } } - recyclerViewTreeObserverResult = RecyclerViewTreeObserverFingerprint.resultOrThrow() + RecyclerViewTreeObserverFingerprint.resultOrThrow().mutableMethod.apply { + recyclerViewTreeObserverMutableMethod = this - } - - fun injectCall(descriptor: String) { - recyclerViewTreeObserverResult.let { - it.mutableMethod.apply { - val insertIndex = it.scanResult.patternScanResult!!.startIndex - val recyclerViewRegister = 2 - - addInstruction( - insertIndex, - "invoke-static/range { p$recyclerViewRegister .. p$recyclerViewRegister }, $descriptor" - ) + val onDrawListenerIndex = indexOfFirstInstructionOrThrow { + opcode == Opcode.IPUT_OBJECT + && getReference()?.type == "Landroid/view/ViewTreeObserver${'$'}OnDrawListener;" } + recyclerViewTreeObserverInsertIndex = getTargetIndexReversedOrThrow(onDrawListenerIndex, Opcode.CHECK_CAST) + 1 } } + + internal fun injectCall(descriptor: String) = + recyclerViewTreeObserverMutableMethod.addInstruction( + recyclerViewTreeObserverInsertIndex++, + "invoke-static/range { p2 .. p2 }, $descriptor" + ) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/recyclerview/fingerprints/RecyclerViewTreeObserverFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/recyclerview/fingerprints/RecyclerViewTreeObserverFingerprint.kt index 58007cf84..3aab14815 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/recyclerview/fingerprints/RecyclerViewTreeObserverFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/recyclerview/fingerprints/RecyclerViewTreeObserverFingerprint.kt @@ -3,18 +3,9 @@ package app.revanced.patches.youtube.utils.recyclerview.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags -import com.android.tools.smali.dexlib2.Opcode internal object RecyclerViewTreeObserverFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, - opcodes = listOf( - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.INVOKE_VIRTUAL, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.IPUT_OBJECT - ), strings = listOf("LithoRVSLCBinder") ) \ No newline at end of file