mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
chore(YouTube): replace with a fingerprint that supports a wider range of versions
This commit is contained in:
@ -1,12 +1,32 @@
|
|||||||
package app.revanced.patches.youtube.general.downloads.fingerprints
|
package app.revanced.patches.youtube.general.downloads.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AccessibilityOfflineButtonSync
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
import app.revanced.patches.youtube.general.downloads.fingerprints.AccessibilityOfflineButtonSyncFingerprint.ENDS_WITH_PARAMETER_LIST
|
||||||
|
import app.revanced.util.parametersEqual
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||||
|
|
||||||
internal object AccessibilityOfflineButtonSyncFingerprint : LiteralValueFingerprint(
|
internal object AccessibilityOfflineButtonSyncFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
literalSupplier = { AccessibilityOfflineButtonSync },
|
customFingerprint = custom@{ methodDef, _ ->
|
||||||
)
|
if (!MethodUtil.isConstructor(methodDef)) {
|
||||||
|
return@custom false
|
||||||
|
}
|
||||||
|
val parameterTypes = methodDef.parameterTypes
|
||||||
|
val parameterSize = parameterTypes.size
|
||||||
|
if (parameterSize < 6) {
|
||||||
|
return@custom false
|
||||||
|
}
|
||||||
|
|
||||||
|
val endsWithMethodParameterList = parameterTypes.slice(parameterSize - 3..< parameterSize)
|
||||||
|
parametersEqual(ENDS_WITH_PARAMETER_LIST, endsWithMethodParameterList)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
private val ENDS_WITH_PARAMETER_LIST = listOf(
|
||||||
|
"Lcom/google/android/apps/youtube/app/offline/ui/OfflineArrowView;",
|
||||||
|
"I",
|
||||||
|
"Landroid/view/View${'$'}OnClickListener;"
|
||||||
|
)
|
||||||
|
}
|
@ -17,7 +17,6 @@ import app.revanced.patches.shared.mapping.ResourceType.STYLE
|
|||||||
|
|
||||||
@Patch(dependencies = [ResourceMappingPatch::class])
|
@Patch(dependencies = [ResourceMappingPatch::class])
|
||||||
object SharedResourceIdPatch : ResourcePatch() {
|
object SharedResourceIdPatch : ResourcePatch() {
|
||||||
var AccessibilityOfflineButtonSync = -1L
|
|
||||||
var AccountSwitcherAccessibility = -1L
|
var AccountSwitcherAccessibility = -1L
|
||||||
var ActionBarRingo = -1L
|
var ActionBarRingo = -1L
|
||||||
var ActionBarRingoBackground = -1L
|
var ActionBarRingoBackground = -1L
|
||||||
@ -127,7 +126,6 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
|
|
||||||
override fun execute(context: ResourceContext) {
|
override fun execute(context: ResourceContext) {
|
||||||
|
|
||||||
AccessibilityOfflineButtonSync = getId(STRING, "accessibility_offline_button_sync")
|
|
||||||
AccountSwitcherAccessibility = getId(STRING, "account_switcher_accessibility_label")
|
AccountSwitcherAccessibility = getId(STRING, "account_switcher_accessibility_label")
|
||||||
ActionBarRingo = getId(LAYOUT, "action_bar_ringo")
|
ActionBarRingo = getId(LAYOUT, "action_bar_ringo")
|
||||||
ActionBarRingoBackground = getId(LAYOUT, "action_bar_ringo_background")
|
ActionBarRingoBackground = getId(LAYOUT, "action_bar_ringo_background")
|
||||||
|
@ -10,7 +10,6 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
|||||||
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
||||||
import app.revanced.patches.youtube.video.playerresponse.PlayerResponseMethodHookPatch
|
import app.revanced.patches.youtube.video.playerresponse.PlayerResponseMethodHookPatch
|
||||||
import app.revanced.patches.youtube.video.videoid.fingerprints.VideoIdFingerprint
|
import app.revanced.patches.youtube.video.videoid.fingerprints.VideoIdFingerprint
|
||||||
import app.revanced.patches.youtube.video.videoid.fingerprints.VideoIdParentFingerprint
|
|
||||||
import app.revanced.util.resultOrThrow
|
import app.revanced.util.resultOrThrow
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@ -19,7 +18,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
dependencies = [PlayerResponseMethodHookPatch::class],
|
dependencies = [PlayerResponseMethodHookPatch::class],
|
||||||
)
|
)
|
||||||
object VideoIdPatch : BytecodePatch(
|
object VideoIdPatch : BytecodePatch(
|
||||||
setOf(VideoIdParentFingerprint)
|
setOf(VideoIdFingerprint)
|
||||||
) {
|
) {
|
||||||
private var videoIdRegister = 0
|
private var videoIdRegister = 0
|
||||||
private var videoIdInsertIndex = 0
|
private var videoIdInsertIndex = 0
|
||||||
@ -44,8 +43,6 @@ object VideoIdPatch : BytecodePatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoIdFingerprint.resolve(context, VideoIdParentFingerprint.resultOrThrow().classDef)
|
|
||||||
|
|
||||||
VideoIdFingerprint.setFields { method, index, register ->
|
VideoIdFingerprint.setFields { method, index, register ->
|
||||||
videoIdMethod = method
|
videoIdMethod = method
|
||||||
videoIdInsertIndex = index
|
videoIdInsertIndex = index
|
||||||
|
@ -2,8 +2,13 @@ package app.revanced.patches.youtube.video.videoid.fingerprints
|
|||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.PlayerResponseModelUtils.PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR
|
||||||
|
import app.revanced.util.getReference
|
||||||
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
internal object VideoIdFingerprint : MethodFingerprint(
|
internal object VideoIdFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
@ -14,5 +19,30 @@ internal object VideoIdFingerprint : MethodFingerprint(
|
|||||||
Opcode.MOVE_RESULT_OBJECT,
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
Opcode.INVOKE_INTERFACE,
|
Opcode.INVOKE_INTERFACE,
|
||||||
Opcode.MOVE_RESULT_OBJECT
|
Opcode.MOVE_RESULT_OBJECT
|
||||||
)
|
),
|
||||||
)
|
customFingerprint = custom@{ methodDef, classDef ->
|
||||||
|
if (!classDef.fields.any { it.type == "Lcom/google/android/libraries/youtube/player/subtitles/model/SubtitleTrack;" }) {
|
||||||
|
return@custom false
|
||||||
|
}
|
||||||
|
val implementation = methodDef.implementation
|
||||||
|
?: return@custom false
|
||||||
|
val instructions = implementation.instructions
|
||||||
|
val instructionCount = instructions.count()
|
||||||
|
if (instructionCount < 30) {
|
||||||
|
return@custom false
|
||||||
|
}
|
||||||
|
|
||||||
|
val reference = (instructions.elementAt(instructionCount - 2) as? ReferenceInstruction)?.reference.toString()
|
||||||
|
if (reference != "Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;") {
|
||||||
|
return@custom false
|
||||||
|
}
|
||||||
|
|
||||||
|
methodDef.indexOfFirstInstruction {
|
||||||
|
val methodReference = getReference<MethodReference>()
|
||||||
|
opcode == Opcode.INVOKE_INTERFACE &&
|
||||||
|
methodReference?.returnType == "Ljava/lang/String;" &&
|
||||||
|
methodReference.parameterTypes.isEmpty() &&
|
||||||
|
methodReference.definingClass == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR
|
||||||
|
} >= 0
|
||||||
|
},
|
||||||
|
)
|
@ -1,9 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.video.videoid.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
|
||||||
|
|
||||||
internal object VideoIdParentFingerprint : MethodFingerprint(
|
|
||||||
returnType = "V",
|
|
||||||
parameters = listOf("Ljava/lang/Object;", "Ljava/lang/Exception;"),
|
|
||||||
strings = listOf("error retrieving subtitle"),
|
|
||||||
)
|
|
Reference in New Issue
Block a user