mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 17:55:24 +08:00
...
This commit is contained in:
@@ -52,6 +52,17 @@ class YukiHookXposedProcessor : SymbolProcessorProvider {
|
||||
/** 插入 Xposed 尾部的名称 */
|
||||
private val xposedClassShortName = "_YukiHookXposedInit"
|
||||
|
||||
/**
|
||||
* 获取父类名称 - 只取最后一个
|
||||
* @return [String]
|
||||
*/
|
||||
private val KSClassDeclaration.superName
|
||||
get() = try {
|
||||
superTypes.last().element.toString()
|
||||
} catch (_: Exception) {
|
||||
""
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个环境方法体方便调用
|
||||
* @param env 方法体
|
||||
@@ -72,14 +83,16 @@ class YukiHookXposedProcessor : SymbolProcessorProvider {
|
||||
resolver.getSymbolsWithAnnotation(InjectYukiHookWithXposed::class.java.name)
|
||||
.asSequence()
|
||||
.filterIsInstance<KSClassDeclaration>().forEach {
|
||||
if (injectOnce) {
|
||||
injectAssets(
|
||||
codePath = (it.location as? FileLocation?)?.filePath ?: "",
|
||||
packageName = it.packageName.asString(),
|
||||
className = it.simpleName.asString()
|
||||
)
|
||||
injectClass(it.packageName.asString(), it.simpleName.asString())
|
||||
} else logger.error(message = "@InjectYukiHookWithXposed only can be use in once times")
|
||||
if (injectOnce)
|
||||
if (it.superName == "YukiHookXposedInitProxy") {
|
||||
injectAssets(
|
||||
codePath = (it.location as? FileLocation?)?.filePath ?: "",
|
||||
packageName = it.packageName.asString(),
|
||||
className = it.simpleName.asString()
|
||||
)
|
||||
injectClass(it.packageName.asString(), it.simpleName.asString())
|
||||
} else logger.error(message = "HookEntryClass \"${it.simpleName.asString()}\" must be implements YukiHookXposedInitProxy")
|
||||
else logger.error(message = "@InjectYukiHookWithXposed only can be use in once times")
|
||||
/** 仅处理第一个标记的类 - 再次处理将拦截并报错 */
|
||||
injectOnce = false
|
||||
}
|
||||
|
Reference in New Issue
Block a user