mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 09:07:46 +01:00
fix(songpal): make patches more resilient (#2386)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
41779305d5
commit
947bf42b7c
2 changed files with 42 additions and 41 deletions
|
@ -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
|
||||
}
|
||||
)
|
||||
|
|
|
@ -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;",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue