Update example documentation

This commit is contained in:
2023-04-16 20:57:05 +08:00
parent 404bbfa4eb
commit f8eefd58fd
2 changed files with 89 additions and 15 deletions

View File

@@ -618,13 +618,19 @@ override fun onHook() = encase {
}
```
## Xposed Module own Active State
## Xposed Module Status
Usually, we choose to write a method that return `false`, and then Hook this method to return `true` to prove that the Hook has taken effect.
Usually, the developer of the Xposed Module will choose to read the activation information of the current Xposed Module to better show the user the effective status of the current function.
In `YukiHookAPI`, you don't need to do this at all. `YukiHookAPI` has already encapsulated this operation for you, and you can use it directly.
In addition to the basic Hook functions, `YukiHookAPI` also designed a set of Xposed Module status judgment functions for developers, such as activation status and Hook Framework information.
Now, you can use `YukiHookAPI.Status.isXposedModuleActive` directly in the Module App to determine whether it is active.
### Determine Self-activation Status
Usually, we will choose to write a method to make it return `false`, and then hook this method to make it return `true` to prove that the Hook has taken effect.
In `YukiHookAPI`, you dont need to do this at all, `YukiHookAPI` has already encapsulated this operation for you, and you can use it directly.
Now, you can directly use `YukiHookAPI.Status.isXposedModuleActive` to determine whether it is activated in the Module App.
> The following example
@@ -634,9 +640,9 @@ if(YukiHookAPI.Status.isXposedModuleActive) {
}
```
Due to some special reasons, Module Apps in TaiChi and Wuji cannot use standard methods to detect the activation state.
Due to some special reasons, the Xposed Modules in TaiChi and Wuji cannot use the standard method to detect the activation state.
At this point, you can use `YukiHookAPI.Status.isTaiChiModuleActive` to determine whether it is activated.
At this point you can use `YukiHookAPI.Status.isTaiChiModuleActive` to determine whether it is activated.
> The following example
@@ -648,7 +654,7 @@ if(YukiHookAPI.Status.isTaiChiModuleActive) {
If you want to use both judgment schemes, `YukiHookAPI` also encapsulates a convenient way for you.
At this point, you can use `YukiHookAPI.Status.isModuleActive` to determine whether you are activated in Xposed or TaiChi and Promise.
At this point, you can use `YukiHookAPI.Status.isModuleActive` to determine whether you are activated in Xposed or TaiChi and Wuji.
> The following example
@@ -666,7 +672,7 @@ For more functions, please refer to [YukiHookAPI.Status](../api/public/com/highc
::: warning
If your Module App's API version is higher than 29 and is running on a system whose target API is 29 or higher, you need to add the following permission statement in **AndroidManifest.xml** to judge the activation status of the Module App in TaiChi and Wuji.
If your Module App's API version is higher than 29 and is running on a system whose target API is 29 or higher, you need to add the following permission statement in **AndroidManifest.xml** to judge the activation status of the module in TaiChi and Wuji.
> The following example
@@ -686,12 +692,44 @@ There is another solution, you can directly declare the **android.permission.QUE
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
```
If the activation state of TaiChi and Wuji is included in the Module App activation judgment, the **Application** of the Module App must be extends **ModuleApplication** or **ModuleApplication** must be used directly;
If the activation status of TaiChi and Wuji is included in the Module App activation judgment, the **Application** of the Module App must be extends from **ModuleApplication** or directly use **ModuleApplication**.
The API after **1.0.91** has modified the activation logic judgment method, now you can use this API in the Module App and Host App at the same time;
:::
### Get Hook Framework Information
In addition to judging your own activation status, you can also get information about the current Hook Framework through the `Executor` in `YukiHookAPI.Status`.
For example, we can use `YukiHookAPI.Status.Executor.name` to get the name of the current Hook Framework.
> The following example
```kotlin
val frameworkName = YukiHookAPI.Status.Executor.name
```
We can also use `YukiHookAPI.Status.Executor.apiLevel` to get the API Level of the current Hook Framework.
> The following example
```kotlin
val frameworkApiLevel = YukiHookAPI.Status.Executor.apiLevel
```
::: tip
For more functions, please refer to [YukiHookAPI.Status.Executor](../api/public/com/highcapable/yukihookapi/YukiHookAPI#executor-object).
:::
::: warning
**YukiHookAPI** after **1.0.91** version modifies the logical judgment method of obtaining the status of the Xposed Module, and now you can use this API in the Module App and Host App at the same time;
Need to make sure **YukiHookAPI.Configs.isEnableHookModuleStatus** is enabled;
Except for Hook Frameworks that provide standard APIs, Module Apps may not be able to determine whether they are activated in other cases.
**YukiHookAPI** only connects to the known acquisition methods.
Except for the Hook Framework that provides standard APIs, in other cases, the Xposed Module may not be able to determine whether it is activated or obtain information about the Hook Framework.
:::

View File

@@ -618,7 +618,13 @@ override fun onHook() = encase {
}
```
## Xposed 模块判断自身激活状态
## Xposed 模块状态
通常情况下Xposed 模块的开发者都会去选择读取当前 Xposed 模块的激活信息以更好地向用户展示当前功能的生效状态。
除了基本的 Hook 功能,`YukiHookAPI` 还为开发者设计了一套 Xposed 模块状态判断的功能如激活状态、Hook Framework 信息。
### 判断自身激活状态
通常情况下,我们会选择写一个方法,使其返回 `false`,然后 Hook 掉这个方法使其返回 `true` 来证明 Hook 已经生效。
@@ -686,12 +692,42 @@ if(YukiHookAPI.Status.isModuleActive) {
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
```
若模块激活判断中包含太极、无极中的激活状态,就必须将模块的 **Application** 继承于 **ModuleApplication** 或直接使用 **ModuleApplication**
若模块激活判断中包含太极、无极中的激活状态,就必须将模块的 **Application** 继承于 **ModuleApplication** 或直接使用 **ModuleApplication**
**1.0.91** 版本后的 API 修改了激活逻辑判断方式,现在你可以在模块与 Hook APP (宿主) 中同时使用此 API
:::
### 获取 Hook Framework 信息
除了判断自身激活状态之外,你还可以通过 `YukiHookAPI.Status` 中的 `Executor` 来获取当前 Hook Framework 的相关信息。
例如我们可以使用 `YukiHookAPI.Status.Executor.name` 来获取当前 Hook Framework 的名称。
> 示例如下
```kotlin
val frameworkName = YukiHookAPI.Status.Executor.name
```
我们还可以使用 `YukiHookAPI.Status.Executor.apiLevel` 来获取当前 Hook Framework 的 API Level。
> 示例如下
```kotlin
val frameworkApiLevel = YukiHookAPI.Status.Executor.apiLevel
```
::: tip
更多功能请参考 [YukiHookAPI.Status.Executor](../api/public/com/highcapable/yukihookapi/YukiHookAPI#executor-object)。
:::
::: warning
**1.0.91** 版本后的 **YukiHookAPI** 修改了获取 Xposed 模块状态的逻辑判断方式,现在你可以在模块与 Hook APP (宿主) 中同时使用此 API
需要确保 **YukiHookAPI.Configs.isEnableHookModuleStatus** 是启用状态;
除了提供标准 API 的 Hook Framework 之外,其它情况下模块可能都将无法判断自己是否被激活。
**YukiHookAPI** 仅对已知的获取方式进行了对接,除了提供标准 API 的 Hook Framework 之外,其它情况下模块可能都将无法判断自己是否被激活或是获取 Hook Framework 的相关信息
:::