diff --git a/docs-source/src/.vuepress/configs/template.ts b/docs-source/src/.vuepress/configs/template.ts index a1e20b4d..62e50936 100644 --- a/docs-source/src/.vuepress/configs/template.ts +++ b/docs-source/src/.vuepress/configs/template.ts @@ -53,6 +53,7 @@ const navigationLinks = { baseApiPath + 'hook/factory/ReflectionFactory', baseApiPath + 'hook/factory/YukiHookFactory', baseApiPath + 'hook/entity/YukiBaseHooker', + baseApiPath + 'hook/core/api/compat/type/ExecutorType', baseApiPath + 'hook/core/YukiMemberHookCreator', baseApiPath + 'hook/core/YukiResourcesHookCreator', baseApiPath + 'hook/core/finder/members/MethodFinder', diff --git a/docs-source/src/en/api/public/com/highcapable/yukihookapi/YukiHookAPI.md b/docs-source/src/en/api/public/com/highcapable/yukihookapi/YukiHookAPI.md index 61875b80..ae46a1e9 100644 --- a/docs-source/src/en/api/public/com/highcapable/yukihookapi/YukiHookAPI.md +++ b/docs-source/src/en/api/public/com/highcapable/yukihookapi/YukiHookAPI.md @@ -260,6 +260,26 @@ val name: String ::: +#### type - field + +```kotlin:no-line-numbers +val type: ExecutorType +``` + +**Change Records** + +`v1.1.9` `added` + +**Function Illustrate** + +> 获取当前 Hook Framework 类型。 + +::: warning + +在模块环境中需要启用 **Configs.isEnableHookModuleStatus**。 + +::: + #### apiLevel - field ```kotlin:no-line-numbers diff --git a/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.md b/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.md new file mode 100644 index 00000000..fbf29e18 --- /dev/null +++ b/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.md @@ -0,0 +1,115 @@ +--- +pageClass: code-page +--- + +::: warning + +The English translation of this page has not been completed, you are welcome to contribute translations to us. + +You can use the **Chrome Translation Plugin** to translate entire pages for reference. + +::: + +# ExecutorType - class + +```kotlin:no-line-numbers +enum class ExecutorType +``` + +**Change Records** + +`v1.1.9` `added` + +**Function Illustrate** + +> Hook Framework 类型定义。 + +定义了目前已知使用频率较高的 Hook Framework。 + +后期根据 Hook Framework 特征和使用情况将会继续添加新的类型。 + +无法识别的 Hook Framework 将被定义为 `UNKNOWN`。 + +## UNKNOWN - enum + +```kotlin:no-line-numbers +UNKNOWN +``` + +**Change Records** + +`v1.1.9` `added` + +**Function Illustrate** + +> 未知类型。 + +## XPOSED - enum + +```kotlin:no-line-numbers +XPOSED +``` + +**Change Records** + +`v1.1.9` `added` + +**Function Illustrate** + +> 原版、第三方 Xposed。 + +## LSPOSED_LSPATCH - enum + +```kotlin:no-line-numbers +LSPOSED_LSPATCH +``` + +**Change Records** + +`v1.1.9` `added` + +**Function Illustrate** + +> LSPosed、LSPatch。 + +## ED_XPOSED - enum + +```kotlin:no-line-numbers +ED_XPOSED +``` + +**Change Records** + +`v1.1.9` `added` + +**Function Illustrate** + +> EdXposed。 + +## TAICHI_XPOSED - enum + +```kotlin:no-line-numbers +TAICHI_XPOSED +``` + +**Change Records** + +`v1.1.9` `added` + +**Function Illustrate** + +> TaiChi (太极)。 + +## BUG_XPOSED - enum + +```kotlin:no-line-numbers +BUG_XPOSED +``` + +**Change Records** + +`v1.1.9` `added` + +**Function Illustrate** + +> BugXposed (应用转生)。 \ No newline at end of file diff --git a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/YukiHookAPI.md b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/YukiHookAPI.md index 2e23c88a..2fcf6e82 100644 --- a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/YukiHookAPI.md +++ b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/YukiHookAPI.md @@ -252,6 +252,26 @@ val name: String ::: +#### type - field + +```kotlin:no-line-numbers +val type: ExecutorType +``` + +**变更记录** + +`v1.1.9` `新增` + +**功能描述** + +> 获取当前 Hook Framework 类型。 + +::: warning + +在模块环境中需要启用 **Configs.isEnableHookModuleStatus**。 + +::: + #### apiLevel - field ```kotlin:no-line-numbers diff --git a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.md b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.md new file mode 100644 index 00000000..dd3d654a --- /dev/null +++ b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.md @@ -0,0 +1,107 @@ +--- +pageClass: code-page +--- + +# ExecutorType - class + +```kotlin:no-line-numbers +enum class ExecutorType +``` + +**变更记录** + +`v1.1.9` `新增` + +**功能描述** + +> Hook Framework 类型定义。 + +定义了目前已知使用频率较高的 Hook Framework。 + +后期根据 Hook Framework 特征和使用情况将会继续添加新的类型。 + +无法识别的 Hook Framework 将被定义为 `UNKNOWN`。 + +## UNKNOWN - enum + +```kotlin:no-line-numbers +UNKNOWN +``` + +**变更记录** + +`v1.1.9` `新增` + +**功能描述** + +> 未知类型。 + +## XPOSED - enum + +```kotlin:no-line-numbers +XPOSED +``` + +**变更记录** + +`v1.1.9` `新增` + +**功能描述** + +> 原版、第三方 Xposed。 + +## LSPOSED_LSPATCH - enum + +```kotlin:no-line-numbers +LSPOSED_LSPATCH +``` + +**变更记录** + +`v1.1.9` `新增` + +**功能描述** + +> LSPosed、LSPatch。 + +## ED_XPOSED - enum + +```kotlin:no-line-numbers +ED_XPOSED +``` + +**变更记录** + +`v1.1.9` `新增` + +**功能描述** + +> EdXposed。 + +## TAICHI_XPOSED - enum + +```kotlin:no-line-numbers +TAICHI_XPOSED +``` + +**变更记录** + +`v1.1.9` `新增` + +**功能描述** + +> TaiChi (太极)。 + +## BUG_XPOSED - enum + +```kotlin:no-line-numbers +BUG_XPOSED +``` + +**变更记录** + +`v1.1.9` `新增` + +**功能描述** + +> BugXposed (应用转生)。 \ No newline at end of file diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/YukiHookAPI.kt b/yukihookapi/src/main/java/com/highcapable/yukihookapi/YukiHookAPI.kt index 0a54a316..7d8c4ca3 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/YukiHookAPI.kt +++ b/yukihookapi/src/main/java/com/highcapable/yukihookapi/YukiHookAPI.kt @@ -39,6 +39,7 @@ import com.highcapable.yukihookapi.YukiHookAPI.encase import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed import com.highcapable.yukihookapi.hook.core.api.compat.HookApiCategoryHelper import com.highcapable.yukihookapi.hook.core.api.compat.HookApiProperty +import com.highcapable.yukihookapi.hook.core.api.compat.type.ExecutorType import com.highcapable.yukihookapi.hook.core.finder.members.ConstructorFinder import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder @@ -193,6 +194,14 @@ object YukiHookAPI { else -> YukiXposedModuleStatus.executorName } + /** + * 获取当前 Hook Framework 类型 + * + * - ❗在模块环境中需要启用 [Configs.isEnableHookModuleStatus] + * @return [ExecutorType] + */ + val type get() = HookApiProperty.type.takeIf { isXposedEnvironment } ?: HookApiProperty.type(YukiXposedModuleStatus.executorName) + /** * 获取当前 Hook Framework 的 API 版本 * diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiProperty.kt b/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiProperty.kt index c17f48ef..654c8ccb 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiProperty.kt +++ b/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiProperty.kt @@ -29,6 +29,7 @@ package com.highcapable.yukihookapi.hook.core.api.compat +import com.highcapable.yukihookapi.hook.core.api.compat.type.ExecutorType import com.highcapable.yukihookapi.hook.factory.classOf import com.highcapable.yukihookapi.hook.factory.field import com.highcapable.yukihookapi.hook.factory.hasClass @@ -40,6 +41,15 @@ import de.robv.android.xposed.XposedBridge */ internal object HookApiProperty { + /** Xposed 框架名称 */ + internal const val XPOSED_NAME = "Xposed" + + /** LSPosed 框架名称 */ + internal const val LSPOSED_NAME = "LSPosed" + + /** EdXposed 框架名称 */ + internal const val ED_XPOSED_NAME = "EdXposed" + /** TaiChi (太极) Xposed 框架名称 */ internal const val TAICHI_XPOSED_NAME = "TaiChi" @@ -69,6 +79,26 @@ internal object HookApiProperty { HookApiCategory.UNKNOWN -> "unknown" } + /** + * 获取当前 Hook Framework 类型 + * @return [ExecutorType] + */ + internal val type get() = type() + + /** + * 获取当前 Hook Framework 类型 + * @param executorName Hook Framework 名称 - 默认为 [name] + * @return [ExecutorType] + */ + internal fun type(executorName: String = name) = when (executorName) { + BUG_XPOSED_NAME -> ExecutorType.BUG_XPOSED + TAICHI_XPOSED_NAME -> ExecutorType.TAICHI_XPOSED + ED_XPOSED_NAME -> ExecutorType.ED_XPOSED + LSPOSED_NAME -> ExecutorType.LSPOSED_LSPATCH + XPOSED_NAME -> ExecutorType.XPOSED + else -> ExecutorType.UNKNOWN + } + /** * 获取当前 Hook Framework 的 API 版本 * @return [Int] 无法获取会返回 -1 diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.kt b/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.kt new file mode 100644 index 00000000..414b1f68 --- /dev/null +++ b/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.kt @@ -0,0 +1,57 @@ +/* + * YukiHookAPI - An efficient Hook API and Xposed Module solution built in Kotlin. + * Copyright (C) 2019-2023 HighCapable + * https://github.com/fankes/YukiHookAPI + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This file is Created by fankes on 2023/4/16. + */ +package com.highcapable.yukihookapi.hook.core.api.compat.type + +/** + * Hook Framework 类型定义 + * + * 定义了目前已知使用频率较高的 Hook Framework + * + * 后期根据 Hook Framework 特征和使用情况将会继续添加新的类型 + * + * 无法识别的 Hook Framework 将被定义为 [UNKNOWN] + */ +enum class ExecutorType { + /** 未知类型 */ + UNKNOWN, + + /** 原版、第三方 Xposed */ + XPOSED, + + /** LSPosed、LSPatch */ + LSPOSED_LSPATCH, + + /** EdXposed */ + ED_XPOSED, + + /** TaiChi (太极) */ + TAICHI_XPOSED, + + /** BugXposed (应用转生) */ + BUG_XPOSED +} \ No newline at end of file