diff --git a/src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/CreateTabsFingerprint.kt b/src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/CreateTabsFingerprint.kt index b78dc6a5..59f82c3a 100644 --- a/src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/CreateTabsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/CreateTabsFingerprint.kt @@ -1,31 +1,26 @@ package app.revanced.patches.songpal.badge.fingerprints -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.songpal.badge.patch.BadgeTabPatch import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.ReferenceInstruction +import org.jf.dexlib2.iface.reference.MethodReference // Located @ ub.i0.h#p (9.5.0) -@FuzzyPatternScanMethod(2) object CreateTabsFingerprint : MethodFingerprint( - "L", + "Ljava/util/List", accessFlags = AccessFlags.PRIVATE.value, - opcodes = listOf( - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.SGET_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT_OBJECT, - Opcode.SGET_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CHECK_CAST, - Opcode.RETURN_OBJECT - ) + customFingerprint = { methodDef, _ -> + methodDef.implementation?.instructions?.any { instruction -> + if (instruction.opcode != Opcode.INVOKE_STATIC) return@any false + + val reference = (instruction as ReferenceInstruction).reference as MethodReference + + if (reference.parameterTypes.isNotEmpty()) return@any false + if (reference.definingClass != BadgeTabPatch.ACTIVITY_TAB_DESCRIPTOR) return@any false + if (reference.returnType != "[${BadgeTabPatch.ACTIVITY_TAB_DESCRIPTOR}") return@any false + true + } ?: false + } ) 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 index b6131554..d480430d 100644 --- a/src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/ShowNotificationFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/ShowNotificationFingerprint.kt @@ -1,31 +1,37 @@ package app.revanced.patches.songpal.badge.fingerprints -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.songpal.badge.fingerprints.ShowNotificationFingerprint.expectedReference import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.ReferenceInstruction +import org.jf.dexlib2.iface.reference.MethodReference +import org.jf.dexlib2.immutable.reference.ImmutableMethodReference // 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 + customFingerprint = custom@{ methodDef, _ -> + methodDef.implementation?.instructions?.any { instruction -> + if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return@any false + + with(expectedReference) { + val currentReference = (instruction as ReferenceInstruction).reference as MethodReference + currentReference.let { + if (it.definingClass != definingClass) return@any false + if (it.parameterTypes != parameterTypes) return@any false + if (it.returnType != returnType) return@any false + } + } + true + } ?: false + } +) { + val expectedReference = ImmutableMethodReference( + "Lcom/google/android/material/bottomnavigation/BottomNavigationView;", + "getOrCreateBadge", // Non-obfuscated placeholder method name. + listOf("I"), + "Lcom/google/android/material/badge/BadgeDrawable;", ) -) +}