mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 02:35:40 +08:00
Merge code
This commit is contained in:
@@ -138,7 +138,7 @@ class YukiHookXposedProcessor : SymbolProcessorProvider {
|
|||||||
)
|
)
|
||||||
injectClass(it.packageName.asString(), it.simpleName.asString(), modulePackageName)
|
injectClass(it.packageName.asString(), it.simpleName.asString(), modulePackageName)
|
||||||
} else error(msg = "HookEntryClass \"${it.simpleName.asString()}\" must be implements YukiHookXposedInitProxy")
|
} else error(msg = "HookEntryClass \"${it.simpleName.asString()}\" must be implements YukiHookXposedInitProxy")
|
||||||
else error(msg = "@InjectYukiHookWithXposed only can be use in once times")
|
else error(msg = "\"@InjectYukiHookWithXposed\" only can be use in once times")
|
||||||
/** 仅处理第一个标记的类 - 再次处理将拦截并报错 */
|
/** 仅处理第一个标记的类 - 再次处理将拦截并报错 */
|
||||||
injectOnce = false
|
injectOnce = false
|
||||||
}
|
}
|
||||||
@@ -216,12 +216,12 @@ class YukiHookXposedProcessor : SymbolProcessorProvider {
|
|||||||
*/
|
*/
|
||||||
private fun injectClass(packageName: String, className: String, modulePackageName: String) =
|
private fun injectClass(packageName: String, className: String, modulePackageName: String) =
|
||||||
environment(ignoredError = true) {
|
environment(ignoredError = true) {
|
||||||
if (modulePackageName.isNotBlank()) warn(msg = "You set the customize module package name to \"$modulePackageName\",please check for yourself if it is correct")
|
if (modulePackageName.isNotBlank()) warn(msg = "You set the customize module package name to \"$modulePackageName\", please check for yourself if it is correct")
|
||||||
val realPackageName =
|
val realPackageName =
|
||||||
modulePackageName.ifBlank {
|
modulePackageName.ifBlank {
|
||||||
if (packageName.contains(".hook.") || packageName.endsWith(".hook"))
|
if (packageName.contains(".hook.") || packageName.endsWith(".hook"))
|
||||||
packageName.split(".hook")[0]
|
packageName.split(".hook")[0]
|
||||||
else error(msg = "Cannot identify your App's package name,please manually configure the package name")
|
else error(msg = "Cannot identify your App's package name, please manually configure the package name")
|
||||||
}
|
}
|
||||||
codeGenerator.createNewFile(
|
codeGenerator.createNewFile(
|
||||||
Dependencies.ALL_FILES,
|
Dependencies.ALL_FILES,
|
||||||
|
@@ -99,7 +99,7 @@ class YukiHookCreater(private val packageParam: PackageParam, private val hookCl
|
|||||||
@YukiPrivateApi
|
@YukiPrivateApi
|
||||||
fun hook(): Result {
|
fun hook(): Result {
|
||||||
if (YukiHookAPI.hasXposedBridge.not()) return Result()
|
if (YukiHookAPI.hasXposedBridge.not()) return Result()
|
||||||
return if (hookMembers.isEmpty()) error("Hook Members is empty,hook aborted")
|
return if (hookMembers.isEmpty()) error("Hook Members is empty, hook aborted")
|
||||||
else Result().also {
|
else Result().also {
|
||||||
Thread {
|
Thread {
|
||||||
/** 延迟使得方法取到返回值 */
|
/** 延迟使得方法取到返回值 */
|
||||||
|
@@ -230,7 +230,7 @@ class ConstructorFinder(
|
|||||||
)
|
)
|
||||||
remedyPlans.clear()
|
remedyPlans.clear()
|
||||||
}
|
}
|
||||||
} else yLoggerW(msg = "RemedyPlan is empty,forgot it? [${hookTag}]")
|
} else yLoggerW(msg = "RemedyPlan is empty, forgot it? [${hookTag}]")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -279,7 +279,7 @@ class MethodFinder(
|
|||||||
)
|
)
|
||||||
remedyPlans.clear()
|
remedyPlans.clear()
|
||||||
}
|
}
|
||||||
} else yLoggerW(msg = "RemedyPlan is empty,forgot it? [${hookTag}]")
|
} else yLoggerW(msg = "RemedyPlan is empty, forgot it? [${hookTag}]")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -69,7 +69,7 @@ class HookParam(private val createrInstance: YukiHookCreater, private val wrappe
|
|||||||
* @return [Any]
|
* @return [Any]
|
||||||
* @throws IllegalStateException 如果对象为空
|
* @throws IllegalStateException 如果对象为空
|
||||||
*/
|
*/
|
||||||
val instance get() = wrapper.instance ?: error("HookParam instance got null,Is this a static member?")
|
val instance get() = wrapper.instance ?: error("HookParam instance got null! Is this a static member?")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前 Hook 实例的类对象
|
* 获取当前 Hook 实例的类对象
|
||||||
@@ -271,8 +271,8 @@ class HookParam(private val createrInstance: YukiHookCreater, private val wrappe
|
|||||||
* @throws IllegalStateException 如果目标方法参数对象数组为空或 [index] 下标不存在
|
* @throws IllegalStateException 如果目标方法参数对象数组为空或 [index] 下标不存在
|
||||||
*/
|
*/
|
||||||
fun <T> set(any: T?) {
|
fun <T> set(any: T?) {
|
||||||
if (args.isEmpty()) error("HookParam method args is empty,mabe not has args")
|
if (args.isEmpty()) error("HookParam method args is empty, mabe not has args")
|
||||||
if (index > args.lastIndex) error("HookParam method args index out of bounds,max is ${args.lastIndex}")
|
if (index > args.lastIndex) error("HookParam method args index out of bounds, max is ${args.lastIndex}")
|
||||||
wrapper.setArgs(index, any)
|
wrapper.setArgs(index, any)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -85,7 +85,7 @@ class YukiHookModulePrefs(private val context: Context? = null) {
|
|||||||
private fun checkApi() {
|
private fun checkApi() {
|
||||||
if (YukiHookAPI.isLoadedFromBaseContext) error("YukiHookModulePrefs not allowed in Custom Hook API")
|
if (YukiHookAPI.isLoadedFromBaseContext) error("YukiHookModulePrefs not allowed in Custom Hook API")
|
||||||
if (YukiHookAPI.hasXposedBridge && YukiHookXposedBridge.modulePackageName.isBlank())
|
if (YukiHookAPI.hasXposedBridge && YukiHookXposedBridge.modulePackageName.isBlank())
|
||||||
error("Xposed modulePackageName load failed,please reset and rebuild it")
|
error("Xposed modulePackageName load failed, please reset and rebuild it")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,11 +107,11 @@ class YukiHookModulePrefs(private val context: Context? = null) {
|
|||||||
get() = try {
|
get() = try {
|
||||||
checkApi()
|
checkApi()
|
||||||
context?.getSharedPreferences(prefsName, Context.MODE_WORLD_READABLE)
|
context?.getSharedPreferences(prefsName, Context.MODE_WORLD_READABLE)
|
||||||
?: error("If you want to use module prefs,you must set the context instance first")
|
?: error("If you want to use module prefs, you must set the context instance first")
|
||||||
} catch (_: Throwable) {
|
} catch (_: Throwable) {
|
||||||
checkApi()
|
checkApi()
|
||||||
context?.getSharedPreferences(prefsName, Context.MODE_PRIVATE)
|
context?.getSharedPreferences(prefsName, Context.MODE_PRIVATE)
|
||||||
?: error("If you want to use module prefs,you must set the context instance first")
|
?: error("If you want to use module prefs, you must set the context instance first")
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置全局可读可写 */
|
/** 设置全局可读可写 */
|
||||||
|
Reference in New Issue
Block a user