add disable-quic-protocol patch (Experimental Flags)

This commit is contained in:
inotia00 2023-03-14 10:38:49 +09:00
parent 2a0fa0b615
commit 714d79f597
5 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,11 @@
package app.revanced.patches.youtube.misc.quic.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object CronetEngineBuilderFingerprint : MethodFingerprint(
returnType = "L",
access = AccessFlags.PUBLIC.value,
parameters = listOf("Z"),
customFingerprint = { it.definingClass == "Lorg/chromium/net/CronetEngine\$Builder;" && it.name == "enableQuic" }
)

View File

@ -0,0 +1,11 @@
package app.revanced.patches.youtube.misc.quic.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object ExperimentalCronetEngineBuilderFingerprint : MethodFingerprint(
returnType = "L",
access = AccessFlags.PUBLIC.value,
parameters = listOf("Z"),
customFingerprint = { it.definingClass == "Lorg/chromium/net/ExperimentalCronetEngine\$Builder;" && it.name == "enableQuic" }
)

View File

@ -0,0 +1,58 @@
package app.revanced.patches.youtube.misc.quic.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.quic.fingerprints.*
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.MISC_PATH
@Patch
@Name("disable-quic-protocol")
@Description("Disable CronetEngine's QUIC protocol.")
@DependsOn([SettingsPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class QUICProtocolPatch : BytecodePatch(
listOf(
CronetEngineBuilderFingerprint,
ExperimentalCronetEngineBuilderFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
arrayOf(
CronetEngineBuilderFingerprint,
ExperimentalCronetEngineBuilderFingerprint
).forEach {
it.result?.mutableMethod?.addInstructions(
0, """
invoke-static {p1}, $MISC_PATH/QUICProtocolPatch;->disableQUICProtocol(Z)Z
move-result p1
"""
)?: return it.toErrorResult()
}
/*
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"SETTINGS: DISABLE_QUIC_PROTOCOL"
)
)
SettingsPatch.updatePatchStatus("disable-quic-protocol")
return PatchResultSuccess()
}
}

View File

@ -173,6 +173,8 @@ Is it ready to submit?"</string>
<string name="revanced_disable_haptic_feedback_zoom_summary_off">Zoom haptic feedback is enabled</string>
<string name="revanced_disable_haptic_feedback_zoom_summary_on">Zoom haptic feedback is disabled</string>
<string name="revanced_disable_haptic_feedback_zoom_title">Disable zoom haptic feedback</string>
<string name="revanced_disable_quic_protocol_summary">"Disable CronetEngine's QUIC protocol"</string>
<string name="revanced_disable_quic_protocol_title">Disable QUIC protocol</string>
<string name="revanced_double_back_timeout_summary">The amount of seconds the double press back to exit</string>
<string name="revanced_double_back_timeout_title">Double back timeout</string>
<string name="revanced_downloader_not_installed">is not installed. Please install it.</string>
@ -485,6 +487,7 @@ In the app settings, the YouTube version may be marked as v17.28.35"</string>
If you enable this setting, the following features are available:
- Community Posts
- Hide Mix playlist"</string>
<string name="revanced_reboot_warning_quic">It is recommended not to use it if your internet speed is not fast enough</string>
<string name="revanced_reboot_warning_switch">"If you enable this setting, the following features are not available:
- Ambient mode"</string>
<string name="revanced_reboot_warning_tablet">"Tricks the dpi to change some layouts to tablet layouts.

View File

@ -377,6 +377,8 @@
<SwitchPreference android:title="@string/revanced_enable_phone_layout_title" android:key="revanced_enable_phone_layout" android:summary="@string/revanced_enable_phone_layout_summary" android:defaultValue="false" />SETTINGS: LAYOUT_SWITCH -->
<!-- SETTINGS: ENABLE_VP9_CODEC
<SwitchPreference android:title="@string/revanced_enable_vp9_codec_title" android:key="revanced_enable_vp9_codec" android:defaultValue="false" android:summary="@string/revanced_enable_vp9_codec_summary" />SETTINGS: ENABLE_VP9_CODEC -->
<!-- SETTINGS: DISABLE_QUIC_PROTOCOL
<SwitchPreference android:title="@string/revanced_disable_quic_protocol_title" android:key="revanced_disable_quic_protocol" android:defaultValue="false" android:summary="@string/revanced_disable_quic_protocol_summary" />SETTINGS: DISABLE_QUIC_PROTOCOL -->
<PreferenceScreen android:title="@string/revanced_backup_title" android:key="backup" android:summary="@string/revanced_backup_summary">
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_backup_title" />
</PreferenceScreen>
@ -465,6 +467,7 @@
<Preference android:title="enable-old-layout" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="layout-switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="force-vp9-codec" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="disable-quic-protocol" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_others" />
<Preference android:title="return-youtube-dislike" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>