feat: Auto Mapper for Manage Friend List(thanks to RSR)
This commit is contained in:
@@ -14,39 +14,67 @@ class FriendRelationshipChangerMapper : AbstractClassMapper("FriendRelationshipC
|
||||
val addFriendMethod = string("addFriendMethod")
|
||||
val runFriendDurableJob = string("runFriendDurableJob")
|
||||
|
||||
val helperClass = classReference("helper")
|
||||
val addFriend14Method = string("addFriend14Method")
|
||||
val sourceType = classReference("sourceType")
|
||||
val pageType = classReference("pageType")
|
||||
|
||||
init {
|
||||
mapper {
|
||||
var frcClassDef: com.android.tools.smali.dexlib2.iface.ClassDef? = null
|
||||
for (classDef in classes) {
|
||||
classDef.methods.firstOrNull { it.name == "<init>" }?.implementation?.findConstString("FriendRelationshipChangerImpl")?.takeIf { it } ?: continue
|
||||
classReference.set(classDef.getClassName())
|
||||
if (classDef.methods.any { it.name == "<init>" && it.implementation?.findConstString("FriendRelationshipChangerImpl") == true }) {
|
||||
frcClassDef = classDef
|
||||
classReference.set(classDef.getClassName())
|
||||
|
||||
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)
|
||||
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)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
mapper {
|
||||
for (classDef in classes) {
|
||||
if (!classDef.isAbstract()) continue
|
||||
val addFriendDexMethod = classDef.methods.firstOrNull {
|
||||
Modifier.isStatic(it.accessFlags) &&
|
||||
it.parameterTypes.size == 6 &&
|
||||
it.parameterTypes[1] == "Ljava/lang/String;" &&
|
||||
getClass(it.parameterTypes[2])?.isEnum() == true &&
|
||||
getClass(it.parameterTypes[4])?.isEnum() == true &&
|
||||
it.parameterTypes[5] == "I"
|
||||
} ?: continue
|
||||
|
||||
friendshipRelationshipChangerKtx.set(classDef.getClassName())
|
||||
addFriendMethod.set(addFriendDexMethod.name)
|
||||
return@mapper
|
||||
val frcType = frcClassDef?.type ?: return@mapper
|
||||
val frcInterfaces = frcClassDef.interfaces
|
||||
|
||||
for (classDef in classes) {
|
||||
if (helperClass.get() == null) {
|
||||
val method = classDef.methods.firstOrNull {
|
||||
Modifier.isStatic(it.accessFlags) &&
|
||||
it.parameterTypes.size == 14 &&
|
||||
(it.parameterTypes[0] == frcType || frcInterfaces.contains(it.parameterTypes[0])) &&
|
||||
it.parameterTypes[1] == "Ljava/lang/String;" &&
|
||||
getClass(it.parameterTypes[2])?.isEnum() == true
|
||||
}
|
||||
if (method != null) {
|
||||
helperClass.set(classDef.getClassName())
|
||||
addFriend14Method.set(method.name)
|
||||
sourceType.set(getClass(method.parameterTypes[3])?.getClassName())
|
||||
pageType.set(getClass(method.parameterTypes[4])?.getClassName())
|
||||
}
|
||||
}
|
||||
|
||||
if (friendshipRelationshipChangerKtx.get() == null && classDef.isAbstract()) {
|
||||
val addFriendDexMethod = classDef.methods.firstOrNull {
|
||||
Modifier.isStatic(it.accessFlags) &&
|
||||
it.parameterTypes.size == 6 &&
|
||||
it.parameterTypes[1] == "Ljava/lang/String;" &&
|
||||
getClass(it.parameterTypes[2])?.isEnum() == true &&
|
||||
getClass(it.parameterTypes[4])?.isEnum() == true &&
|
||||
it.parameterTypes[5] == "I"
|
||||
}
|
||||
if (addFriendDexMethod != null) {
|
||||
friendshipRelationshipChangerKtx.set(classDef.getClassName())
|
||||
addFriendMethod.set(addFriendDexMethod.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user