Fix when classSet and loaderSet is null still print logcat problem in MemberBaseFinder, ClassBaseFinder

This commit is contained in:
2022-09-21 20:05:02 +08:00
parent f6e905ef5a
commit c5fa51456e
6 changed files with 20 additions and 4 deletions

View File

@@ -39,6 +39,12 @@ import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge
*/ */
abstract class ClassBaseFinder internal constructor(internal open val loaderSet: ClassLoader? = null) : BaseFinder() { abstract class ClassBaseFinder internal constructor(internal open val loaderSet: ClassLoader? = null) : BaseFinder() {
internal companion object {
/** [loaderSet] 为 null 的提示 */
internal const val LOADERSET_IS_NULL = "loaderSet is null"
}
/** 当前找到的 [Class] 数组 */ /** 当前找到的 [Class] 数组 */
internal var classInstances = HashSet<Class<*>>() internal var classInstances = HashSet<Class<*>>()
@@ -67,6 +73,8 @@ abstract class ClassBaseFinder internal constructor(internal open val loaderSet:
*/ */
internal fun onFailureMsg(throwable: Throwable? = null) { internal fun onFailureMsg(throwable: Throwable? = null) {
if (isShutErrorPrinting) return if (isShutErrorPrinting) return
/** 判断是否为 [LOADERSET_IS_NULL] */
if (throwable?.message == LOADERSET_IS_NULL) return
yLoggerE(msg = "NoClassDefFound happend in [$loaderSet]", e = throwable) yLoggerE(msg = "NoClassDefFound happend in [$loaderSet]", e = throwable)
} }

View File

@@ -54,6 +54,12 @@ abstract class MemberBaseFinder internal constructor(
internal open val classSet: Class<*>? = null internal open val classSet: Class<*>? = null
) : BaseFinder() { ) : BaseFinder() {
internal companion object {
/** [classSet] 为 null 的提示 */
internal const val CLASSSET_IS_NULL = "classSet is null"
}
/** 是否使用了重查找功能 */ /** 是否使用了重查找功能 */
@PublishedApi @PublishedApi
internal var isUsingRemedyPlan = false internal var isUsingRemedyPlan = false
@@ -121,6 +127,8 @@ abstract class MemberBaseFinder internal constructor(
if (isNotIgnoredNoSuchMemberFailure && isUsingRemedyPlan.not() && isShutErrorPrinting.not()) if (isNotIgnoredNoSuchMemberFailure && isUsingRemedyPlan.not() && isShutErrorPrinting.not())
loggingContent = Pair(msg, throwable) loggingContent = Pair(msg, throwable)
} }
/** 判断是否为 [CLASSSET_IS_NULL] */
if (throwable?.message == CLASSSET_IS_NULL) return
/** 判断绑定到 Hooker 时仅创建日志 */ /** 判断绑定到 Hooker 时仅创建日志 */
if (isBindToHooker) return await { build() }.unit() if (isBindToHooker) return await { build() }.unit()
/** 判断始终输出日志或等待结果后输出日志 */ /** 判断始终输出日志或等待结果后输出日志 */

View File

@@ -494,7 +494,7 @@ class DexClassFinder @PublishedApi internal constructor(
} }
} else startProcess() } else startProcess()
} }
} else Result(isNotFound = true, Throwable("loaderSet is null")).await { onFailureMsg() } } else Result(isNotFound = true, Throwable(LOADERSET_IS_NULL)).await { onFailureMsg() }
}.getOrElse { e -> Result(isNotFound = true, e).await { onFailureMsg(throwable = e) } } }.getOrElse { e -> Result(isNotFound = true, e).await { onFailureMsg(throwable = e) } }
/** /**

View File

@@ -237,7 +237,7 @@ class ConstructorFinder @PublishedApi internal constructor(
* @param isBind 是否将结果设置到目标 [YukiMemberHookCreator.MemberHookCreator] * @param isBind 是否将结果设置到目标 [YukiMemberHookCreator.MemberHookCreator]
*/ */
private fun build(isBind: Boolean) { private fun build(isBind: Boolean) {
if (classSet == null) error("classSet is null") if (classSet == null) error(CLASSSET_IS_NULL)
classSet.checkingInternal() classSet.checkingInternal()
runBlocking { runBlocking {
isBindToHooker = isBind isBindToHooker = isBind

View File

@@ -196,7 +196,7 @@ class FieldFinder @PublishedApi internal constructor(
memberInstances.takeIf { it.isNotEmpty() }?.forEach { onDebuggingMsg(msg = "Find Field [$it] takes ${ms}ms [${hookTag}]") } memberInstances.takeIf { it.isNotEmpty() }?.forEach { onDebuggingMsg(msg = "Find Field [$it] takes ${ms}ms [${hookTag}]") }
} }
Result() Result()
} else Result(isNoSuch = true, Throwable("classSet is null")) } else Result(isNoSuch = true, Throwable(CLASSSET_IS_NULL))
}.getOrElse { e -> Result(isNoSuch = true, e).await { onFailureMsg(throwable = e) } } }.getOrElse { e -> Result(isNoSuch = true, e).await { onFailureMsg(throwable = e) } }
@YukiPrivateApi @YukiPrivateApi

View File

@@ -309,7 +309,7 @@ class MethodFinder @PublishedApi internal constructor(
* @param isBind 是否将结果设置到目标 [YukiMemberHookCreator.MemberHookCreator] * @param isBind 是否将结果设置到目标 [YukiMemberHookCreator.MemberHookCreator]
*/ */
private fun build(isBind: Boolean) { private fun build(isBind: Boolean) {
if (classSet == null) error("classSet is null") if (classSet == null) error(CLASSSET_IS_NULL)
classSet.checkingInternal() classSet.checkingInternal()
runBlocking { runBlocking {
isBindToHooker = isBind isBindToHooker = isBind