mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-17 06:47:15 +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:
parent
5e8d280294
commit
d708f36052
@ -1,39 +1,24 @@
|
|||||||
package app.revanced.patches.music.general.autocaptions
|
package app.revanced.patches.music.general.autocaptions
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|
||||||
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||||
import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
|
|
||||||
import app.revanced.patches.music.utils.settings.CategoryType
|
import app.revanced.patches.music.utils.settings.CategoryType
|
||||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||||
import app.revanced.patches.shared.fingerprints.SubtitleTrackFingerprint
|
import app.revanced.patches.shared.captions.BaseAutoCaptionsPatch
|
||||||
import app.revanced.util.patch.BaseBytecodePatch
|
import app.revanced.util.patch.BaseBytecodePatch
|
||||||
import app.revanced.util.resultOrThrow
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object AutoCaptionsPatch : BaseBytecodePatch(
|
object AutoCaptionsPatch : BaseBytecodePatch(
|
||||||
name = "Disable auto captions",
|
name = "Disable auto captions",
|
||||||
description = "Adds an option to disable captions from being automatically enabled.",
|
description = "Adds an option to disable captions from being automatically enabled.",
|
||||||
dependencies = setOf(SettingsPatch::class),
|
dependencies = setOf(
|
||||||
|
BaseAutoCaptionsPatch::class,
|
||||||
|
SettingsPatch::class
|
||||||
|
),
|
||||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||||
fingerprints = setOf(SubtitleTrackFingerprint),
|
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
SubtitleTrackFingerprint.resultOrThrow().mutableMethod.apply {
|
|
||||||
val index = implementation!!.instructions.lastIndex
|
|
||||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
|
||||||
|
|
||||||
addInstructions(
|
|
||||||
index, """
|
|
||||||
invoke-static {v$register}, $GENERAL_CLASS_DESCRIPTOR->disableAutoCaptions(Z)Z
|
|
||||||
move-result v$register
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsPatch.addSwitchPreference(
|
SettingsPatch.addSwitchPreference(
|
||||||
CategoryType.GENERAL,
|
CategoryType.GENERAL,
|
||||||
"revanced_disable_auto_captions",
|
"revanced_disable_auto_captions",
|
||||||
|
@ -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
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,12 @@
|
|||||||
package app.revanced.patches.youtube.general.autocaptions.fingerprints
|
package app.revanced.patches.shared.captions.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 com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
internal object StoryboardRendererDecoderRecommendedLevelFingerprint : MethodFingerprint(
|
internal object StoryboardRendererDecoderRecommendedLevelFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf(PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR),
|
parameters = listOf("L"),
|
||||||
strings = listOf("#-1#")
|
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.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.utils.fingerprints
|
package app.revanced.patches.shared.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
|
@ -1,57 +1,23 @@
|
|||||||
package app.revanced.patches.youtube.general.autocaptions
|
package app.revanced.patches.youtube.general.autocaptions
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patches.shared.captions.BaseAutoCaptionsPatch
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
|
||||||
import app.revanced.patches.shared.fingerprints.SubtitleTrackFingerprint
|
|
||||||
import app.revanced.patches.youtube.general.autocaptions.fingerprints.StoryboardRendererDecoderRecommendedLevelFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.StartVideoInformerFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
|
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.patch.BaseBytecodePatch
|
import app.revanced.util.patch.BaseBytecodePatch
|
||||||
import app.revanced.util.resultOrThrow
|
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object AutoCaptionsPatch : BaseBytecodePatch(
|
object AutoCaptionsPatch : BaseBytecodePatch(
|
||||||
name = "Disable auto captions",
|
name = "Disable auto captions",
|
||||||
description = "Adds an option to disable captions from being automatically enabled.",
|
description = "Adds an option to disable captions from being automatically enabled.",
|
||||||
dependencies = setOf(SettingsPatch::class),
|
dependencies = setOf(
|
||||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
BaseAutoCaptionsPatch::class,
|
||||||
fingerprints = setOf(
|
SettingsPatch::class
|
||||||
SubtitleTrackFingerprint,
|
),
|
||||||
StartVideoInformerFingerprint,
|
compatiblePackages = COMPATIBLE_PACKAGE
|
||||||
StoryboardRendererDecoderRecommendedLevelFingerprint,
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
SubtitleTrackFingerprint.resultOrThrow().mutableMethod.apply {
|
|
||||||
addInstructionsWithLabels(
|
|
||||||
0, """
|
|
||||||
invoke-static {}, $GENERAL_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}, $GENERAL_CLASS_DESCRIPTOR->setCaptionsButtonStatus(Z)V
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add settings
|
* Add settings
|
||||||
*/
|
*/
|
||||||
|
@ -9,6 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
|||||||
import app.revanced.patcher.patch.PatchException
|
import app.revanced.patcher.patch.PatchException
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
|
import app.revanced.patches.shared.fingerprints.StartVideoInformerFingerprint
|
||||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||||
import app.revanced.patches.youtube.player.components.fingerprints.CrowdfundingBoxFingerprint
|
import app.revanced.patches.youtube.player.components.fingerprints.CrowdfundingBoxFingerprint
|
||||||
import app.revanced.patches.youtube.player.components.fingerprints.EngagementPanelControllerFingerprint
|
import app.revanced.patches.youtube.player.components.fingerprints.EngagementPanelControllerFingerprint
|
||||||
@ -33,7 +34,6 @@ import app.revanced.patches.youtube.player.components.fingerprints.WatermarkPare
|
|||||||
import app.revanced.patches.youtube.player.speedoverlay.SpeedOverlayPatch
|
import app.revanced.patches.youtube.player.speedoverlay.SpeedOverlayPatch
|
||||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||||
import app.revanced.patches.youtube.utils.controlsoverlay.ControlsOverlayConfigPatch
|
import app.revanced.patches.youtube.utils.controlsoverlay.ControlsOverlayConfigPatch
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.StartVideoInformerFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
|
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.SuggestedVideoEndScreenPatch
|
import app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.SuggestedVideoEndScreenPatch
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||||
|
Loading…
x
Reference in New Issue
Block a user