Skip to content

Commit 1831257

Browse files
committed
Update api-example documentation
1 parent 3b56218 commit 1831257

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

docs-source/src/en/config/api-example.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ object CustomHooker : YukiBaseHooker() {
105105
}
106106
```
107107

108-
Child Hooker **recommended** singleton `object` creation, you can also use `class` but not recommended.
108+
Child Hooker **recommended** to use singleton `object` to create, you can also use `class` but it is generally not recommended.
109109

110110
::: warning
111111

@@ -195,6 +195,33 @@ object HookEntry : IYukiHookXposedInit {
195195
}
196196
```
197197

198+
#### Special Case
199+
200+
As we mentioned above, it is generally not recommended to use `class` to create child Hookers, but there is a special case where it may still be necessary to keep your Hooker supporting multiple instantiations.
201+
202+
There is a rare possibility that there are multiple package names in a process.
203+
204+
In this case, when `YukiHookAPI` finds that the child Hooker is a singleton, it will ignore it and print a warning message.
205+
206+
```: no-line-numbers
207+
This Hooker "HOOKER" is singleton or reused, but the current process has multiple package name "NAME", the original is "NAME"
208+
Make sure your Hooker supports multiple instances for this situation
209+
The process with package name "NAME" will be ignored
210+
```
211+
212+
In this case, we only need to modify `object` to `class` or determine the package name during loading and then load the child Hooker.
213+
214+
For example, in the above cases, the following forms can be used to load.
215+
216+
> The following example
217+
218+
```kotlin
219+
encase {
220+
// Assume this is the app package name and child Hooker you need to load
221+
loadApp("com.example.demo", YourCustomHooker)
222+
}
223+
```
224+
198225
### Expansion Features
199226

200227
If your current Hook Framework supports and enables the Resources Hook feature, you can now create Resources Hooks directly in `encase`.

docs-source/src/zh-cn/config/api-example.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ object CustomHooker : YukiBaseHooker() {
105105
}
106106
```
107107

108-
子 Hooker **建议使用**单例 `object` 创建,你也可以使用 `class` 但不推荐
108+
子 Hooker **建议使用**单例 `object` 创建,你也可以使用 `class` 但一般情况下不推荐
109109

110110
::: warning
111111

@@ -195,6 +195,31 @@ object HookEntry : IYukiHookXposedInit {
195195
}
196196
```
197197

198+
#### 特殊情况
199+
200+
上面我们说到,在一般情况下不推荐使用 `class` 创建子 Hooker,但是有一种特殊情况,它可能依然需要保持你的 Hooker 支持多例。
201+
202+
有极少的可能性会出现在一个进程中存在多个包名的情况,这种情况下,`YukiHookAPI` 发现子 Hooker 为单例时,将会忽略并打印一条警告信息。
203+
204+
```:no-line-numbers
205+
This Hooker "HOOKER" is singleton or reused, but the current process has multiple package name "NAME", the original is "NAME"
206+
Make sure your Hooker supports multiple instances for this situation
207+
The process with package name "NAME" will be ignored
208+
```
209+
210+
遇到这种情况时,我们只需要修改 `object``class` 或者在装载时判断包名后再装载子 Hooker。
211+
212+
例如以上情况中可使用以下形式来装载。
213+
214+
> 示例如下
215+
216+
```kotlin
217+
encase {
218+
// 假设这个就是你需要装载的 APP 包名和子 Hooker
219+
loadApp("com.example.demo", YourCustomHooker)
220+
}
221+
```
222+
198223
### 扩展特性
199224

200225
如果你当前使用的 Hook Framework 支持并启用了资源钩子(Resources Hook)功能,你现在可以直接在 `encase` 中创建 Resources Hook。

0 commit comments

Comments
 (0)