mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-05 18:25:28 +08:00
Fix checkApi ignored bug in YukiHookModulePrefs
This commit is contained in:
@@ -154,28 +154,30 @@ class YukiHookModulePrefs private constructor(private var context: Context? = nu
|
|||||||
* @return [XSharedPreferences]
|
* @return [XSharedPreferences]
|
||||||
*/
|
*/
|
||||||
private val xPrefs
|
private val xPrefs
|
||||||
get() = runCatching {
|
get() = checkApi().let {
|
||||||
XSharedPreferences(YukiHookBridge.modulePackageName, prefsName).apply {
|
runCatching {
|
||||||
checkApi()
|
XSharedPreferences(YukiHookBridge.modulePackageName, prefsName).apply {
|
||||||
makeWorldReadable()
|
checkApi()
|
||||||
reload()
|
makeWorldReadable()
|
||||||
}
|
reload()
|
||||||
}.onFailure { yLoggerE(msg = it.message ?: "Operating system not supported", e = it) }.getOrNull()
|
}
|
||||||
?: error("Cannot load the XSharedPreferences, maybe is your Hook Framework not support it")
|
}.onFailure { yLoggerE(msg = it.message ?: "Operating system not supported", e = it) }.getOrNull()
|
||||||
|
?: error("Cannot load the XSharedPreferences, maybe is your Hook Framework not support it")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得 [SharedPreferences] 对象
|
* 获得 [SharedPreferences] 对象
|
||||||
* @return [SharedPreferences]
|
* @return [SharedPreferences]
|
||||||
*/
|
*/
|
||||||
private val sPrefs
|
private val sPrefs
|
||||||
get() = try {
|
get() = checkApi().let {
|
||||||
checkApi()
|
try {
|
||||||
context?.getSharedPreferences(prefsName, Context.MODE_WORLD_READABLE).also { isUsingNewXSharedPreferences = true }
|
context?.getSharedPreferences(prefsName, Context.MODE_WORLD_READABLE).also { isUsingNewXSharedPreferences = true }
|
||||||
?: error("YukiHookModulePrefs missing Context instance")
|
?: error("YukiHookModulePrefs missing Context instance")
|
||||||
} catch (_: Throwable) {
|
} catch (_: Throwable) {
|
||||||
checkApi()
|
context?.getSharedPreferences(prefsName, Context.MODE_PRIVATE).also { isUsingNewXSharedPreferences = false }
|
||||||
context?.getSharedPreferences(prefsName, Context.MODE_PRIVATE).also { isUsingNewXSharedPreferences = false }
|
?: error("YukiHookModulePrefs missing Context instance")
|
||||||
?: error("YukiHookModulePrefs missing Context instance")
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置全局可读可写 */
|
/** 设置全局可读可写 */
|
||||||
|
Reference in New Issue
Block a user