fix: friend relationship changer mapper

This commit is contained in:
rhunk
2024-05-17 16:37:29 +02:00
parent fc65dfc626
commit 28433922c5
2 changed files with 33 additions and 21 deletions

View File

@ -12,30 +12,28 @@ class FriendRelationshipChangerMapper : AbstractClassMapper("FriendRelationshipC
val friendshipRelationshipChangerKtx = classReference("removeFriendClass")
val addFriendMethod = string("addFriendMethod")
val removeFriendMethod = string("removeFriendMethod")
val runFriendDurableJob = string("runFriendDurableJob")
init {
mapper {
for (classDef in classes) {
classDef.methods.firstOrNull { it.name == "<init>" }?.implementation?.findConstString("FriendRelationshipChangerImpl")?.takeIf { it } ?: continue
classReference.set(classDef.getClassName())
return@mapper
runFriendDurableJob.set(classDef.methods.firstOrNull {
Modifier.isStatic(it.accessFlags) &&
it.returnType.contains("CompletableAndThenCompletable") &&
it.parameterTypes.size == 5 &&
it.parameterTypes[0] == classDef.type &&
it.parameterTypes[1] == "Ljava/lang/String;" &&
it.parameterTypes[3] == "I" &&
it.parameterTypes[4] == "Ljava/lang/String;"
}?.name ?: continue)
}
}
mapper {
for (classDef in classes) {
if (!classDef.isAbstract()) continue
val removeFriendDexMethod = classDef.methods.firstOrNull {
Modifier.isStatic(it.accessFlags) &&
it.parameterTypes.size == 5 &&
it.returnType.contains("io/reactivex/rxjava3") &&
getClass(it.parameterTypes[2])?.isEnum() == true &&
getClass(it.parameterTypes[3])?.getClassName()?.endsWith("InteractionPlacementInfo") == true
} ?: continue
friendshipRelationshipChangerKtx.set(classDef.getClassName())
removeFriendMethod.set(removeFriendDexMethod.name)
val addFriendDexMethod = classDef.methods.firstOrNull {
Modifier.isStatic(it.accessFlags) &&
it.parameterTypes.size == 6 &&
@ -43,8 +41,9 @@ class FriendRelationshipChangerMapper : AbstractClassMapper("FriendRelationshipC
getClass(it.parameterTypes[2])?.isEnum() == true &&
getClass(it.parameterTypes[4])?.isEnum() == true &&
it.parameterTypes[5] == "I"
} ?: return@mapper
} ?: continue
friendshipRelationshipChangerKtx.set(classDef.getClassName())
addFriendMethod.set(addFriendDexMethod.name)
return@mapper
}