From b219e0d0265bf22ac415c2c6a3069126ddf76298 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sun, 13 Oct 2024 01:52:09 +0900 Subject: [PATCH] fix(YouTube Music/Spoof app version): ListPreference sometimes selects wrong values --- .../general/spoofappversion/SpoofAppVersionPatch.kt | 11 +++++++++++ .../music/utils/settings/SettingsBytecodePatch.kt | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt index b3a40403d..11a691e9c 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt @@ -1,11 +1,15 @@ package app.revanced.patches.music.general.spoofappversion import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patches.music.general.oldstylelibraryshelf.OldStyleLibraryShelfPatch 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.SettingsBytecodePatch import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.util.appendAppVersion +import app.revanced.util.findMethodOrThrow import app.revanced.util.patch.BaseResourcePatch @Suppress("unused") @@ -24,6 +28,13 @@ object SpoofAppVersionPatch : BaseResourcePatch( if (SettingsPatch.upward0718) { context.appendAppVersion("7.16.53") + + SettingsBytecodePatch.contexts.findMethodOrThrow(GENERAL_CLASS_DESCRIPTOR) { + name == "getSpoofAppVersionDefault" + }.replaceInstruction( + 0, + "const-string v0, \"7.16.53\"" + ) } SettingsPatch.addSwitchPreference( diff --git a/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsBytecodePatch.kt index e3a25fead..44ac05499 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsBytecodePatch.kt @@ -44,8 +44,10 @@ object SettingsBytecodePatch : BytecodePatch( "$INTEGRATIONS_PATH/settings/preference/ReVancedPreferenceFragment;" private const val INTEGRATIONS_INITIALIZATION_CLASS_DESCRIPTOR = "$UTILS_PATH/InitializationPatch;" + lateinit var contexts: BytecodeContext override fun execute(context: BytecodeContext) { + contexts = context /** * Set SharedPrefCategory