mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-05 18:25:28 +08:00
Update api-exception documentation
This commit is contained in:
@@ -1226,13 +1226,13 @@ This situation basically does not exist, because `appContext` is assigned in `on
|
|||||||
|
|
||||||
::: danger IllegalStateException
|
::: danger IllegalStateException
|
||||||
|
|
||||||
YukiHookModulePrefs not allowed in Custom Hook API
|
YukiHookPrefsBridge not allowed in Custom Hook API
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
**Abnormal**
|
**Abnormal**
|
||||||
|
|
||||||
`YukiHookModulePrefs` is used in Hook's own app (not Xposed Module).
|
`YukiHookPrefsBridge` is used in Hook's own app (not Xposed Module).
|
||||||
|
|
||||||
> The following example
|
> The following example
|
||||||
|
|
||||||
@@ -1251,7 +1251,7 @@ class MyApplication : Application() {
|
|||||||
|
|
||||||
**Solution**
|
**Solution**
|
||||||
|
|
||||||
You can only use `YukiHookModulePrefs` when [Use as Xposed Module Configs](../config/xposed-using), please use the native `Sp` storage in the Hook's own app.
|
You can only use `YukiHookPrefsBridge` when [Use as Xposed Module Configs](../config/xposed-using), please use the native `Sp` storage in the Hook's own app.
|
||||||
|
|
||||||
###### exception
|
###### exception
|
||||||
|
|
||||||
@@ -1263,7 +1263,7 @@ Cannot load the XSharedPreferences, maybe is your Hook Framework not support it
|
|||||||
|
|
||||||
**Abnormal**
|
**Abnormal**
|
||||||
|
|
||||||
Using `YukiHookModulePrefs` in (Xposed) Host environment but unable to get `XSharedPreferences` object.
|
Using `YukiHookPrefsBridge` in (Xposed) Host environment but unable to get `XSharedPreferences` object.
|
||||||
|
|
||||||
> The following example
|
> The following example
|
||||||
|
|
||||||
@@ -1323,7 +1323,7 @@ Xposed modulePackageName load failed, please reset and rebuild it
|
|||||||
|
|
||||||
**Abnormal**
|
**Abnormal**
|
||||||
|
|
||||||
When using `YukiHookModulePrefs` or `YukiHookDataChannel` in the Hook process, the `modulePackageName` at load time cannot be read, resulting in the package name of the own Module App cannot be determined.
|
When using `YYukiHookPrefsBridge` or `YukiHookDataChannel` in the Hook process, the `modulePackageName` at load time cannot be read, resulting in the package name of the own Module App cannot be determined.
|
||||||
|
|
||||||
**Solution**
|
**Solution**
|
||||||
|
|
||||||
@@ -1333,13 +1333,13 @@ Please read the help document [here](../config/xposed-using#modulepackagename-pa
|
|||||||
|
|
||||||
::: danger IllegalStateException
|
::: danger IllegalStateException
|
||||||
|
|
||||||
YukiHookModulePrefs missing Context instance
|
YukiHookPrefsBridge missing Context instance
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
**Abnormal**
|
**Abnormal**
|
||||||
|
|
||||||
`YukiHookModulePrefs` is used in the Module App to store data but no `Context` instance is passed in.
|
`YukiHookPrefsBridge` is used in the Module App to store data but no `Context` instance is passed in.
|
||||||
|
|
||||||
> The following example
|
> The following example
|
||||||
|
|
||||||
@@ -1350,14 +1350,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
// ❗ Wrong usage
|
// ❗ Wrong usage
|
||||||
// Constructor has been set to private in API 1.0.88 and later
|
// Constructor has been set to private in API 1.0.88 and later
|
||||||
YukiHookModulePrefs().getBoolean("test_data")
|
YukiHookPrefsBridge().getBoolean("test_data")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Solution**
|
**Solution**
|
||||||
|
|
||||||
It is recommended to use the `modulePrefs` method to load `YukiHookModulePrefs` in `Activity`.
|
It is recommended to use the `prefs(...)` method to load `YukiHookPrefsBridge` in `Activity`.
|
||||||
|
|
||||||
> The following example
|
> The following example
|
||||||
|
|
||||||
@@ -1367,7 +1367,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
// ✅ Correct usage
|
// ✅ Correct usage
|
||||||
modulePrefs.getBoolean("test_data")
|
prefs().getBoolean("test_data")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -1376,17 +1376,42 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
::: danger IllegalStateException
|
::: danger IllegalStateException
|
||||||
|
|
||||||
|
The Host App's Context has not yet initialized successfully, the native function cannot be used at this time
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
**Abnormal**
|
||||||
|
|
||||||
|
In the (Xposed) Host environment `PackageParam`, `YukiHookPrefsBridge` is used and the `native` method is called, but the lifecycle of the Host App is not initialized at this time.
|
||||||
|
|
||||||
|
> The following example
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
encase {
|
||||||
|
// This method was called
|
||||||
|
prefs.native()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Solution**
|
||||||
|
|
||||||
|
The `native` method requires an existing `Context` object to store data in, and you can use this method in listening to the Host App lifecycle state.
|
||||||
|
|
||||||
|
###### exception
|
||||||
|
|
||||||
|
::: danger IllegalStateException
|
||||||
|
|
||||||
Key-Value type **TYPE** is not allowed
|
Key-Value type **TYPE** is not allowed
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
**Abnormal**
|
**Abnormal**
|
||||||
|
|
||||||
An unsupported storage type was passed in when using the `get` or `put` methods of `YukiHookModulePrefs` or the `wait` or `put` methods of `YukiHookDataChannel`.
|
An unsupported storage type was passed in when using the `get` or `put` methods of `YukiHookPrefsBridge` or the `wait` or `put` methods of `YukiHookDataChannel`.
|
||||||
|
|
||||||
**Solution**
|
**Solution**
|
||||||
|
|
||||||
The supported types of `YukiHookModulePrefs` are only `String`, `Set<String>`, `Int`, `Float`, `Long`, `Boolean`, please pass in the supported types.
|
The supported types of `YukiHookPrefsBridge` are only `String`, `Set<String>`, `Int`, `Float`, `Long`, `Boolean`, please pass in the supported types.
|
||||||
|
|
||||||
The supported types of `YukiHookDataChannel` are the types restricted by `Intent.putExtra`, please pass in the supported types.
|
The supported types of `YukiHookDataChannel` are the types restricted by `Intent.putExtra`, please pass in the supported types.
|
||||||
|
|
||||||
|
@@ -1167,13 +1167,13 @@ ModuleApplication.appContext...
|
|||||||
|
|
||||||
::: danger IllegalStateException
|
::: danger IllegalStateException
|
||||||
|
|
||||||
YukiHookModulePrefs not allowed in Custom Hook API
|
YukiHookPrefsBridge not allowed in Custom Hook API
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
**异常原因**
|
**异常原因**
|
||||||
|
|
||||||
在 Hook 自身 APP(非 Xposed 模块) 中使用了 `YukiHookModulePrefs`。
|
在 Hook 自身 APP(非 Xposed 模块) 中使用了 `YukiHookPrefsBridge`。
|
||||||
|
|
||||||
> 示例如下
|
> 示例如下
|
||||||
|
|
||||||
@@ -1192,7 +1192,7 @@ class MyApplication : Application() {
|
|||||||
|
|
||||||
**解决方案**
|
**解决方案**
|
||||||
|
|
||||||
你只能在 [作为 Xposed 模块使用](../config/xposed-using) 时使用 `YukiHookModulePrefs`,在 Hook 自身 APP 中请使用原生的 `Sp` 存储。
|
你只能在 [作为 Xposed 模块使用](../config/xposed-using) 时使用 `YukiHookPrefsBridge`,在 Hook 自身 APP 中请使用原生的 `Sp` 存储。
|
||||||
|
|
||||||
###### exception
|
###### exception
|
||||||
|
|
||||||
@@ -1204,7 +1204,7 @@ Cannot load the XSharedPreferences, maybe is your Hook Framework not support it
|
|||||||
|
|
||||||
**异常原因**
|
**异常原因**
|
||||||
|
|
||||||
在 (Xposed) 宿主环境使用了 `YukiHookModulePrefs` 但是无法得到 `XSharedPreferences` 对象。
|
在 (Xposed) 宿主环境使用了 `YukiHookPrefsBridge` 但是无法得到 `XSharedPreferences` 对象。
|
||||||
|
|
||||||
> 示例如下
|
> 示例如下
|
||||||
|
|
||||||
@@ -1262,7 +1262,7 @@ Xposed modulePackageName load failed, please reset and rebuild it
|
|||||||
|
|
||||||
**异常原因**
|
**异常原因**
|
||||||
|
|
||||||
在 Hook 过程中使用 `YukiHookModulePrefs` 或 `YukiHookDataChannel` 时无法读取装载时的 `modulePackageName` 导致不能确定自身模块的包名。
|
在 Hook 过程中使用 `YukiHookPrefsBridge` 或 `YukiHookDataChannel` 时无法读取装载时的 `modulePackageName` 导致不能确定自身模块的包名。
|
||||||
|
|
||||||
**解决方案**
|
**解决方案**
|
||||||
|
|
||||||
@@ -1272,13 +1272,13 @@ Xposed modulePackageName load failed, please reset and rebuild it
|
|||||||
|
|
||||||
::: danger IllegalStateException
|
::: danger IllegalStateException
|
||||||
|
|
||||||
YukiHookModulePrefs missing Context instance
|
YukiHookPrefsBridge missing Context instance
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
**异常原因**
|
**异常原因**
|
||||||
|
|
||||||
在模块中使用了 `YukiHookModulePrefs` 存储数据但并未传入 `Context` 实例。
|
在模块中使用了 `YukiHookPrefsBridge` 存储数据但并未传入 `Context` 实例。
|
||||||
|
|
||||||
> 示例如下
|
> 示例如下
|
||||||
|
|
||||||
@@ -1289,14 +1289,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
// ❗错误的使用方法
|
// ❗错误的使用方法
|
||||||
// 构造方法已在 API 1.0.88 及以后的版本中设置为 private
|
// 构造方法已在 API 1.0.88 及以后的版本中设置为 private
|
||||||
YukiHookModulePrefs().getBoolean("test_data")
|
YukiHookPrefsBridge().getBoolean("test_data")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**解决方案**
|
**解决方案**
|
||||||
|
|
||||||
在 `Activity` 中推荐使用 `modulePrefs` 方法来装载 `YukiHookModulePrefs`。
|
在 `Activity` 中推荐使用 `prefs(...)` 方法来装载 `YukiHookPrefsBridge`。
|
||||||
|
|
||||||
> 示例如下
|
> 示例如下
|
||||||
|
|
||||||
@@ -1306,7 +1306,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
// ✅ 正确的使用方法
|
// ✅ 正确的使用方法
|
||||||
modulePrefs.getBoolean("test_data")
|
prefs().getBoolean("test_data")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -1315,17 +1315,42 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
::: danger IllegalStateException
|
::: danger IllegalStateException
|
||||||
|
|
||||||
|
The Host App's Context has not yet initialized successfully, the native function cannot be used at this time
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
**异常原因**
|
||||||
|
|
||||||
|
在 (Xposed) 宿主环境 `PackageParam` 中使用了 `YukiHookPrefsBridge` 并调用了 `native` 方法但此时宿主的生命周期并未初始化。
|
||||||
|
|
||||||
|
> 示例如下
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
encase {
|
||||||
|
// 调用了此方法
|
||||||
|
prefs.native()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**解决方案**
|
||||||
|
|
||||||
|
`native` 方法需要一个存在的 `Context` 对象用于存储数据,你可以在监听宿主生命周期状态中使用此方法。
|
||||||
|
|
||||||
|
###### exception
|
||||||
|
|
||||||
|
::: danger IllegalStateException
|
||||||
|
|
||||||
Key-Value type **TYPE** is not allowed
|
Key-Value type **TYPE** is not allowed
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
**异常原因**
|
**异常原因**
|
||||||
|
|
||||||
在使用 `YukiHookModulePrefs` 的 `get` 或 `put` 方法或 `YukiHookDataChannel` 的 `wait` 或 `put` 方法时传入了不支持的存储类型。
|
在使用 `YukiHookPrefsBridge` 的 `get` 或 `put` 方法或 `YukiHookDataChannel` 的 `wait` 或 `put` 方法时传入了不支持的存储类型。
|
||||||
|
|
||||||
**解决方案**
|
**解决方案**
|
||||||
|
|
||||||
`YukiHookModulePrefs` 支持的类型只有 `String`、`Set<String>`、`Int`、`Float`、`Long`、`Boolean`,请传入支持的类型。
|
`YukiHookPrefsBridge` 支持的类型只有 `String`、`Set<String>`、`Int`、`Float`、`Long`、`Boolean`,请传入支持的类型。
|
||||||
|
|
||||||
`YukiHookDataChannel` 支持的类型为 `Intent.putExtra` 限制的类型,请传入支持的类型。
|
`YukiHookDataChannel` 支持的类型为 `Intent.putExtra` 限制的类型,请传入支持的类型。
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user