From a14d53f3989977a16e5c75c704190845c6249f0b Mon Sep 17 00:00:00 2001 From: inotia00 Date: Tue, 5 Sep 2023 10:51:49 +0900 Subject: [PATCH] fix(music/settings): blank screen appears when text input dialog is shown --- .../FullStackTraceActivityFingerprint.kt | 7 ++++ .../utils/intenthook/patch/IntentHookPatch.kt | 33 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/music/utils/intenthook/fingerprints/FullStackTraceActivityFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/music/utils/intenthook/patch/IntentHookPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/music/utils/intenthook/fingerprints/FullStackTraceActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/intenthook/fingerprints/FullStackTraceActivityFingerprint.kt new file mode 100644 index 000000000..7b4f369bf --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/utils/intenthook/fingerprints/FullStackTraceActivityFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.music.utils.intenthook.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object FullStackTraceActivityFingerprint : MethodFingerprint( + customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/FullStackTraceActivity;") && methodDef.name == "onCreate" } +) diff --git a/src/main/kotlin/app/revanced/patches/music/utils/intenthook/patch/IntentHookPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/intenthook/patch/IntentHookPatch.kt new file mode 100644 index 000000000..a3bfc27da --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/utils/intenthook/patch/IntentHookPatch.kt @@ -0,0 +1,33 @@ +package app.revanced.patches.music.utils.intenthook.patch + +import app.revanced.extensions.exception +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.music.utils.intenthook.fingerprints.FullStackTraceActivityFingerprint +import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.integrations.Constants.MUSIC_INTEGRATIONS_PATH + +@DependsOn([SettingsPatch::class]) +class IntentHookPatch : BytecodePatch( + listOf(FullStackTraceActivityFingerprint) +) { + override fun execute(context: BytecodeContext) { + FullStackTraceActivityFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 1, """ + invoke-static {p0}, $MUSIC_INTEGRATIONS_PATH/settingsmenu/SharedPreferenceChangeListener;->initializeSettings(Landroid/app/Activity;)Z + move-result v0 + if-eqz v0, :show + return-void + """, ExternalLabel("show", getInstruction(1)) + ) + } + } ?: throw FullStackTraceActivityFingerprint.exception + + } +} \ No newline at end of file