mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-06 18:17:01 +01:00
feat(youtube): support version 18.08.37
This commit is contained in:
parent
b0834faa69
commit
4f4ceab2cc
@ -6,6 +6,7 @@ import app.revanced.patcher.annotation.Name
|
|||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.instruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
@ -20,6 +21,7 @@ import app.revanced.patches.youtube.layout.buttons.autoplay.fingerprints.LayoutC
|
|||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction
|
import org.jf.dexlib2.iface.instruction.Instruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||||
import org.jf.dexlib2.iface.reference.MethodReference
|
import org.jf.dexlib2.iface.reference.MethodReference
|
||||||
@ -66,12 +68,15 @@ class HideAutoplayButtonPatch : BytecodePatch(
|
|||||||
|
|
||||||
val jumpInstruction = layoutGenMethodInstructions[insertIndex + branchIndex] as Instruction
|
val jumpInstruction = layoutGenMethodInstructions[insertIndex + branchIndex] as Instruction
|
||||||
|
|
||||||
|
// can be clobbered because this register is overwritten after the injected code
|
||||||
|
val clobberRegister = (instruction(insertIndex) as OneRegisterInstruction).registerA
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
insertIndex,
|
insertIndex,
|
||||||
"""
|
"""
|
||||||
invoke-static {}, Lapp/revanced/integrations/patches/HideAutoplayButtonPatch;->isButtonShown()Z
|
invoke-static {}, Lapp/revanced/integrations/patches/HideAutoplayButtonPatch;->isButtonShown()Z
|
||||||
move-result v11
|
move-result v$clobberRegister
|
||||||
if-eqz v11, :hidden
|
if-eqz v$clobberRegister, :hidden
|
||||||
""", listOf(ExternalLabel("hidden", jumpInstruction))
|
""", listOf(ExternalLabel("hidden", jumpInstruction))
|
||||||
)
|
)
|
||||||
} ?: return LayoutConstructorFingerprint.toErrorResult()
|
} ?: return LayoutConstructorFingerprint.toErrorResult()
|
||||||
|
@ -13,7 +13,8 @@ import app.revanced.patcher.annotation.Package
|
|||||||
"18.04.41",
|
"18.04.41",
|
||||||
"18.05.32",
|
"18.05.32",
|
||||||
"18.05.35",
|
"18.05.35",
|
||||||
"18.05.40"
|
"18.05.40",
|
||||||
|
"18.08.37"
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
)
|
)
|
||||||
|
@ -7,12 +7,9 @@ import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
|||||||
|
|
||||||
object CrowdfundingBoxFingerprint : MethodFingerprint(
|
object CrowdfundingBoxFingerprint : MethodFingerprint(
|
||||||
opcodes = listOf(
|
opcodes = listOf(
|
||||||
Opcode.CONST_4,
|
|
||||||
Opcode.CONST,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.INVOKE_VIRTUAL,
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
Opcode.IPUT_OBJECT,
|
Opcode.IPUT_OBJECT,
|
||||||
Opcode.CONST,
|
|
||||||
),
|
),
|
||||||
customFingerprint = { methodDef ->
|
customFingerprint = { methodDef ->
|
||||||
methodDef.implementation?.instructions?.any { instruction ->
|
methodDef.implementation?.instructions?.any { instruction ->
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package app.revanced.patches.youtube.layout.hide.crowdfundingbox.bytecode.patch
|
package app.revanced.patches.youtube.layout.hide.crowdfundingbox.bytecode.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
@ -15,7 +16,7 @@ import app.revanced.patches.youtube.layout.hide.crowdfundingbox.annotations.Crow
|
|||||||
import app.revanced.patches.youtube.layout.hide.crowdfundingbox.bytecode.fingerprints.CrowdfundingBoxFingerprint
|
import app.revanced.patches.youtube.layout.hide.crowdfundingbox.bytecode.fingerprints.CrowdfundingBoxFingerprint
|
||||||
import app.revanced.patches.youtube.layout.hide.crowdfundingbox.resource.patch.CrowdfundingBoxResourcePatch
|
import app.revanced.patches.youtube.layout.hide.crowdfundingbox.resource.patch.CrowdfundingBoxResourcePatch
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@DependsOn([IntegrationsPatch::class, CrowdfundingBoxResourcePatch::class])
|
@DependsOn([IntegrationsPatch::class, CrowdfundingBoxResourcePatch::class])
|
||||||
@ -29,18 +30,20 @@ class CrowdfundingBoxPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
val crowdfundingBoxResult = CrowdfundingBoxFingerprint.result!!
|
CrowdfundingBoxFingerprint.result?.let {
|
||||||
val crowdfundingBoxMethod = crowdfundingBoxResult.mutableMethod
|
it.mutableMethod.apply {
|
||||||
|
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
|
val objectRegister = (instruction(insertIndex) as TwoRegisterInstruction).registerA
|
||||||
|
|
||||||
val moveResultObjectIndex =
|
addInstruction(insertIndex, "invoke-static {v$objectRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR")
|
||||||
crowdfundingBoxResult.scanResult.patternScanResult!!.endIndex - 2
|
}
|
||||||
|
} ?: return CrowdfundingBoxFingerprint.toErrorResult()
|
||||||
crowdfundingBoxMethod.addInstruction(
|
|
||||||
moveResultObjectIndex + 1, """
|
|
||||||
invoke-static {v${(crowdfundingBoxMethod.instruction(moveResultObjectIndex) as OneRegisterInstruction).registerA}}, Lapp/revanced/integrations/patches/HideCrowdfundingBoxPatch;->hideCrowdfundingBox(Landroid/view/View;)V
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val INTEGRATIONS_METHOD_DESCRIPTOR =
|
||||||
|
"Lapp/revanced/integrations/patches/HideCrowdfundingBoxPatch;->hideCrowdfundingBox(Landroid/view/View;)V"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,19 +3,6 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.annotations
|
|||||||
import app.revanced.patcher.annotation.Compatibility
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
||||||
|
|
||||||
@Compatibility(
|
@Compatibility([Package("com.google.android.youtube", arrayOf("18.08.37"))])
|
||||||
[Package(
|
|
||||||
"com.google.android.youtube", arrayOf(
|
|
||||||
"17.49.37",
|
|
||||||
"18.03.36",
|
|
||||||
"18.03.42",
|
|
||||||
"18.04.35",
|
|
||||||
"18.04.41",
|
|
||||||
"18.05.32",
|
|
||||||
"18.05.35",
|
|
||||||
"18.05.40"
|
|
||||||
)
|
|
||||||
)]
|
|
||||||
)
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
internal annotation class ReturnYouTubeDislikeCompatibility
|
internal annotation class ReturnYouTubeDislikeCompatibility
|
@ -1,11 +1,8 @@
|
|||||||
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
|
|
||||||
object DislikeFingerprint : MethodFingerprint(
|
object DislikeFingerprint : MethodFingerprint(
|
||||||
"V",
|
"V",
|
||||||
AccessFlags.PROTECTED or AccessFlags.CONSTRUCTOR,
|
|
||||||
strings = listOf("like/dislike")
|
strings = listOf("like/dislike")
|
||||||
)
|
)
|
@ -1,14 +1,11 @@
|
|||||||
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
|
|
||||||
|
|
||||||
@FuzzyPatternScanMethod(2)
|
@FuzzyPatternScanMethod(2)
|
||||||
object LikeFingerprint : MethodFingerprint(
|
object LikeFingerprint : MethodFingerprint(
|
||||||
"V",
|
"V",
|
||||||
AccessFlags.PROTECTED or AccessFlags.CONSTRUCTOR,
|
|
||||||
strings = listOf("like/like")
|
strings = listOf("like/like")
|
||||||
)
|
)
|
@ -1,11 +1,8 @@
|
|||||||
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
|
|
||||||
object RemoveLikeFingerprint : MethodFingerprint(
|
object RemoveLikeFingerprint : MethodFingerprint(
|
||||||
"V",
|
"V",
|
||||||
AccessFlags.PROTECTED or AccessFlags.CONSTRUCTOR,
|
|
||||||
strings = listOf("like/removelike")
|
strings = listOf("like/removelike")
|
||||||
)
|
)
|
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
||||||
|
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
object TextComponentConstructorFingerprint : MethodFingerprint(
|
||||||
|
access = AccessFlags.CONSTRUCTOR or AccessFlags.PRIVATE,
|
||||||
|
strings = listOf("TextComponent")
|
||||||
|
)
|
@ -1,8 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
|
||||||
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
|
|
||||||
object TextComponentFingerprint : MethodFingerprint(
|
|
||||||
strings = listOf("com.google.android.apps.youtube.music")
|
|
||||||
)
|
|
@ -1,8 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
|
||||||
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
|
|
||||||
object TextComponentSpecParentFingerprint : MethodFingerprint(
|
|
||||||
strings = listOf("TextComponentSpec: No converter for extension: ")
|
|
||||||
)
|
|
@ -0,0 +1,14 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
||||||
|
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object TextReferenceFingerprint : MethodFingerprint(
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_STATIC_RANGE,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.INVOKE_DIRECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL
|
||||||
|
)
|
||||||
|
)
|
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object TextReferenceParamFingerprint : MethodFingerprint(
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.MOVE_OBJECT,
|
||||||
|
Opcode.MOVE_OBJECT_FROM16 // the first occurrence of this instruction uses the register for the text object
|
||||||
|
)
|
||||||
|
)
|
@ -25,7 +25,9 @@ import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
|||||||
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
||||||
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
||||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
||||||
|
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@DependsOn(
|
@DependsOn(
|
||||||
@ -42,7 +44,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class ReturnYouTubeDislikePatch : BytecodePatch(
|
class ReturnYouTubeDislikePatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
TextComponentSpecParentFingerprint,
|
TextComponentConstructorFingerprint,
|
||||||
ShortsTextComponentParentFingerprint,
|
ShortsTextComponentParentFingerprint,
|
||||||
LikeFingerprint,
|
LikeFingerprint,
|
||||||
DislikeFingerprint,
|
DislikeFingerprint,
|
||||||
@ -78,27 +80,37 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
|
|||||||
|
|
||||||
// region Hook components
|
// region Hook components
|
||||||
|
|
||||||
TextComponentFingerprint.also { it.resolve(context, TextComponentSpecParentFingerprint.result!!.classDef) }
|
TextReferenceFingerprint.also {
|
||||||
.result?.let {
|
it.resolve(
|
||||||
with(it.mutableMethod) {
|
context,
|
||||||
val createComponentMethod = this
|
TextComponentConstructorFingerprint.result!!.classDef
|
||||||
|
)
|
||||||
|
}.result?.let { result ->
|
||||||
|
val moveTextRefParamInstructionIndex = TextReferenceParamFingerprint.also {
|
||||||
|
if (!TextReferenceParamFingerprint.resolve(context, result.method, result.classDef))
|
||||||
|
return TextReferenceParamFingerprint.toErrorResult()
|
||||||
|
}.result!!.scanResult.patternScanResult!!.endIndex
|
||||||
|
|
||||||
val conversionContextParam = 5
|
result.mutableMethod.apply {
|
||||||
val textRefParam = createComponentMethod.parameters.size - 2
|
val insertIndex = result.scanResult.patternScanResult!!.endIndex
|
||||||
// Insert index must be 0, otherwise UI does not updated correctly in some situations
|
|
||||||
// such as switching from full screen or when using previous/next overlay buttons.
|
|
||||||
val insertIndex = 0
|
|
||||||
|
|
||||||
createComponentMethod.addInstructions(
|
val atomicReferenceInstruction = (instruction(insertIndex - 1) as FiveRegisterInstruction)
|
||||||
insertIndex,
|
val conversionContextParam = atomicReferenceInstruction.registerC
|
||||||
"""
|
val textRefParam = (instruction(moveTextRefParamInstructionIndex) as TwoRegisterInstruction).registerA
|
||||||
move-object/from16 v7, p$conversionContextParam
|
|
||||||
move-object/from16 v8, p$textRefParam
|
// Overwritten after injected code, which is why it can be used.
|
||||||
invoke-static {v7, v8}, $INTEGRATIONS_PATCH_CLASS_DESCRIPTOR->onComponentCreated(Ljava/lang/Object;Ljava/util/concurrent/atomic/AtomicReference;)V
|
val clobberRegister = atomicReferenceInstruction.registerD
|
||||||
"""
|
|
||||||
)
|
addInstructions(
|
||||||
}
|
insertIndex,
|
||||||
} ?: return TextComponentFingerprint.toErrorResult()
|
"""
|
||||||
|
# required instruction, otherwise register might be out of range
|
||||||
|
move-object/from16 v$clobberRegister, v$textRefParam
|
||||||
|
invoke-static {v$clobberRegister, v$conversionContextParam}, $ON_COMPONENT_CREATED_DESCRIPTOR
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: return TextReferenceFingerprint.toErrorResult()
|
||||||
|
|
||||||
ShortsTextComponentParentFingerprint.result?.let {
|
ShortsTextComponentParentFingerprint.result?.let {
|
||||||
context
|
context
|
||||||
@ -138,6 +150,9 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
|
|||||||
const val INTEGRATIONS_PATCH_CLASS_DESCRIPTOR =
|
const val INTEGRATIONS_PATCH_CLASS_DESCRIPTOR =
|
||||||
"Lapp/revanced/integrations/patches/ReturnYouTubeDislikePatch;"
|
"Lapp/revanced/integrations/patches/ReturnYouTubeDislikePatch;"
|
||||||
|
|
||||||
|
const val ON_COMPONENT_CREATED_DESCRIPTOR =
|
||||||
|
"$INTEGRATIONS_PATCH_CLASS_DESCRIPTOR->onComponentCreated(Ljava/lang/Object;Ljava/util/concurrent/atomic/AtomicReference;)V"
|
||||||
|
|
||||||
private fun MethodFingerprint.toPatch(voteKind: Vote) = VotePatch(this, voteKind)
|
private fun MethodFingerprint.toPatch(voteKind: Vote) = VotePatch(this, voteKind)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,6 @@ class SpoofAppVersionPatch : BytecodePatch(
|
|||||||
SpoofAppVersionFingerprint
|
SpoofAppVersionFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
companion object {
|
|
||||||
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/SpoofAppVersionPatch"
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||||
SwitchPreference(
|
SwitchPreference(
|
||||||
@ -61,4 +57,8 @@ class SpoofAppVersionPatch : BytecodePatch(
|
|||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/SpoofAppVersionPatch"
|
||||||
|
}
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ import org.jf.dexlib2.AccessFlags
|
|||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
|
||||||
@FuzzyPatternScanMethod(2) // TODO: Find a good threshold value
|
@FuzzyPatternScanMethod(2)
|
||||||
object MiniPlayerDimensionsCalculatorFingerprint : MethodFingerprint(
|
object MiniPlayerDimensionsCalculatorFingerprint : MethodFingerprint(
|
||||||
"V",
|
"V",
|
||||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
|
||||||
|
object MiniPlayerOverrideParentFingerprint : MethodFingerprint(
|
||||||
|
returnType = "L",
|
||||||
|
access = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||||
|
parameters = listOf("L"),
|
||||||
|
strings = listOf("VIDEO_QUALITIES_QUICK_MENU_BOTTOM_SHEET_FRAGMENT")
|
||||||
|
)
|
@ -1,5 +1,6 @@
|
|||||||
package app.revanced.patches.youtube.layout.tabletminiplayer.patch
|
package app.revanced.patches.youtube.layout.tabletminiplayer.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
@ -16,10 +17,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
|||||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||||
import app.revanced.patches.youtube.layout.tabletminiplayer.annotations.TabletMiniPlayerCompatibility
|
import app.revanced.patches.youtube.layout.tabletminiplayer.annotations.TabletMiniPlayerCompatibility
|
||||||
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerDimensionsCalculatorFingerprint
|
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.*
|
||||||
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerOverrideFingerprint
|
|
||||||
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerOverrideNoContextFingerprint
|
|
||||||
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerResponseModelSizeCheckFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
@ -33,7 +31,8 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
class TabletMiniPlayerPatch : BytecodePatch(
|
class TabletMiniPlayerPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
MiniPlayerDimensionsCalculatorFingerprint,
|
MiniPlayerDimensionsCalculatorFingerprint,
|
||||||
MiniPlayerResponseModelSizeCheckFingerprint
|
MiniPlayerResponseModelSizeCheckFingerprint,
|
||||||
|
MiniPlayerOverrideParentFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
@ -47,33 +46,42 @@ class TabletMiniPlayerPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// first resolve the fingerprints via the parent fingerprint
|
// First resolve the fingerprints via the parent fingerprint.
|
||||||
val miniPlayerClass = MiniPlayerDimensionsCalculatorFingerprint.result!!.classDef
|
val miniPlayerClass = MiniPlayerDimensionsCalculatorFingerprint.result!!.classDef
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* no context parameter method
|
* No context parameter method.
|
||||||
*/
|
*/
|
||||||
MiniPlayerOverrideNoContextFingerprint.resolve(context, miniPlayerClass)
|
MiniPlayerOverrideNoContextFingerprint.resolve(context, miniPlayerClass)
|
||||||
val (method, _, parameterRegister) = MiniPlayerOverrideNoContextFingerprint.addProxyCall()
|
val (method, _, parameterRegister) = MiniPlayerOverrideNoContextFingerprint.addProxyCall()
|
||||||
// - 1 means to insert before the return instruction
|
|
||||||
|
// Insert right before the return instruction.
|
||||||
val secondInsertIndex = method.implementation!!.instructions.size - 1
|
val secondInsertIndex = method.implementation!!.instructions.size - 1
|
||||||
method.insertOverride(secondInsertIndex, parameterRegister /** same register used to return **/)
|
method.insertOverride(
|
||||||
|
secondInsertIndex, parameterRegister
|
||||||
|
/** same register used to return **/
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* method with context parameter
|
* Method with context parameter.
|
||||||
*/
|
*/
|
||||||
MiniPlayerOverrideFingerprint.resolve(context, miniPlayerClass)
|
MiniPlayerOverrideParentFingerprint.result?.let {
|
||||||
val (_, _, _) = MiniPlayerOverrideFingerprint.addProxyCall()
|
if (!MiniPlayerOverrideFingerprint.resolve(context, it.classDef))
|
||||||
|
return MiniPlayerOverrideFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
MiniPlayerOverrideFingerprint.addProxyCall()
|
||||||
|
|
||||||
|
} ?: return MiniPlayerOverrideParentFingerprint.toErrorResult()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* size check return value override
|
* Size check return value override.
|
||||||
*/
|
*/
|
||||||
val (_, _, _) = MiniPlayerResponseModelSizeCheckFingerprint.addProxyCall()
|
MiniPlayerResponseModelSizeCheckFingerprint.addProxyCall()
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper methods
|
// Helper methods.
|
||||||
private companion object {
|
private companion object {
|
||||||
fun MethodFingerprint.addProxyCall(): Triple<MutableMethod, Int, Int> {
|
fun MethodFingerprint.addProxyCall(): Triple<MutableMethod, Int, Int> {
|
||||||
val (method, scanIndex, parameterRegister) = this.unwrap()
|
val (method, scanIndex, parameterRegister) = this.unwrap()
|
||||||
|
@ -13,7 +13,8 @@ import app.revanced.patcher.annotation.Package
|
|||||||
"18.04.41",
|
"18.04.41",
|
||||||
"18.05.32",
|
"18.05.32",
|
||||||
"18.05.35",
|
"18.05.35",
|
||||||
"18.05.40"
|
"18.05.40",
|
||||||
|
"18.08.37"
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
)
|
)
|
||||||
|
@ -107,7 +107,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
|
|||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
private companion object {
|
||||||
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/SpoofSignatureVerificationPatch;"
|
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/SpoofSignatureVerificationPatch;"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ import app.revanced.patcher.annotation.Package
|
|||||||
"18.04.41",
|
"18.04.41",
|
||||||
"18.05.32",
|
"18.05.32",
|
||||||
"18.05.35",
|
"18.05.35",
|
||||||
"18.05.40"
|
"18.05.40",
|
||||||
|
"18.08.37"
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
)
|
)
|
||||||
|
@ -3,5 +3,5 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints
|
|||||||
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
|
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint
|
||||||
|
|
||||||
object InitFingerprint : IntegrationsFingerprint(
|
object InitFingerprint : IntegrationsFingerprint(
|
||||||
strings = listOf("Application creation"),
|
strings = listOf("Application creation", "Application.onCreate"),
|
||||||
)
|
)
|
@ -5,13 +5,6 @@ import org.jf.dexlib2.Opcode
|
|||||||
|
|
||||||
object ComponentContextParserFingerprint : MethodFingerprint(
|
object ComponentContextParserFingerprint : MethodFingerprint(
|
||||||
opcodes = listOf(
|
opcodes = listOf(
|
||||||
Opcode.INVOKE_INTERFACE,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.CHECK_CAST,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.GOTO,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.CONST_16,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.INVOKE_VIRTUAL,
|
||||||
Opcode.IPUT_OBJECT,
|
Opcode.IPUT_OBJECT,
|
||||||
Opcode.NEW_INSTANCE
|
Opcode.NEW_INSTANCE
|
||||||
|
@ -5,6 +5,7 @@ import org.jf.dexlib2.Opcode
|
|||||||
|
|
||||||
object EmptyComponentBuilderFingerprint : MethodFingerprint(
|
object EmptyComponentBuilderFingerprint : MethodFingerprint(
|
||||||
opcodes = listOf(
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_INTERFACE,
|
||||||
Opcode.INVOKE_STATIC_RANGE
|
Opcode.INVOKE_STATIC_RANGE
|
||||||
),
|
),
|
||||||
)
|
)
|
@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.patches.youtube.misc.litho.filter.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object ReadComponentIdentifierFingerprint : MethodFingerprint(
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.IF_NEZ,
|
||||||
|
null,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT // Register stores the component identifier string
|
||||||
|
)
|
||||||
|
)
|
@ -1,10 +1,12 @@
|
|||||||
package app.revanced.patches.youtube.misc.litho.filter.patch
|
package app.revanced.patches.youtube.misc.litho.filter.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.instruction
|
import app.revanced.patcher.extensions.instruction
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
@ -16,12 +18,10 @@ import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
|||||||
import app.revanced.patches.youtube.misc.litho.filter.annotation.LithoFilterCompatibility
|
import app.revanced.patches.youtube.misc.litho.filter.annotation.LithoFilterCompatibility
|
||||||
import app.revanced.patches.youtube.misc.litho.filter.fingerprints.ComponentContextParserFingerprint
|
import app.revanced.patches.youtube.misc.litho.filter.fingerprints.ComponentContextParserFingerprint
|
||||||
import app.revanced.patches.youtube.misc.litho.filter.fingerprints.EmptyComponentBuilderFingerprint
|
import app.revanced.patches.youtube.misc.litho.filter.fingerprints.EmptyComponentBuilderFingerprint
|
||||||
|
import app.revanced.patches.youtube.misc.litho.filter.fingerprints.ReadComponentIdentifierFingerprint
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction
|
import org.jf.dexlib2.iface.instruction.Instruction
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference
|
|
||||||
import org.jf.dexlib2.iface.reference.MethodReference
|
|
||||||
|
|
||||||
@DependsOn([IntegrationsPatch::class])
|
@DependsOn([IntegrationsPatch::class])
|
||||||
@Description("Hooks the method which parses the bytes into a ComponentContext to filter components.")
|
@Description("Hooks the method which parses the bytes into a ComponentContext to filter components.")
|
||||||
@ -31,33 +31,40 @@ class LithoFilterPatch : BytecodePatch(
|
|||||||
listOf(ComponentContextParserFingerprint)
|
listOf(ComponentContextParserFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
ComponentContextParserFingerprint.result?.let { result ->
|
ComponentContextParserFingerprint.result?.also {
|
||||||
val builderMethodIndex = EmptyComponentBuilderFingerprint
|
arrayOf(EmptyComponentBuilderFingerprint, ReadComponentIdentifierFingerprint).forEach { fingerprint ->
|
||||||
.also { it.resolve(context, result.mutableMethod, result.mutableClass) }
|
if (!fingerprint.resolve(context, it.mutableMethod, it.mutableClass))
|
||||||
.let { it.result!!.scanResult.patternScanResult!!.startIndex }
|
return fingerprint.toErrorResult()
|
||||||
|
}
|
||||||
|
}?.let { result ->
|
||||||
|
val builderMethodIndex = EmptyComponentBuilderFingerprint.patternScanEndIndex
|
||||||
val emptyComponentFieldIndex = builderMethodIndex + 2
|
val emptyComponentFieldIndex = builderMethodIndex + 2
|
||||||
|
|
||||||
with(result.mutableMethod) {
|
result.mutableMethod.apply {
|
||||||
val insertHookIndex = result.scanResult.patternScanResult!!.endIndex
|
val insertHookIndex = result.scanResult.patternScanResult!!.endIndex
|
||||||
val clobberedRegister = (instruction(insertHookIndex - 3) as OneRegisterInstruction).registerA
|
val builderMethodDescriptor = instruction(builderMethodIndex).descriptor
|
||||||
|
val emptyComponentFieldDescriptor = instruction(emptyComponentFieldIndex).descriptor
|
||||||
|
// Register is overwritten right after it is used for this patch, therefore free to clobber.
|
||||||
|
val clobberedRegister = instruction(insertHookIndex).oneRegister
|
||||||
|
|
||||||
val builderMethodDescriptor = instruction(builderMethodIndex).toDescriptor()
|
@Suppress("UnnecessaryVariable")
|
||||||
val emptyComponentFieldDescriptor = instruction(emptyComponentFieldIndex).toDescriptor()
|
// The register, this patch clobbers, is previously used for the StringBuilder,
|
||||||
|
// later on a new StringBuilder is instantiated on it.
|
||||||
|
val stringBuilderRegister = clobberedRegister
|
||||||
|
|
||||||
val stringBuilderRegister = (instruction(insertHookIndex - 1) as TwoRegisterInstruction).registerA
|
val identifierRegister = instruction(ReadComponentIdentifierFingerprint.patternScanEndIndex).oneRegister
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
insertHookIndex, // right after setting the component.pathBuilder field,
|
insertHookIndex, // right after setting the component.pathBuilder field,
|
||||||
"""
|
"""
|
||||||
invoke-static {v$stringBuilderRegister, v0}, Lapp/revanced/integrations/patches/LithoFilterPatch;->filter(Ljava/lang/StringBuilder;Ljava/lang/String;)Z
|
invoke-static {v$stringBuilderRegister, v$identifierRegister}, Lapp/revanced/integrations/patches/LithoFilterPatch;->filter(Ljava/lang/StringBuilder;Ljava/lang/String;)Z
|
||||||
move-result v$clobberedRegister
|
move-result v$clobberedRegister
|
||||||
if-eqz v$clobberedRegister, :not_an_ad
|
if-eqz v$clobberedRegister, :not_an_ad
|
||||||
move-object/from16 v0, p1
|
move-object/from16 v$clobberedRegister, p1
|
||||||
invoke-static {v0}, $builderMethodDescriptor
|
invoke-static {v$clobberedRegister}, $builderMethodDescriptor
|
||||||
move-result-object v0
|
move-result-object v$clobberedRegister
|
||||||
iget-object v0, v0, $emptyComponentFieldDescriptor
|
iget-object v$clobberedRegister, v$clobberedRegister, $emptyComponentFieldDescriptor
|
||||||
return-object v0
|
return-object v$clobberedRegister
|
||||||
""",
|
""",
|
||||||
listOf(ExternalLabel("not_an_ad", instruction(insertHookIndex)))
|
listOf(ExternalLabel("not_an_ad", instruction(insertHookIndex)))
|
||||||
)
|
)
|
||||||
@ -68,14 +75,14 @@ class LithoFilterPatch : BytecodePatch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
fun Instruction.toDescriptor() = when (val reference = (this as? ReferenceInstruction)?.reference) {
|
val MethodFingerprint.patternScanEndIndex
|
||||||
is MethodReference -> "${reference.definingClass}->${reference.name}(${
|
get() = result!!.scanResult.patternScanResult!!.endIndex
|
||||||
reference.parameterTypes.joinToString(
|
|
||||||
""
|
val Instruction.descriptor
|
||||||
) { it }
|
get() = (this as ReferenceInstruction).reference.toString()
|
||||||
})${reference.returnType}"
|
|
||||||
is FieldReference -> "${reference.definingClass}->${reference.name}:${reference.type}"
|
val Instruction.oneRegister
|
||||||
else -> throw PatchResultError("Unsupported reference type")
|
get() = (this as OneRegisterInstruction).registerA
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.misc.microg.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
|
|
||||||
object IntegrityCheckFingerprint : MethodFingerprint(
|
|
||||||
"L", AccessFlags.PUBLIC or AccessFlags.STATIC, listOf("L", "L"),
|
|
||||||
strings = listOf("This should never happen.", "GooglePlayServicesUtil", "Google Play Store signature invalid.")
|
|
||||||
)
|
|
@ -10,8 +10,8 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
|||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint
|
import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint
|
||||||
import app.revanced.patches.youtube.layout.buttons.cast.patch.HideCastButtonPatch
|
|
||||||
import app.revanced.patches.shared.misc.fix.spoof.patch.ClientSpoofPatch
|
import app.revanced.patches.shared.misc.fix.spoof.patch.ClientSpoofPatch
|
||||||
|
import app.revanced.patches.youtube.layout.buttons.cast.patch.HideCastButtonPatch
|
||||||
import app.revanced.patches.youtube.misc.fix.playback.patch.SpoofSignatureVerificationPatch
|
import app.revanced.patches.youtube.misc.fix.playback.patch.SpoofSignatureVerificationPatch
|
||||||
import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility
|
import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility
|
||||||
import app.revanced.patches.youtube.misc.microg.fingerprints.*
|
import app.revanced.patches.youtube.misc.microg.fingerprints.*
|
||||||
@ -34,7 +34,6 @@ import app.revanced.util.microg.MicroGBytecodeHelper
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class MicroGBytecodePatch : BytecodePatch(
|
class MicroGBytecodePatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
IntegrityCheckFingerprint,
|
|
||||||
ServiceCheckFingerprint,
|
ServiceCheckFingerprint,
|
||||||
GooglePlayUtilityFingerprint,
|
GooglePlayUtilityFingerprint,
|
||||||
CastDynamiteModuleFingerprint,
|
CastDynamiteModuleFingerprint,
|
||||||
@ -59,7 +58,6 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||||||
REVANCED_PACKAGE_NAME
|
REVANCED_PACKAGE_NAME
|
||||||
),
|
),
|
||||||
listOf(
|
listOf(
|
||||||
IntegrityCheckFingerprint,
|
|
||||||
ServiceCheckFingerprint,
|
ServiceCheckFingerprint,
|
||||||
GooglePlayUtilityFingerprint,
|
GooglePlayUtilityFingerprint,
|
||||||
CastDynamiteModuleFingerprint,
|
CastDynamiteModuleFingerprint,
|
||||||
|
@ -10,16 +10,16 @@ object ThemeSetterAppFingerprint : MethodFingerprint(
|
|||||||
AccessFlags.PUBLIC or AccessFlags.STATIC,
|
AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||||
parameters = listOf("L", "L", "L", "L"),
|
parameters = listOf("L", "L", "L", "L"),
|
||||||
opcodes = listOf(
|
opcodes = listOf(
|
||||||
Opcode.CONST, //target reference
|
Opcode.CONST, // target reference
|
||||||
Opcode.GOTO,
|
Opcode.GOTO,
|
||||||
Opcode.CONST, //target reference
|
Opcode.CONST, // target reference
|
||||||
Opcode.INVOKE_DIRECT,
|
Opcode.INVOKE_DIRECT,
|
||||||
Opcode.RETURN_OBJECT,
|
Opcode.RETURN_OBJECT,
|
||||||
Opcode.NEW_INSTANCE,
|
Opcode.NEW_INSTANCE,
|
||||||
Opcode.INVOKE_INTERFACE,
|
null, // changed from invoke interface to invoke virtual
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
Opcode.SGET_OBJECT,
|
Opcode.SGET_OBJECT,
|
||||||
Opcode.IF_NE,
|
Opcode.IF_NE,
|
||||||
Opcode.CONST, //target reference
|
Opcode.CONST, // target reference
|
||||||
)
|
)
|
||||||
)
|
)
|
@ -0,0 +1,14 @@
|
|||||||
|
package app.revanced.patches.youtube.misc.video.quality.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object SetQualityByIndexMethodClassFieldReferenceFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
parameters = listOf("L"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.INVOKE_INTERFACE,
|
||||||
|
Opcode.RETURN_VOID
|
||||||
|
)
|
||||||
|
)
|
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
package app.revanced.patches.youtube.misc.video.quality.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object VideoQualityItemOnClickParentFingerprint : MethodFingerprint(
|
||||||
|
"V",
|
||||||
|
strings = listOf("VIDEO_QUALITIES_MENU_BOTTOM_SHEET_FRAGMENT")
|
||||||
|
)
|
@ -1,12 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.misc.video.quality.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
|
|
||||||
object VideoQualityReferenceFingerprint : MethodFingerprint(
|
|
||||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), listOf(
|
|
||||||
Opcode.IPUT_OBJECT, Opcode.RETURN_VOID
|
|
||||||
)
|
|
||||||
)
|
|
@ -9,12 +9,13 @@ import org.jf.dexlib2.Opcode
|
|||||||
object VideoQualitySetterFingerprint : MethodFingerprint(
|
object VideoQualitySetterFingerprint : MethodFingerprint(
|
||||||
"V",
|
"V",
|
||||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
listOf("[L", "I", "I", "Z", "I"),
|
listOf("[L", "I", "Z"),
|
||||||
listOf(
|
listOf(
|
||||||
Opcode.IF_EQZ,
|
Opcode.IF_EQZ,
|
||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.INVOKE_VIRTUAL,
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.INVOKE_VIRTUAL,
|
||||||
Opcode.IPUT_BOOLEAN,
|
Opcode.IPUT_BOOLEAN,
|
||||||
)
|
),
|
||||||
|
strings = listOf("menu_item_video_quality"),
|
||||||
)
|
)
|
@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
package app.revanced.patches.youtube.misc.video.quality.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
|
|
||||||
object VideoUserQualityChangeFingerprint : MethodFingerprint(
|
|
||||||
"V",
|
|
||||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
listOf("L","L","I","J"),
|
|
||||||
listOf(
|
|
||||||
Opcode.MOVE,
|
|
||||||
Opcode.MOVE_WIDE,
|
|
||||||
Opcode.INVOKE_INTERFACE_RANGE,
|
|
||||||
Opcode.RETURN_VOID
|
|
||||||
)
|
|
||||||
)
|
|
@ -1,5 +1,6 @@
|
|||||||
package app.revanced.patches.youtube.misc.video.quality.patch
|
package app.revanced.patches.youtube.misc.video.quality.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
@ -9,6 +10,7 @@ import app.revanced.patcher.extensions.addInstructions
|
|||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultError
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
@ -17,9 +19,9 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
|||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
import app.revanced.patches.youtube.misc.video.quality.annotations.RememberVideoQualityCompatibility
|
import app.revanced.patches.youtube.misc.video.quality.annotations.RememberVideoQualityCompatibility
|
||||||
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoQualityReferenceFingerprint
|
import app.revanced.patches.youtube.misc.video.quality.fingerprints.SetQualityByIndexMethodClassFieldReferenceFingerprint
|
||||||
|
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoQualityItemOnClickParentFingerprint
|
||||||
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoQualitySetterFingerprint
|
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoQualitySetterFingerprint
|
||||||
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoUserQualityChangeFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference
|
import org.jf.dexlib2.iface.reference.FieldReference
|
||||||
@ -32,14 +34,18 @@ import org.jf.dexlib2.iface.reference.FieldReference
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class RememberVideoQualityPatch : BytecodePatch(
|
class RememberVideoQualityPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
VideoQualitySetterFingerprint
|
VideoQualitySetterFingerprint,
|
||||||
|
VideoQualityItemOnClickParentFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||||
SwitchPreference(
|
SwitchPreference(
|
||||||
"revanced_remember_video_quality_last_selected",
|
"revanced_remember_video_quality_last_selected",
|
||||||
StringResource("revanced_remember_video_quality_last_selected_title", "Remember video quality changes"),
|
StringResource(
|
||||||
|
"revanced_remember_video_quality_last_selected_title",
|
||||||
|
"Remember video quality changes"
|
||||||
|
),
|
||||||
true,
|
true,
|
||||||
StringResource(
|
StringResource(
|
||||||
"revanced_remember_video_quality_last_selected_summary_on",
|
"revanced_remember_video_quality_last_selected_summary_on",
|
||||||
@ -52,37 +58,80 @@ class RememberVideoQualityPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val setterMethod = VideoQualitySetterFingerprint.result!!
|
/*
|
||||||
|
* The following code works by hooking the method which is called when the user selects a video quality
|
||||||
|
* to remember the last selected video quality.
|
||||||
|
*
|
||||||
|
* It also hooks the method which is called when the video quality to set is determined.
|
||||||
|
* Conveniently, at this point the video quality is overridden to the remembered playback speed.
|
||||||
|
*/
|
||||||
|
|
||||||
VideoUserQualityChangeFingerprint.resolve(context, setterMethod.classDef)
|
VideoIdPatch.injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")
|
||||||
val userQualityMethod = VideoUserQualityChangeFingerprint.result!!
|
|
||||||
|
|
||||||
VideoQualityReferenceFingerprint.resolve(context, setterMethod.classDef)
|
// Inject a call to set the remembered quality once a video loads.
|
||||||
val qualityFieldReference =
|
VideoQualitySetterFingerprint.result?.also {
|
||||||
VideoQualityReferenceFingerprint.result!!.method.let { method ->
|
if (!SetQualityByIndexMethodClassFieldReferenceFingerprint.resolve(context, it.classDef))
|
||||||
(method.implementation!!.instructions.elementAt(0) as ReferenceInstruction).reference as FieldReference
|
return PatchResultError("Could not resolve fingerprint to find setQualityByIndex method")
|
||||||
}
|
}?.let {
|
||||||
|
// This instruction refers to the field with the type that contains the setQualityByIndex method.
|
||||||
|
val instructions = SetQualityByIndexMethodClassFieldReferenceFingerprint.result!!
|
||||||
|
.method.implementation!!.instructions
|
||||||
|
|
||||||
VideoIdPatch.injectCall("Lapp/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch;->newVideoStarted(Ljava/lang/String;)V")
|
val getOnItemClickListenerClassReference =
|
||||||
|
(instructions.elementAt(0) as ReferenceInstruction).reference
|
||||||
|
val getSetQualityByIndexMethodClassFieldReference =
|
||||||
|
(instructions.elementAt(1) as ReferenceInstruction).reference
|
||||||
|
|
||||||
val qIndexMethodName =
|
val setQualityByIndexMethodClassFieldReference =
|
||||||
context.classes.single { it.type == qualityFieldReference.type }.methods.single { it.parameterTypes.first() == "I" }.name
|
getSetQualityByIndexMethodClassFieldReference as FieldReference
|
||||||
|
|
||||||
setterMethod.mutableMethod.addInstructions(
|
val setQualityByIndexMethodClass = context.classes
|
||||||
0,
|
.find { classDef -> classDef.type == setQualityByIndexMethodClassFieldReference.type }!!
|
||||||
"""
|
|
||||||
iget-object v0, p0, ${setterMethod.classDef.type}->${qualityFieldReference.name}:${qualityFieldReference.type}
|
|
||||||
const-string v1, "$qIndexMethodName"
|
|
||||||
invoke-static {p1, p2, v0, v1}, Lapp/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch;->setVideoQuality([Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/String;)I
|
|
||||||
move-result p2
|
|
||||||
""",
|
|
||||||
)
|
|
||||||
|
|
||||||
userQualityMethod.mutableMethod.addInstruction(
|
// Get the name of the setQualityByIndex method.
|
||||||
0,
|
val setQualityByIndexMethod = setQualityByIndexMethodClass.methods
|
||||||
"invoke-static {p3}, Lapp/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch;->userChangedQuality(I)V"
|
.find { method -> method.parameterTypes.first() == "I" }
|
||||||
)
|
?: return PatchResultError("Could not find setQualityByIndex method")
|
||||||
|
|
||||||
|
it.mutableMethod.addInstructions(
|
||||||
|
0,
|
||||||
|
"""
|
||||||
|
# Get the object instance to invoke the setQualityByIndex method on.
|
||||||
|
iget-object v0, p0, $getOnItemClickListenerClassReference
|
||||||
|
iget-object v0, v0, $getSetQualityByIndexMethodClassFieldReference
|
||||||
|
|
||||||
|
# Get the method name.
|
||||||
|
const-string v1, "${setQualityByIndexMethod.name}"
|
||||||
|
|
||||||
|
# Set the quality.
|
||||||
|
# The first parameter is the array list of video qualities.
|
||||||
|
# The second parameter is the index of the selected quality.
|
||||||
|
# The register v0 stores the object instance to invoke the setQualityByIndex method on.
|
||||||
|
# The register v1 stores the name of the setQualityByIndex method.
|
||||||
|
invoke-static {p1, p2, v0, v1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setVideoQuality([Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/String;)I
|
||||||
|
move-result p2
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
} ?: return VideoQualitySetterFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
// Inject a call to remember the selected quality.
|
||||||
|
VideoQualityItemOnClickParentFingerprint.result?.let {
|
||||||
|
val onItemClickMethod = it.mutableClass.methods.find { method -> method.name == "onItemClick" }
|
||||||
|
|
||||||
|
onItemClickMethod?.apply {
|
||||||
|
val listItemIndexParameter = 3
|
||||||
|
|
||||||
|
addInstruction(
|
||||||
|
0,
|
||||||
|
"invoke-static {p$listItemIndexParameter}, $INTEGRATIONS_CLASS_DESCRIPTOR->userChangedQuality(I)V"
|
||||||
|
)
|
||||||
|
} ?: return PatchResultError("Failed to find onItemClick method")
|
||||||
|
} ?: return VideoQualityItemOnClickParentFingerprint.toErrorResult()
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||||
|
"Lapp/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch;"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.misc.video.speed.remember.fingerprint
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
|
|
||||||
object ChangePlaybackSpeedFragmentStateFingerprint : MethodFingerprint(
|
|
||||||
"V",
|
|
||||||
strings = listOf("PLAYBACK_RATE_MENU_BOTTOM_SHEET_FRAGMENT")
|
|
||||||
)
|
|
@ -3,5 +3,6 @@ package app.revanced.patches.youtube.misc.video.speed.remember.fingerprint
|
|||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
object InitializePlaybackSpeedValuesFingerprint : MethodFingerprint(
|
object InitializePlaybackSpeedValuesFingerprint : MethodFingerprint(
|
||||||
parameters = listOf("[L", "I")
|
parameters = listOf("[L", "I"),
|
||||||
|
strings = listOf("menu_item_playback_speed")
|
||||||
)
|
)
|
@ -6,7 +6,9 @@ import org.jf.dexlib2.Opcode
|
|||||||
object OnPlaybackSpeedItemClickFingerprint : MethodFingerprint(
|
object OnPlaybackSpeedItemClickFingerprint : MethodFingerprint(
|
||||||
customFingerprint = { it.name == "onItemClick" },
|
customFingerprint = { it.name == "onItemClick" },
|
||||||
opcodes = listOf(
|
opcodes = listOf(
|
||||||
Opcode.IGET_OBJECT,
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
Opcode.INVOKE_VIRTUAL
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.RETURN_VOID
|
||||||
)
|
)
|
||||||
)
|
)
|
@ -8,8 +8,6 @@ import app.revanced.patcher.data.BytecodeContext
|
|||||||
import app.revanced.patcher.extensions.addInstruction
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.instruction
|
import app.revanced.patcher.extensions.instruction
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
|
||||||
import app.revanced.patcher.patch.*
|
import app.revanced.patcher.patch.*
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
@ -19,12 +17,12 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
|||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
import app.revanced.patches.youtube.misc.video.speed.remember.annotation.RememberPlaybackSpeedCompatibility
|
import app.revanced.patches.youtube.misc.video.speed.remember.annotation.RememberPlaybackSpeedCompatibility
|
||||||
import app.revanced.patches.youtube.misc.video.speed.remember.fingerprint.ChangePlaybackSpeedFragmentStateFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.video.speed.remember.fingerprint.InitializePlaybackSpeedValuesFingerprint
|
import app.revanced.patches.youtube.misc.video.speed.remember.fingerprint.InitializePlaybackSpeedValuesFingerprint
|
||||||
import app.revanced.patches.youtube.misc.video.speed.remember.fingerprint.OnPlaybackSpeedItemClickFingerprint
|
import app.revanced.patches.youtube.misc.video.speed.remember.fingerprint.OnPlaybackSpeedItemClickFingerprint
|
||||||
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.Instruction
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@ -34,7 +32,10 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
|||||||
@RememberPlaybackSpeedCompatibility
|
@RememberPlaybackSpeedCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class RememberPlaybackSpeedPatch : BytecodePatch(
|
class RememberPlaybackSpeedPatch : BytecodePatch(
|
||||||
listOf(ChangePlaybackSpeedFragmentStateFingerprint)
|
listOf(
|
||||||
|
OnPlaybackSpeedItemClickFingerprint,
|
||||||
|
InitializePlaybackSpeedValuesFingerprint
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||||
@ -56,54 +57,67 @@ class RememberPlaybackSpeedPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
context.resolveFingerprints()
|
|
||||||
|
|
||||||
VideoIdPatch.injectCall("${INTEGRATIONS_CLASS_DESCRIPTOR}->newVideoLoaded(Ljava/lang/String;)V")
|
VideoIdPatch.injectCall("${INTEGRATIONS_CLASS_DESCRIPTOR}->newVideoLoaded(Ljava/lang/String;)V")
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following code works by hooking the method which is called when the user selects a playback speed
|
||||||
|
* to remember the last selected playback speed.
|
||||||
|
*
|
||||||
|
* It also hooks the method which is called when the playback speeds are initialized.
|
||||||
|
* Conveniently, at this point the playback speed is set to the remembered playback speed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Set the remembered playback speed.
|
// Set the remembered playback speed.
|
||||||
InitializePlaybackSpeedValuesFingerprint.result!!.apply {
|
InitializePlaybackSpeedValuesFingerprint.result?.apply {
|
||||||
// Infer everything necessary for setPlaybackSate()
|
// Infer everything necessary for calling the method setPlaybackSpeed().
|
||||||
|
val instructions = OnPlaybackSpeedItemClickFingerprint.result!!.mutableMethod.implementation!!.instructions
|
||||||
|
fun getReference(offset: Int = 0, opcode: Opcode) =
|
||||||
|
instructions[instructions.indexOfFirst { it.opcode == opcode } + offset].reference
|
||||||
|
|
||||||
val playbackHandlerWrapperFieldReference =
|
val setPlaybackSpeedContainerClassFieldReference =
|
||||||
(object : MethodFingerprint(opcodes = listOf(Opcode.IF_EQZ)) {}).apply {
|
getReference(-1, Opcode.IF_EQZ)
|
||||||
OnPlaybackSpeedItemClickFingerprint.result!!.apply {
|
|
||||||
resolve(
|
|
||||||
context,
|
|
||||||
method,
|
|
||||||
classDef
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}.getReference(-1)
|
|
||||||
val playbackHandlerWrapperImplementorClassReference = OnPlaybackSpeedItemClickFingerprint
|
|
||||||
.getReference(-1)
|
|
||||||
val playbackHandlerFieldReference = OnPlaybackSpeedItemClickFingerprint
|
|
||||||
.getReference()
|
|
||||||
val setPlaybackSpeedMethodReference = OnPlaybackSpeedItemClickFingerprint
|
|
||||||
.getReference(1)
|
|
||||||
|
|
||||||
|
val setPlaybackSpeedClassFieldReference =
|
||||||
|
getReference(1, Opcode.IGET)
|
||||||
|
|
||||||
|
val setPlaybackSpeedMethodReference =
|
||||||
|
getReference(2, Opcode.IGET)
|
||||||
|
|
||||||
|
val onItemClickListenerClassFieldReference = mutableMethod.instruction(0).reference
|
||||||
|
|
||||||
|
// Registers are not used at index 0, so they can be freely used.
|
||||||
mutableMethod.addInstructions(
|
mutableMethod.addInstructions(
|
||||||
0,
|
0,
|
||||||
"""
|
"""
|
||||||
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->getCurrentPlaybackSpeed()F
|
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->getCurrentPlaybackSpeed()F
|
||||||
move-result v0
|
move-result v0
|
||||||
# check if the playback speed is not 1.0x
|
|
||||||
|
# Check if the playback speed is not 1.0x.
|
||||||
const/high16 v1, 0x3f800000 # 1.0f
|
const/high16 v1, 0x3f800000 # 1.0f
|
||||||
cmpg-float v1, v0, v1
|
cmpg-float v1, v0, v1
|
||||||
if-eqz v1, :do_not_override
|
if-eqz v1, :do_not_override
|
||||||
|
|
||||||
# invoke setPlaybackSpeed
|
# Get the instance of the class which has the container class field below.
|
||||||
iget-object v1, p0, $playbackHandlerWrapperFieldReference
|
iget-object v1, p0, $onItemClickListenerClassFieldReference
|
||||||
check-cast v1, $playbackHandlerWrapperImplementorClassReference
|
|
||||||
iget-object v2, v1, $playbackHandlerFieldReference
|
# Get the container class field.
|
||||||
|
iget-object v1, v1, $setPlaybackSpeedContainerClassFieldReference
|
||||||
|
|
||||||
|
# Get the field from its class.
|
||||||
|
iget-object v2, v1, $setPlaybackSpeedClassFieldReference
|
||||||
|
|
||||||
|
# Invoke setPlaybackSpeed on that class.
|
||||||
invoke-virtual {v2, v0}, $setPlaybackSpeedMethodReference
|
invoke-virtual {v2, v0}, $setPlaybackSpeedMethodReference
|
||||||
""".trimIndent(),
|
""".trimIndent(),
|
||||||
listOf(ExternalLabel("do_not_override", mutableMethod.instruction(0)))
|
listOf(ExternalLabel("do_not_override", mutableMethod.instruction(0)))
|
||||||
)
|
)
|
||||||
}
|
} ?: return InitializePlaybackSpeedValuesFingerprint.toErrorResult()
|
||||||
|
|
||||||
// Remember the selected playback speed.
|
// Remember the selected playback speed.
|
||||||
OnPlaybackSpeedItemClickFingerprint.result!!.apply {
|
OnPlaybackSpeedItemClickFingerprint.result?.apply {
|
||||||
val setPlaybackSpeedIndex = scanResult.patternScanResult!!.endIndex
|
val setPlaybackSpeedIndex = scanResult.patternScanResult!!.startIndex - 3
|
||||||
|
|
||||||
val selectedPlaybackSpeedRegister =
|
val selectedPlaybackSpeedRegister =
|
||||||
(mutableMethod.instruction(setPlaybackSpeedIndex) as FiveRegisterInstruction).registerD
|
(mutableMethod.instruction(setPlaybackSpeedIndex) as FiveRegisterInstruction).registerD
|
||||||
|
|
||||||
@ -111,8 +125,7 @@ class RememberPlaybackSpeedPatch : BytecodePatch(
|
|||||||
setPlaybackSpeedIndex,
|
setPlaybackSpeedIndex,
|
||||||
"invoke-static { v$selectedPlaybackSpeedRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlaybackSpeed(F)V"
|
"invoke-static { v$selectedPlaybackSpeedRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlaybackSpeed(F)V"
|
||||||
)
|
)
|
||||||
}
|
} ?: return OnPlaybackSpeedItemClickFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
@ -121,20 +134,6 @@ class RememberPlaybackSpeedPatch : BytecodePatch(
|
|||||||
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||||
"Lapp/revanced/integrations/patches/playback/speed/RememberPlaybackSpeedPatch;"
|
"Lapp/revanced/integrations/patches/playback/speed/RememberPlaybackSpeedPatch;"
|
||||||
|
|
||||||
fun MethodFingerprint.getReference(offsetFromPatternScanResultStartIndex: Int = 0) = this.result!!.let {
|
val Instruction.reference get() = (this as ReferenceInstruction).reference.toString()
|
||||||
val referenceInstruction = it.mutableMethod
|
|
||||||
.instruction(it.scanResult.patternScanResult!!.startIndex + offsetFromPatternScanResultStartIndex) as ReferenceInstruction
|
|
||||||
referenceInstruction.reference.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun BytecodeContext.resolveFingerprints() {
|
|
||||||
ChangePlaybackSpeedFragmentStateFingerprint.result?.also {
|
|
||||||
fun MethodFingerprint.resolve() = resolve(this@resolveFingerprints, it.classDef)
|
|
||||||
|
|
||||||
OnPlaybackSpeedItemClickFingerprint.resolve()
|
|
||||||
InitializePlaybackSpeedValuesFingerprint.resolve()
|
|
||||||
|
|
||||||
} ?: throw ChangePlaybackSpeedFragmentStateFingerprint.toErrorResult()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user