mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-30 06:34:37 +02:00
feat(YouTube Music): Add Disable QUIC protocol
patch https://github.com/inotia00/ReVanced_Extended/issues/2763
This commit is contained in:
parent
e4771f558b
commit
ef63c8dba7
@ -1,11 +0,0 @@
|
||||
package app.revanced.extension.music.patches.misc;
|
||||
|
||||
import app.revanced.extension.music.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class OpusCodecPatch {
|
||||
|
||||
public static boolean enableOpusCodec() {
|
||||
return Settings.ENABLE_OPUS_CODEC.get();
|
||||
}
|
||||
}
|
@ -190,7 +190,6 @@ public class Settings extends BaseSettings {
|
||||
public static final BooleanSetting DISABLE_DRC_AUDIO = new BooleanSetting("revanced_disable_drc_audio", FALSE, true);
|
||||
public static final BooleanSetting DISABLE_MUSIC_VIDEO_IN_ALBUM = new BooleanSetting("revanced_disable_music_video_in_album", FALSE, true);
|
||||
public static final EnumSetting<RedirectType> DISABLE_MUSIC_VIDEO_IN_ALBUM_REDIRECT_TYPE = new EnumSetting<>("revanced_disable_music_video_in_album_redirect_type", RedirectType.REDIRECT, true);
|
||||
public static final BooleanSetting ENABLE_OPUS_CODEC = new BooleanSetting("revanced_enable_opus_codec", FALSE, true);
|
||||
public static final BooleanSetting SETTINGS_IMPORT_EXPORT = new BooleanSetting("revanced_extended_settings_import_export", FALSE, false);
|
||||
|
||||
// PreferenceScreen: Return YouTube Dislike
|
||||
|
@ -0,0 +1,11 @@
|
||||
package app.revanced.extension.shared.patches;
|
||||
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class OpusCodecPatch {
|
||||
|
||||
public static boolean enableOpusCodec() {
|
||||
return BaseSettings.ENABLE_OPUS_CODEC.get();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.extension.youtube.patches.misc;
|
||||
package app.revanced.extension.shared.patches;
|
||||
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
|
@ -56,6 +56,7 @@ public class BaseSettings {
|
||||
|
||||
public static final BooleanSetting DISABLE_AUTO_CAPTIONS = new BooleanSetting("revanced_disable_auto_captions", FALSE, true);
|
||||
public static final BooleanSetting DISABLE_QUIC_PROTOCOL = new BooleanSetting("revanced_disable_quic_protocol", FALSE, true);
|
||||
public static final BooleanSetting ENABLE_OPUS_CODEC = new BooleanSetting("revanced_enable_opus_codec", FALSE, true);
|
||||
|
||||
public static final BooleanSetting BYPASS_IMAGE_REGION_RESTRICTIONS = new BooleanSetting("revanced_bypass_image_region_restrictions", FALSE, true);
|
||||
public static final EnumSetting<WatchHistoryType> WATCH_HISTORY_TYPE = new EnumSetting<>("revanced_watch_history_type", WatchHistoryType.REPLACE);
|
||||
|
@ -1,11 +0,0 @@
|
||||
package app.revanced.extension.youtube.patches.misc;
|
||||
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class OpusCodecPatch {
|
||||
|
||||
public static boolean enableOpusCodec() {
|
||||
return Settings.ENABLE_OPUS_CODEC.get();
|
||||
}
|
||||
}
|
@ -567,7 +567,6 @@ public class Settings extends BaseSettings {
|
||||
|
||||
// Experimental Flags
|
||||
public static final BooleanSetting CHANGE_SHARE_SHEET = new BooleanSetting("revanced_change_share_sheet", FALSE, true);
|
||||
public static final BooleanSetting ENABLE_OPUS_CODEC = new BooleanSetting("revanced_enable_opus_codec", FALSE, true);
|
||||
|
||||
/**
|
||||
* @noinspection DeprecatedIsStillUsed
|
||||
|
@ -2,7 +2,6 @@ package app.revanced.patches.music.misc.codecs
|
||||
|
||||
import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.music.utils.extension.Constants.MISC_PATH
|
||||
import app.revanced.patches.music.utils.patch.PatchList.ENABLE_OPUS_CODEC
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus
|
||||
@ -18,10 +17,8 @@ val opusCodecPatch = resourcePatch(
|
||||
compatibleWith(COMPATIBLE_PACKAGE)
|
||||
|
||||
dependsOn(
|
||||
baseOpusCodecsPatch(
|
||||
"$MISC_PATH/OpusCodecPatch;->enableOpusCodec()Z"
|
||||
),
|
||||
settingsPatch
|
||||
settingsPatch,
|
||||
baseOpusCodecsPatch(),
|
||||
)
|
||||
|
||||
execute {
|
||||
@ -30,8 +27,6 @@ val opusCodecPatch = resourcePatch(
|
||||
"revanced_enable_opus_codec",
|
||||
"false"
|
||||
)
|
||||
|
||||
updatePatchStatus(ENABLE_OPUS_CODEC)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package app.revanced.patches.music.misc.quic
|
||||
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.music.utils.patch.PatchList.DISABLE_QUIC_PROTOCOL
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus
|
||||
import app.revanced.patches.music.utils.settings.addSwitchPreference
|
||||
import app.revanced.patches.music.utils.settings.settingsPatch
|
||||
import app.revanced.patches.shared.quic.baseQuicProtocolPatch
|
||||
|
||||
@Suppress("unused", "SpellCheckingInspection")
|
||||
val quicProtocolPatch = bytecodePatch(
|
||||
DISABLE_QUIC_PROTOCOL.title,
|
||||
DISABLE_QUIC_PROTOCOL.summary,
|
||||
) {
|
||||
compatibleWith(COMPATIBLE_PACKAGE)
|
||||
|
||||
dependsOn(
|
||||
settingsPatch,
|
||||
baseQuicProtocolPatch(),
|
||||
)
|
||||
|
||||
execute {
|
||||
|
||||
addSwitchPreference(
|
||||
CategoryType.MISC,
|
||||
"revanced_disable_quic_protocol",
|
||||
"false"
|
||||
)
|
||||
updatePatchStatus(DISABLE_QUIC_PROTOCOL)
|
||||
|
||||
}
|
||||
}
|
@ -61,6 +61,10 @@ internal enum class PatchList(
|
||||
"Disable music video in album",
|
||||
"Adds option to redirect music videos from albums for non-premium users."
|
||||
),
|
||||
DISABLE_QUIC_PROTOCOL(
|
||||
"Disable QUIC protocol",
|
||||
"Adds an option to disable CronetEngine's QUIC protocol."
|
||||
),
|
||||
ENABLE_OPUS_CODEC(
|
||||
"Enable OPUS codec",
|
||||
"Adds an option to enable the OPUS audio codec if the player response includes it."
|
||||
|
@ -4,6 +4,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.extension.Constants.PATCHES_PATH
|
||||
import app.revanced.util.fingerprint.matchOrThrow
|
||||
import app.revanced.util.fingerprint.methodOrThrow
|
||||
import app.revanced.util.getReference
|
||||
@ -13,9 +14,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
fun baseOpusCodecsPatch(
|
||||
descriptor: String,
|
||||
) = bytecodePatch(
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
"$PATCHES_PATH/OpusCodecPatch;"
|
||||
|
||||
fun baseOpusCodecsPatch() = bytecodePatch(
|
||||
description = "baseOpusCodecsPatch"
|
||||
) {
|
||||
execute {
|
||||
@ -35,7 +37,7 @@ fun baseOpusCodecsPatch(
|
||||
|
||||
addInstructionsWithLabels(
|
||||
targetIndex + 1, """
|
||||
invoke-static {}, $descriptor
|
||||
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->enableOpusCodec()Z
|
||||
move-result v$freeRegister
|
||||
if-eqz v$freeRegister, :mp4a
|
||||
invoke-static {}, $opusCodecReference
|
||||
|
@ -0,0 +1,30 @@
|
||||
@file:Suppress("SpellCheckingInspection")
|
||||
|
||||
package app.revanced.patches.shared.quic
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.shared.extension.Constants.PATCHES_PATH
|
||||
import app.revanced.util.fingerprint.methodOrThrow
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
"$PATCHES_PATH/QUICProtocolPatch;"
|
||||
|
||||
fun baseQuicProtocolPatch() = bytecodePatch(
|
||||
description = "baseQuicProtocolPatch"
|
||||
) {
|
||||
execute {
|
||||
arrayOf(
|
||||
cronetEngineBuilderFingerprint,
|
||||
experimentalCronetEngineBuilderFingerprint
|
||||
).forEach {
|
||||
it.methodOrThrow().addInstructions(
|
||||
0, """
|
||||
invoke-static {p1}, $EXTENSION_CLASS_DESCRIPTOR->disableQUICProtocol(Z)Z
|
||||
move-result p1
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
@file:Suppress("SpellCheckingInspection")
|
||||
|
||||
package app.revanced.patches.youtube.misc.quic
|
||||
package app.revanced.patches.shared.quic
|
||||
|
||||
import app.revanced.util.fingerprint.legacyFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
@ -3,7 +3,6 @@ package app.revanced.patches.youtube.misc.codecs
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.shared.opus.baseOpusCodecsPatch
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.extension.Constants.MISC_PATH
|
||||
import app.revanced.patches.youtube.utils.patch.PatchList.ENABLE_OPUS_CODEC
|
||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference
|
||||
import app.revanced.patches.youtube.utils.settings.settingsPatch
|
||||
@ -16,16 +15,11 @@ val opusCodecPatch = bytecodePatch(
|
||||
compatibleWith(COMPATIBLE_PACKAGE)
|
||||
|
||||
dependsOn(
|
||||
baseOpusCodecsPatch(
|
||||
"$MISC_PATH/OpusCodecPatch;->enableOpusCodec()Z"
|
||||
),
|
||||
settingsPatch,
|
||||
baseOpusCodecsPatch(),
|
||||
)
|
||||
|
||||
execute {
|
||||
|
||||
// region add settings
|
||||
|
||||
addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE_CATEGORY: MISC_EXPERIMENTAL_FLAGS",
|
||||
@ -33,8 +27,5 @@ val opusCodecPatch = bytecodePatch(
|
||||
),
|
||||
ENABLE_OPUS_CODEC
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,30 @@
|
||||
package app.revanced.patches.youtube.misc.quic
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.shared.quic.baseQuicProtocolPatch
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.extension.Constants.MISC_PATH
|
||||
import app.revanced.patches.youtube.utils.patch.PatchList.DISABLE_QUIC_PROTOCOL
|
||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference
|
||||
import app.revanced.patches.youtube.utils.settings.settingsPatch
|
||||
import app.revanced.util.fingerprint.methodOrThrow
|
||||
|
||||
@Suppress("unused")
|
||||
@Suppress("unused", "SpellCheckingInspection")
|
||||
val quicProtocolPatch = bytecodePatch(
|
||||
DISABLE_QUIC_PROTOCOL.title,
|
||||
DISABLE_QUIC_PROTOCOL.summary,
|
||||
) {
|
||||
compatibleWith(COMPATIBLE_PACKAGE)
|
||||
|
||||
dependsOn(settingsPatch)
|
||||
dependsOn(
|
||||
settingsPatch,
|
||||
baseQuicProtocolPatch(),
|
||||
)
|
||||
|
||||
execute {
|
||||
|
||||
arrayOf(
|
||||
cronetEngineBuilderFingerprint,
|
||||
experimentalCronetEngineBuilderFingerprint
|
||||
).forEach {
|
||||
it.methodOrThrow().addInstructions(
|
||||
0, """
|
||||
invoke-static {p1}, $MISC_PATH/QUICProtocolPatch;->disableQUICProtocol(Z)Z
|
||||
move-result p1
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
// region add settings
|
||||
|
||||
addPreference(
|
||||
arrayOf(
|
||||
"SETTINGS: DISABLE_QUIC_PROTOCOL"
|
||||
),
|
||||
DISABLE_QUIC_PROTOCOL
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -469,6 +469,8 @@ Click to see how to issue an API key."</string>
|
||||
Find the official song if a music video is detected playing from an album.
|
||||
|
||||
• Powered by Piped Instance API."</string>
|
||||
<string name="revanced_disable_quic_protocol_title">Disable QUIC protocol</string>
|
||||
<string name="revanced_disable_quic_protocol_summary">"Disables CronetEngine's QUIC protocol."</string>
|
||||
<string name="revanced_disable_music_video_in_album_redirect_type_title">Redirection type</string>
|
||||
<string name="revanced_disable_music_video_in_album_redirect_type_summary">Specifies how to redirect to official song.</string>
|
||||
<string name="revanced_disable_music_video_in_album_redirect_type_entry_redirect">Redirect</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user