From 1b77f9633cf7e72d653f1d37483b7399e1ad797d Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 10 Jun 2023 18:39:50 +0200 Subject: [PATCH] feat(songpal): add `remove-notification-badge` patch --- .../ShowNotificationFingerprint.kt | 31 +++++++++++++++++++ .../patch/RemoveNotificationBadgePatch.kt | 31 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/ShowNotificationFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/songpal/badge/patch/RemoveNotificationBadgePatch.kt diff --git a/src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/ShowNotificationFingerprint.kt b/src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/ShowNotificationFingerprint.kt new file mode 100644 index 000000000..b6131554d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/ShowNotificationFingerprint.kt @@ -0,0 +1,31 @@ +package app.revanced.patches.songpal.badge.fingerprints + +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +// Located @ com.sony.songpal.mdr.vim.activity.MdrRemoteBaseActivity.e#run (9.5.0) +@FuzzyPatternScanMethod(2) +object ShowNotificationFingerprint : MethodFingerprint( + "V", + accessFlags = AccessFlags.PUBLIC.value, + opcodes = listOf( + Opcode.IGET_OBJECT, + Opcode.IGET, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.IGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CONST, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.INVOKE_VIRTUAL, + Opcode.IGET_BOOLEAN, + Opcode.INVOKE_VIRTUAL, + Opcode.CONST, + Opcode.INVOKE_VIRTUAL, + Opcode.RETURN_VOID + ) +) diff --git a/src/main/kotlin/app/revanced/patches/songpal/badge/patch/RemoveNotificationBadgePatch.kt b/src/main/kotlin/app/revanced/patches/songpal/badge/patch/RemoveNotificationBadgePatch.kt new file mode 100644 index 000000000..3c1626867 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/songpal/badge/patch/RemoveNotificationBadgePatch.kt @@ -0,0 +1,31 @@ +package app.revanced.patches.songpal.badge.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.songpal.badge.annotations.BadgeCompatibility +import app.revanced.patches.songpal.badge.fingerprints.ShowNotificationFingerprint + +@Patch +@Name("remove-notification-badge") +@Description("Removes the red notification badge from the activity tab.") +@BadgeCompatibility +@Version("0.0.1") +class RemoveNotificationBadgePatch : BytecodePatch( + listOf(ShowNotificationFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + ShowNotificationFingerprint.result?.mutableMethod?.apply { + addInstructions(0, "return-void") + } ?: return ShowNotificationFingerprint.toErrorResult() + + return PatchResultSuccess() + } +}