Modify optimize code style

This commit is contained in:
2022-12-29 23:41:40 +08:00
parent d2042daf5f
commit 6eab7127ca
5 changed files with 6 additions and 4 deletions

View File

@@ -25,6 +25,8 @@
* *
* This file is Created by fankes on 2022/9/20. * This file is Created by fankes on 2022/9/20.
*/ */
@file:Suppress("unused")
package com.highcapable.yukihookapi.hook.bean package com.highcapable.yukihookapi.hook.bean
import java.lang.reflect.ParameterizedType import java.lang.reflect.ParameterizedType

View File

@@ -236,7 +236,7 @@ internal object ReflectionTool {
} }
findDexClassList(loaderSet).takeIf { it.isNotEmpty() }?.forEach { className -> findDexClassList(loaderSet).takeIf { it.isNotEmpty() }?.forEach { className ->
/** 分离包名 → com.demo.Test → com.demo (获取最后一个 "." + 简单类名的长度) → 由于末位存在 "." 最后要去掉 1 个长度 */ /** 分离包名 → com.demo.Test → com.demo (获取最后一个 "." + 简单类名的长度) → 由于末位存在 "." 最后要去掉 1 个长度 */
(if (className.contains(other = ".")) (if (className.contains("."))
className.substring(0, className.length - className.split(".").let { it[it.lastIndex] }.length - 1) className.substring(0, className.length - className.split(".").let { it[it.lastIndex] }.length - 1)
else className).also { packageName -> else className).also { packageName ->
if ((fromPackages.isEmpty() || fromPackages.any { if ((fromPackages.isEmpty() || fromPackages.any {

View File

@@ -411,7 +411,7 @@ inline fun Class<*>.allFields(result: (index: Int, field: Field) -> Unit) =
@PublishedApi @PublishedApi
internal fun Class<*>.checkingInternal() { internal fun Class<*>.checkingInternal() {
if (name == classOf<YukiHookModuleStatus>().name) return if (name == classOf<YukiHookModuleStatus>().name) return
if (name == classOf<YukiHookAPI>().name || name.startsWith(prefix = "com.highcapable.yukihookapi.hook")) throw RuntimeException( if (name == classOf<YukiHookAPI>().name || name.startsWith("com.highcapable.yukihookapi.hook")) throw RuntimeException(
"!!!DO NOT ALLOWED!!! You cannot hook or reflection to call the internal class of the YukiHookAPI itself, " + "!!!DO NOT ALLOWED!!! You cannot hook or reflection to call the internal class of the YukiHookAPI itself, " +
"The called class is [$this]" "The called class is [$this]"
) )

View File

@@ -143,7 +143,7 @@ internal object AppParasitics {
if (YukiHookAPI.Configs.isEnableHookSharedPreferences && type == HookEntryType.PACKAGE) if (YukiHookAPI.Configs.isEnableHookSharedPreferences && type == HookEntryType.PACKAGE)
YukiHookHelper.hook(ContextImplClass.method { name = "setFilePermissionsFromMode" }, object : YukiMemberHook() { YukiHookHelper.hook(ContextImplClass.method { name = "setFilePermissionsFromMode" }, object : YukiMemberHook() {
override fun beforeHookedMember(param: Param) { override fun beforeHookedMember(param: Param) {
if ((param.args?.get(0) as? String?)?.endsWith(suffix = "preferences.xml") == true) param.args?.set(1, 1) if ((param.args?.get(0) as? String?)?.endsWith("preferences.xml") == true) param.args?.set(1, 1)
} }
}) })
if (YukiHookAPI.Configs.isEnableHookModuleStatus) classOf<YukiHookModuleStatus>(loader).apply { if (YukiHookAPI.Configs.isEnableHookModuleStatus) classOf<YukiHookModuleStatus>(loader).apply {

View File

@@ -82,7 +82,7 @@ internal class HandlerDelegate private constructor(private val baseInstance: Han
EXECUTE_TRANSACTION -> msg.obj?.runCatching client@{ EXECUTE_TRANSACTION -> msg.obj?.runCatching client@{
ClientTransactionClass.method { name = "getCallbacks" }.ignored().get(this).list<Any?>().takeIf { it.isNotEmpty() } ClientTransactionClass.method { name = "getCallbacks" }.ignored().get(this).list<Any?>().takeIf { it.isNotEmpty() }
?.forEach { item -> ?.forEach { item ->
item?.current(ignored = true)?.takeIf { it.name.contains(other = "LaunchActivityItem") }?.field { name = "mIntent" } item?.current(ignored = true)?.takeIf { it.name.contains("LaunchActivityItem") }?.field { name = "mIntent" }
?.apply { ?.apply {
cast<Intent?>()?.also { intent -> cast<Intent?>()?.also { intent ->
IntentClass.field { name = "mExtras" }.ignored().get(intent).cast<Bundle?>() IntentClass.field { name = "mExtras" }.ignored().get(intent).cast<Bundle?>()