From 4387c55479ca2fb39ef633617d0f1394615ebe4f Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:06:33 +0900 Subject: [PATCH] feat(YouTube Music/Spoof app version): app crashes when first installed --- .../spoofappversion/SpoofAppVersionPatch.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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 11a691e9c..90ac0f104 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 @@ -4,7 +4,7 @@ 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.integrations.Constants.PATCH_STATUS_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 @@ -26,21 +26,30 @@ object SpoofAppVersionPatch : BaseResourcePatch( ) { override fun execute(context: ResourceContext) { + var defaultValue = "false" + if (SettingsPatch.upward0718) { context.appendAppVersion("7.16.53") - SettingsBytecodePatch.contexts.findMethodOrThrow(GENERAL_CLASS_DESCRIPTOR) { - name == "getSpoofAppVersionDefault" + SettingsBytecodePatch.contexts.findMethodOrThrow(PATCH_STATUS_CLASS_DESCRIPTOR) { + name == "SpoofAppVersionDefaultString" }.replaceInstruction( 0, "const-string v0, \"7.16.53\"" ) + SettingsBytecodePatch.contexts.findMethodOrThrow(PATCH_STATUS_CLASS_DESCRIPTOR) { + name == "SpoofAppVersionDefaultBoolean" + }.replaceInstruction( + 0, + "const/4 v0, 0x1" + ) + defaultValue = "true" } SettingsPatch.addSwitchPreference( CategoryType.GENERAL, "revanced_spoof_app_version", - "false" + defaultValue ) SettingsPatch.addPreferenceWithIntent( CategoryType.GENERAL,