From ccf5054b046177149f8426e40b358f7f27bba993 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sat, 21 Oct 2023 05:02:18 +0900 Subject: [PATCH] fix(YouTube/Default playback speed): change default value --- .../music/video/speed/PlaybackSpeedPatch.kt | 3 ++ .../youtube/video/speed/PlaybackSpeedPatch.kt | 4 +++ .../revanced/util/bytecode/BytecodeHelper.kt | 29 ++++++++++++------- .../youtube/settings/xml/revanced_prefs.xml | 2 +- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/music/video/speed/PlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/music/video/speed/PlaybackSpeedPatch.kt index cef33e270..86ccd8139 100644 --- a/src/main/kotlin/app/revanced/patches/music/video/speed/PlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/video/speed/PlaybackSpeedPatch.kt @@ -12,6 +12,7 @@ import app.revanced.patches.music.utils.overridespeed.OverrideSpeedHookPatch import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.video.speed.fingerprints.PlaybackSpeedBottomSheetFingerprint import app.revanced.patches.music.video.speed.fingerprints.PlaybackSpeedBottomSheetParentFingerprint +import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_VIDEO_PATH import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction @@ -67,6 +68,8 @@ object PlaybackSpeedPatch : BytecodePatch( "false" ) + context.updatePatchStatus("RememberPlaybackSpeed", false) + } private const val INTEGRATIONS_CLASS_DESCRIPTOR = diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt index 2336afef0..bd1b35409 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt @@ -13,6 +13,8 @@ import app.revanced.patches.youtube.utils.overridespeed.OverrideSpeedHookPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.videocpn.VideoCpnPatch import app.revanced.patches.youtube.video.speed.fingerprints.NewPlaybackSpeedChangedFingerprint +import app.revanced.util.bytecode.BytecodeHelper +import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.integrations.Constants.VIDEO_PATH import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction @@ -87,6 +89,8 @@ object PlaybackSpeedPatch : BytecodePatch( SettingsPatch.updatePatchStatus("Default playback speed") + context.updatePatchStatus("DefaultPlaybackSpeed", true) + } private const val INTEGRATIONS_PLAYBACK_SPEED_CLASS_DESCRIPTOR = diff --git a/src/main/kotlin/app/revanced/util/bytecode/BytecodeHelper.kt b/src/main/kotlin/app/revanced/util/bytecode/BytecodeHelper.kt index fc678c44f..7f9d5e9bb 100644 --- a/src/main/kotlin/app/revanced/util/bytecode/BytecodeHelper.kt +++ b/src/main/kotlin/app/revanced/util/bytecode/BytecodeHelper.kt @@ -40,18 +40,25 @@ internal object BytecodeHelper { } } - internal fun BytecodeContext.updatePatchStatus(patch: String) { - this.classes.forEach { classDef -> - classDef.methods.forEach { method -> - if (classDef.type.endsWith("/PatchStatus;") && method.name == patch) { - val patchStatusMethod = - this.proxy(classDef).mutableClass.methods.first { it.name == patch } + internal fun BytecodeContext.updatePatchStatus( + methodName: String, + isYouTube: Boolean + ) { + val integrationPath = + if (isYouTube) + UTILS_PATH + else + MUSIC_UTILS_PATH - patchStatusMethod.replaceInstruction( - 0, - "const/4 v0, 0x1" - ) - } + this.classes.forEach { classDef -> + if (classDef.type.endsWith("$integrationPath/PatchStatus;")) { + val patchStatusMethod = + this.proxy(classDef).mutableClass.methods.first { it.name == methodName } + + patchStatusMethod.replaceInstruction( + 0, + "const/4 v0, 0x1" + ) } } } diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index aeea48844..e4cc81945 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -673,7 +673,7 @@ SETTINGS: CUSTOM_PLAYBACK_SPEED --> + SETTINGS: DEFAULT_PLAYBACK_SPEED -->