Fix a bug and Merge code

This commit is contained in:
2022-03-18 02:06:43 +08:00
parent 3875a7d73c
commit 07e45dae89
15 changed files with 31 additions and 28 deletions

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/2. * 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 package com.highcapable.yukihookapi
@@ -57,6 +57,9 @@ object YukiHookAPI {
/** Xposed Hook API 方法体回调 */ /** Xposed Hook API 方法体回调 */
private var packageParamCallback: (PackageParam.() -> Unit)? = null private var packageParamCallback: (PackageParam.() -> Unit)? = null
/** 是否还未输出欢迎信息 */
private var isShowSplashLogOnceTime = true
/** 获取当前 [YukiHookAPI] 的版本 */ /** 获取当前 [YukiHookAPI] 的版本 */
const val API_VERSION_NAME = "1.0.4" const val API_VERSION_NAME = "1.0.4"
@@ -144,7 +147,7 @@ object YukiHookAPI {
appClassLoader = lpparam.classLoader, appClassLoader = lpparam.classLoader,
appInfo = lpparam.appInfo appInfo = lpparam.appInfo
) )
).apply { printHelloMsg() } ).apply { printSplashLog() }
) )
/** /**
@@ -159,7 +162,7 @@ object YukiHookAPI {
isLoadedFromBaseContext = false isLoadedFromBaseContext = false
if (hasXposedBridge) if (hasXposedBridge)
packageParamCallback = initiate packageParamCallback = initiate
else printNoXposedBridge() else printNoXposedEnvLog()
} }
/** /**
@@ -179,7 +182,7 @@ object YukiHookAPI {
hooker.forEach { it.assignInstance(packageParam = this) } hooker.forEach { it.assignInstance(packageParam = this) }
else yLoggerE(msg = "Failed to passing \"encase\" method because your hooker param is empty") 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) { fun encase(baseContext: Context?, initiate: PackageParam.() -> Unit) {
isLoadedFromBaseContext = true isLoadedFromBaseContext = true
if (hasXposedBridge) when {
(if (baseContext != null) initiate.invoke(baseContext.packagePararm.apply { printHelloMsg() })) hasXposedBridge && baseContext != null -> initiate.invoke(baseContext.packagePararm.apply { printSplashLog() })
else printNoXposedBridge() else -> printNoXposedEnvLog()
}
} }
/** /**
@@ -221,18 +225,19 @@ object YukiHookAPI {
if (hasXposedBridge) if (hasXposedBridge)
(if (baseContext != null) (if (baseContext != null)
if (hooker.isNotEmpty()) { if (hooker.isNotEmpty()) {
printHelloMsg() printSplashLog()
hooker.forEach { it.assignInstance(packageParam = baseContext.packagePararm) } hooker.forEach { it.assignInstance(packageParam = baseContext.packagePararm) }
} else yLoggerE(msg = "Failed to passing \"encase\" method because your hooker param is empty")) } else yLoggerE(msg = "Failed to passing \"encase\" method because your hooker param is empty"))
else printNoXposedBridge() else printNoXposedEnvLog()
} }
/** 输出找不到 [XposedBridge] 的错误日志 */ /** 输出找不到 [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() { private fun printSplashLog() {
if (Configs.isDebug) if (!Configs.isDebug || !isShowSplashLogOnceTime) return
isShowSplashLogOnceTime = false
yLoggerI(msg = "Welcome to YukiHookAPI $API_VERSION_NAME($API_VERSION_CODE)! Using Xposed API $hookingXposedApiVersion") yLoggerI(msg = "Welcome to YukiHookAPI $API_VERSION_NAME($API_VERSION_CODE)! Using Xposed API $hookingXposedApiVersion")
} }

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/2. * 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 package com.highcapable.yukihookapi.annotation

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/2. * 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 package com.highcapable.yukihookapi.annotation

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/2. * 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 package com.highcapable.yukihookapi.annotation

View File

@@ -25,8 +25,6 @@
* *
* This file is Created by fankes on 2022/2/3. * This file is Created by fankes on 2022/2/3.
*/ */
@file:Suppress("unused")
package com.highcapable.yukihookapi.annotation.xposed package com.highcapable.yukihookapi.annotation.xposed
import com.highcapable.yukihookapi.YukiHookAPI import com.highcapable.yukihookapi.YukiHookAPI

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/2. * 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 package com.highcapable.yukihookapi.hook.core

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/4. * 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 package com.highcapable.yukihookapi.hook.core.finder

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/4. * 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 package com.highcapable.yukihookapi.hook.core.finder

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/4. * 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 package com.highcapable.yukihookapi.hook.core.finder

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/2. * 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 package com.highcapable.yukihookapi.hook.factory

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/2. * 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 package com.highcapable.yukihookapi.hook.param

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/2. * 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 package com.highcapable.yukihookapi.hook.param

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/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 package com.highcapable.yukihookapi.hook.param.wrapper

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/5. * 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 package com.highcapable.yukihookapi.hook.utils

View File

@@ -26,7 +26,7 @@
* This file is Created by fankes on 2022/2/8. * This file is Created by fankes on 2022/2/8.
*/ */
@file:Suppress( @file:Suppress(
"OPT_IN_USAGE", "SetWorldReadable", "CommitPrefEdits", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE", "SetWorldReadable", "CommitPrefEdits",
"DEPRECATION", "WorldReadableFiles", "unused" "DEPRECATION", "WorldReadableFiles", "unused"
) )