use of jadx.api.JavaMethod in project jadx by skylot.
the class XposedAction method generateMethodSnippet.
private String generateMethodSnippet(JMethod jMth) {
JavaMethod javaMethod = jMth.getJavaMethod();
MethodNode mth = javaMethod.getMethodNode();
String methodName;
String xposedMethod;
if (mth.isConstructor()) {
xposedMethod = "findAndHookConstructor";
methodName = "";
} else {
xposedMethod = "findAndHookMethod";
methodName = "\"" + mth.getMethodInfo().getName() + "\", ";
}
String rawClassName = javaMethod.getDeclaringClass().getRawName();
String xposedFormatStr = "XposedHelpers.%s(\"%s\", classLoader, %snew XC_MethodHook() {\n" + " @Override\n" + " protected void beforeHookedMethod(MethodHookParam param) throws Throwable {\n" + " super.beforeHookedMethod(param);\n" + " }\n" + " @Override\n" + " protected void afterHookedMethod(MethodHookParam param) throws Throwable {\n" + " super.afterHookedMethod(param);\n" + " }\n" + "});";
List<ArgType> mthArgs = mth.getArgTypes();
if (mthArgs.isEmpty()) {
return String.format(xposedFormatStr, xposedMethod, rawClassName, methodName);
}
String params = mthArgs.stream().map(type -> type + ".class, ").collect(Collectors.joining());
return String.format(xposedFormatStr, xposedMethod, rawClassName, methodName + params);
}
Aggregations