From 07e45dae89838a833b0fb912a5a5697bac88b050 Mon Sep 17 00:00:00 2001 From: Fankesyooni Date: Fri, 18 Mar 2022 02:06:43 +0800 Subject: [PATCH] Fix a bug and Merge code --- .../highcapable/yukihookapi/YukiHookAPI.kt | 31 +++++++++++-------- .../yukihookapi/annotation/DoNotUseClass.kt | 2 +- .../yukihookapi/annotation/DoNotUseField.kt | 2 +- .../yukihookapi/annotation/DoNotUseMethod.kt | 2 +- .../xposed/InjectYukiHookWithXposed.kt | 2 -- .../yukihookapi/hook/core/YukiHookCreater.kt | 2 +- .../hook/core/finder/ConstructorFinder.kt | 2 +- .../hook/core/finder/FieldFinder.kt | 2 +- .../hook/core/finder/MethodFinder.kt | 2 +- .../hook/factory/ReflectionFactory.kt | 2 +- .../yukihookapi/hook/param/HookParam.kt | 2 +- .../yukihookapi/hook/param/PackageParam.kt | 2 +- .../hook/param/wrapper/PackageParamWrapper.kt | 2 +- .../yukihookapi/hook/utils/UtilsFactory.kt | 2 +- .../hook/xposed/prefs/YukiHookModulePrefs.kt | 2 +- 15 files changed, 31 insertions(+), 28 deletions(-) diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/YukiHookAPI.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/YukiHookAPI.kt index 9de6997c..b3bc6ad4 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/YukiHookAPI.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/YukiHookAPI.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/2. */ -@file:Suppress("MemberVisibilityCanBePrivate", "unused", "OPT_IN_USAGE") +@file:Suppress("MemberVisibilityCanBePrivate", "unused", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE") package com.highcapable.yukihookapi @@ -57,6 +57,9 @@ object YukiHookAPI { /** Xposed Hook API 方法体回调 */ private var packageParamCallback: (PackageParam.() -> Unit)? = null + /** 是否还未输出欢迎信息 */ + private var isShowSplashLogOnceTime = true + /** 获取当前 [YukiHookAPI] 的版本 */ const val API_VERSION_NAME = "1.0.4" @@ -144,7 +147,7 @@ object YukiHookAPI { appClassLoader = lpparam.classLoader, appInfo = lpparam.appInfo ) - ).apply { printHelloMsg() } + ).apply { printSplashLog() } ) /** @@ -159,7 +162,7 @@ object YukiHookAPI { isLoadedFromBaseContext = false if (hasXposedBridge) packageParamCallback = initiate - else printNoXposedBridge() + else printNoXposedEnvLog() } /** @@ -179,7 +182,7 @@ object YukiHookAPI { hooker.forEach { it.assignInstance(packageParam = this) } else yLoggerE(msg = "Failed to passing \"encase\" method because your hooker param is empty") } - else printNoXposedBridge() + else printNoXposedEnvLog() } /** @@ -197,9 +200,10 @@ object YukiHookAPI { */ fun encase(baseContext: Context?, initiate: PackageParam.() -> Unit) { isLoadedFromBaseContext = true - if (hasXposedBridge) - (if (baseContext != null) initiate.invoke(baseContext.packagePararm.apply { printHelloMsg() })) - else printNoXposedBridge() + when { + hasXposedBridge && baseContext != null -> initiate.invoke(baseContext.packagePararm.apply { printSplashLog() }) + else -> printNoXposedEnvLog() + } } /** @@ -221,19 +225,20 @@ object YukiHookAPI { if (hasXposedBridge) (if (baseContext != null) if (hooker.isNotEmpty()) { - printHelloMsg() + printSplashLog() hooker.forEach { it.assignInstance(packageParam = baseContext.packagePararm) } } else yLoggerE(msg = "Failed to passing \"encase\" method because your hooker param is empty")) - else printNoXposedBridge() + else printNoXposedEnvLog() } /** 输出找不到 [XposedBridge] 的错误日志 */ - private fun printNoXposedBridge() = yLoggerE(msg = "Could not found XposedBridge in current space! Aborted") + private fun printNoXposedEnvLog() = yLoggerE(msg = "Could not found XposedBridge in current space! Aborted") /** 输出欢迎信息调试日志 */ - private fun printHelloMsg() { - if (Configs.isDebug) - yLoggerI(msg = "Welcome to YukiHookAPI $API_VERSION_NAME($API_VERSION_CODE)! Using Xposed API $hookingXposedApiVersion") + private fun printSplashLog() { + if (!Configs.isDebug || !isShowSplashLogOnceTime) return + isShowSplashLogOnceTime = false + yLoggerI(msg = "Welcome to YukiHookAPI $API_VERSION_NAME($API_VERSION_CODE)! Using Xposed API $hookingXposedApiVersion") } /** diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseClass.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseClass.kt index 0f6d5a54..491db631 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseClass.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseClass.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/2. */ -@file:Suppress("OPT_IN_IS_NOT_ENABLED") +@file:Suppress("OPT_IN_IS_NOT_ENABLED", "EXPERIMENTAL_IS_NOT_ENABLED") package com.highcapable.yukihookapi.annotation diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseField.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseField.kt index 1708d8e7..369c80a3 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseField.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseField.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/2. */ -@file:Suppress("OPT_IN_IS_NOT_ENABLED") +@file:Suppress("OPT_IN_IS_NOT_ENABLED", "EXPERIMENTAL_IS_NOT_ENABLED") package com.highcapable.yukihookapi.annotation diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseMethod.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseMethod.kt index 63e5aaa2..db2aa3d9 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseMethod.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/DoNotUseMethod.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/2. */ -@file:Suppress("OPT_IN_IS_NOT_ENABLED") +@file:Suppress("OPT_IN_IS_NOT_ENABLED", "EXPERIMENTAL_IS_NOT_ENABLED") package com.highcapable.yukihookapi.annotation diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/xposed/InjectYukiHookWithXposed.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/xposed/InjectYukiHookWithXposed.kt index 1c41a5db..f7555e19 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/xposed/InjectYukiHookWithXposed.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/annotation/xposed/InjectYukiHookWithXposed.kt @@ -25,8 +25,6 @@ * * This file is Created by fankes on 2022/2/3. */ -@file:Suppress("unused") - package com.highcapable.yukihookapi.annotation.xposed import com.highcapable.yukihookapi.YukiHookAPI diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/YukiHookCreater.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/YukiHookCreater.kt index 297ed5fc..c91d34e3 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/YukiHookCreater.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/YukiHookCreater.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/2. */ -@file:Suppress("MemberVisibilityCanBePrivate", "unused", "OPT_IN_USAGE") +@file:Suppress("MemberVisibilityCanBePrivate", "unused", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE") package com.highcapable.yukihookapi.hook.core diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/ConstructorFinder.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/ConstructorFinder.kt index 0a33ceac..758ab6ad 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/ConstructorFinder.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/ConstructorFinder.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/4. */ -@file:Suppress("unused", "OPT_IN_USAGE", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST") +@file:Suppress("unused", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST") package com.highcapable.yukihookapi.hook.core.finder diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/FieldFinder.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/FieldFinder.kt index 0a951b01..ccdbe8b8 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/FieldFinder.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/FieldFinder.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/4. */ -@file:Suppress("unused", "UNCHECKED_CAST", "MemberVisibilityCanBePrivate", "OPT_IN_USAGE") +@file:Suppress("unused", "UNCHECKED_CAST", "MemberVisibilityCanBePrivate", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE") package com.highcapable.yukihookapi.hook.core.finder diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/MethodFinder.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/MethodFinder.kt index 9d0a3fa5..b9ccb32d 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/MethodFinder.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/finder/MethodFinder.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/4. */ -@file:Suppress("unused", "MemberVisibilityCanBePrivate", "OPT_IN_USAGE", "UNCHECKED_CAST") +@file:Suppress("unused", "MemberVisibilityCanBePrivate", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE", "UNCHECKED_CAST") package com.highcapable.yukihookapi.hook.core.finder diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt index a780fabc..8fbf2d0d 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/2. */ -@file:Suppress("unused", "OPT_IN_USAGE") +@file:Suppress("unused", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE") package com.highcapable.yukihookapi.hook.factory diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/HookParam.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/HookParam.kt index 81cf51fc..5f0e03ec 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/HookParam.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/HookParam.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/2. */ -@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "OPT_IN_USAGE") +@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE") package com.highcapable.yukihookapi.hook.param diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/PackageParam.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/PackageParam.kt index 69cb9192..a16d3e56 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/PackageParam.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/PackageParam.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/2. */ -@file:Suppress("unused", "MemberVisibilityCanBePrivate", "OPT_IN_USAGE") +@file:Suppress("unused", "MemberVisibilityCanBePrivate", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE") package com.highcapable.yukihookapi.hook.param diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/wrapper/PackageParamWrapper.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/wrapper/PackageParamWrapper.kt index 766ff890..90a50420 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/wrapper/PackageParamWrapper.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/param/wrapper/PackageParamWrapper.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/7. */ -@file:Suppress("unused", "MemberVisibilityCanBePrivate", "OPT_IN_USAGE") +@file:Suppress("unused", "MemberVisibilityCanBePrivate", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE") package com.highcapable.yukihookapi.hook.param.wrapper diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt index a89bd4f0..b84b91fd 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/5. */ -@file:Suppress("OPT_IN_USAGE") +@file:Suppress("OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE") package com.highcapable.yukihookapi.hook.utils diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookModulePrefs.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookModulePrefs.kt index 8cd75c59..b109e90b 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookModulePrefs.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookModulePrefs.kt @@ -26,7 +26,7 @@ * This file is Created by fankes on 2022/2/8. */ @file:Suppress( - "OPT_IN_USAGE", "SetWorldReadable", "CommitPrefEdits", + "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE", "SetWorldReadable", "CommitPrefEdits", "DEPRECATION", "WorldReadableFiles", "unused" )