feat(YouTube Music/Spoof app version): app crashes when first installed

This commit is contained in:
inotia00 2024-10-18 21:06:33 +09:00
parent f29fbaeebe
commit 4387c55479

View File

@ -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,