mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 17:55:24 +08:00
Release 1.0 available
This commit is contained in:
@@ -9,9 +9,15 @@ java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceSets.main { java.srcDir("src/api/kotlin") }
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.addStringOption("charset", "UTF-8")
|
||||
if (JavaVersion.current().isJava9Compatible()) options.addBooleanOption('html5', true)
|
||||
}
|
||||
|
||||
kotlin { sourceSets.main { kotlin.srcDir("src/api/kotlin") } }
|
||||
|
||||
dependencies {
|
||||
@@ -63,14 +69,8 @@ publishing {
|
||||
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||
}
|
||||
credentials {
|
||||
BufferedReader buff_USERNAME = new BufferedReader(new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/OSSRH_USERNAME"))
|
||||
String OSSRH_USERNAME = buff_USERNAME.readLine()
|
||||
buff_USERNAME.close()
|
||||
BufferedReader buff_PASSWORD = new BufferedReader(new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/OSSRH_PASSWORD"))
|
||||
String OSSRH_PASSWORD = buff_PASSWORD.readLine()
|
||||
buff_PASSWORD.close()
|
||||
username = OSSRH_USERNAME
|
||||
password = OSSRH_PASSWORD
|
||||
username = getFileContent("OSSRH_USERNAME")
|
||||
password = getFileContent("OSSRH_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,4 +78,13 @@ publishing {
|
||||
|
||||
signing {
|
||||
sign(publishing.publications.mavenJava)
|
||||
}
|
||||
|
||||
private static String getFileContent(String name) {
|
||||
FileReader reader = new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/" + name)
|
||||
BufferedReader buff = new BufferedReader(reader)
|
||||
String result = buff.readLine()
|
||||
buff.close()
|
||||
reader.close()
|
||||
return result
|
||||
}
|
@@ -49,10 +49,6 @@ public class ReflectionUtils {
|
||||
private static final HashMap<String, Field> fieldCache = new HashMap<>();
|
||||
private static final HashMap<String, Method> methodCache = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @param clazzes
|
||||
* @return String
|
||||
*/
|
||||
private static String getParametersString(Class<?>... clazzes) {
|
||||
StringBuilder sb = new StringBuilder("(");
|
||||
boolean first = true;
|
||||
@@ -72,70 +68,13 @@ public class ReflectionUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clazz
|
||||
* @param fieldType
|
||||
* @param fieldName
|
||||
* @param value
|
||||
* @return Field
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setStaticObjectField(Class<?> clazz, Class<?> fieldType, String fieldName, Object value)
|
||||
throws NoSuchFieldException, IllegalAccessException {
|
||||
findFieldIfExists(clazz, fieldType, fieldName).set(null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fieldType
|
||||
* @param fieldName
|
||||
* @param value
|
||||
* @param obj
|
||||
* @return Field
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setObjectField(Object obj, Class<?> fieldType, String fieldName, Object value)
|
||||
throws NoSuchFieldException, IllegalAccessException {
|
||||
if (obj != null) {
|
||||
Field field = findFieldIfExists(obj.getClass(), fieldType, fieldName);
|
||||
if (field != null) {
|
||||
field.set(obj, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Field findFieldIfExists(Class<?> clazz, Class<?> fieldType, String fieldName)
|
||||
throws NoSuchFieldException {
|
||||
return findFieldIfExists(clazz, fieldType.getName(), fieldName);
|
||||
}
|
||||
|
||||
private static boolean isCallingFrom(String className) {
|
||||
StackTraceElement[] stackTraceElements = Thread.currentThread()
|
||||
.getStackTrace();
|
||||
for (StackTraceElement element : stackTraceElements) {
|
||||
if (element.getClassName()
|
||||
.contains(className)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isCallingFromEither(String... classname) {
|
||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||
for (StackTraceElement element : stackTraceElements) {
|
||||
for (String name : classname) {
|
||||
if (element.toString().contains(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clazz
|
||||
* @param typeName
|
||||
* @param fieldName
|
||||
* 适用于查找混淆类型的 abcd 变量
|
||||
*
|
||||
* @param clazz 变量所在类
|
||||
* @param typeName 类型名称
|
||||
* @param fieldName 变量名
|
||||
* @return Field
|
||||
* @throws NoSuchFieldException 如果找不到变量
|
||||
*/
|
||||
public static Field findFieldIfExists(Class<?> clazz, String typeName, String fieldName) throws NoSuchFieldException {
|
||||
String fullFieldName = "name:[" + fieldName + "] type:[" + typeName + "] in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
||||
@@ -172,6 +111,7 @@ public class ReflectionUtils {
|
||||
* @param returnType 返回类型
|
||||
* @param methodName 方法名
|
||||
* @return Method
|
||||
* @throws NoSuchMethodError 如果找不到方法
|
||||
*/
|
||||
public static Method findMethodNoParam(Class<?> clazz, Class<?> returnType, String methodName) {
|
||||
String fullMethodName = "name:[" + methodName + "] in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
||||
@@ -192,6 +132,7 @@ public class ReflectionUtils {
|
||||
* @param methodName 方法名
|
||||
* @param parameterTypes 方法参数类型数组
|
||||
* @return Method
|
||||
* @throws NoSuchMethodError 如果找不到方法
|
||||
*/
|
||||
public static Method findMethodBestMatch(Class<?> clazz, Class<?> returnType, String methodName, Class<?>... parameterTypes) {
|
||||
String fullMethodName = "name:[" + methodName + "] paramType:[" + getParametersString(parameterTypes) + "] in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
||||
@@ -210,6 +151,7 @@ public class ReflectionUtils {
|
||||
* @param clazz 构造类所在类
|
||||
* @param parameterTypes 构造类方法参数类型数组
|
||||
* @return Constructor
|
||||
* @throws NoSuchMethodError 如果找不到构造类
|
||||
*/
|
||||
public static Constructor<?> findConstructorExact(Class<?> clazz, Class<?>... parameterTypes) {
|
||||
String fullConstructorName = "paramType:[" + getParametersString(parameterTypes) + "in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
||||
|
Reference in New Issue
Block a user