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