mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
fix(YouTube Music/Disable auto captions): captions cannot be changed when Disable forced auto captions
is turned on
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
package app.revanced.patches.shared.captions
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.captions.fingerprints.StoryboardRendererDecoderRecommendedLevelFingerprint
|
||||
import app.revanced.patches.shared.captions.fingerprints.SubtitleTrackFingerprint
|
||||
import app.revanced.patches.shared.fingerprints.StartVideoInformerFingerprint
|
||||
import app.revanced.patches.shared.integrations.Constants.PATCHES_PATH
|
||||
import app.revanced.util.resultOrThrow
|
||||
|
||||
@Patch(
|
||||
description = "Disable forced auto captions for YouTube or YouTube Music."
|
||||
)
|
||||
object BaseAutoCaptionsPatch : BytecodePatch(
|
||||
setOf(
|
||||
StartVideoInformerFingerprint,
|
||||
StoryboardRendererDecoderRecommendedLevelFingerprint,
|
||||
SubtitleTrackFingerprint,
|
||||
)
|
||||
) {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$PATCHES_PATH/AutoCaptionsPatch;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SubtitleTrackFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
addInstructionsWithLabels(
|
||||
0, """
|
||||
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->disableAutoCaptions()Z
|
||||
move-result v0
|
||||
if-eqz v0, :disabled
|
||||
const/4 v0, 0x1
|
||||
return v0
|
||||
""", ExternalLabel("disabled", getInstruction(0))
|
||||
)
|
||||
}
|
||||
|
||||
mapOf(
|
||||
StartVideoInformerFingerprint to 0,
|
||||
StoryboardRendererDecoderRecommendedLevelFingerprint to 1
|
||||
).forEach { (fingerprint, enabled) ->
|
||||
fingerprint.resultOrThrow().mutableMethod.addInstructions(
|
||||
0, """
|
||||
const/4 v0, 0x$enabled
|
||||
invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->setCaptionsButtonStatus(Z)V
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.shared.captions.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object StoryboardRendererDecoderRecommendedLevelFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
strings = listOf("#-1#")
|
||||
)
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.shared.fingerprints
|
||||
package app.revanced.patches.shared.captions.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.shared.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 StartVideoInformerFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.RETURN_VOID
|
||||
),
|
||||
strings = listOf("pc")
|
||||
)
|
Reference in New Issue
Block a user