mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 09:45:19 +08:00
Merge code
This commit is contained in:
@@ -138,7 +138,7 @@ class YukiHookXposedProcessor : SymbolProcessorProvider {
|
||||
)
|
||||
injectClass(it.packageName.asString(), it.simpleName.asString(), modulePackageName)
|
||||
} 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
|
||||
}
|
||||
@@ -216,12 +216,12 @@ class YukiHookXposedProcessor : SymbolProcessorProvider {
|
||||
*/
|
||||
private fun injectClass(packageName: String, className: String, modulePackageName: String) =
|
||||
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 =
|
||||
modulePackageName.ifBlank {
|
||||
if (packageName.contains(".hook.") || packageName.endsWith(".hook"))
|
||||
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(
|
||||
Dependencies.ALL_FILES,
|
||||
|
@@ -99,7 +99,7 @@ class YukiHookCreater(private val packageParam: PackageParam, private val hookCl
|
||||
@YukiPrivateApi
|
||||
fun hook(): 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 {
|
||||
Thread {
|
||||
/** 延迟使得方法取到返回值 */
|
||||
|
@@ -230,7 +230,7 @@ class ConstructorFinder(
|
||||
)
|
||||
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()
|
||||
}
|
||||
} 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]
|
||||
* @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 实例的类对象
|
||||
@@ -271,8 +271,8 @@ class HookParam(private val createrInstance: YukiHookCreater, private val wrappe
|
||||
* @throws IllegalStateException 如果目标方法参数对象数组为空或 [index] 下标不存在
|
||||
*/
|
||||
fun <T> set(any: T?) {
|
||||
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 (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}")
|
||||
wrapper.setArgs(index, any)
|
||||
}
|
||||
|
||||
|
@@ -85,7 +85,7 @@ class YukiHookModulePrefs(private val context: Context? = null) {
|
||||
private fun checkApi() {
|
||||
if (YukiHookAPI.isLoadedFromBaseContext) error("YukiHookModulePrefs not allowed in Custom Hook API")
|
||||
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 {
|
||||
checkApi()
|
||||
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) {
|
||||
checkApi()
|
||||
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