mirror of
https://github.com/KitsunePie/AppErrorsTracking.git
synced 2025-09-01 08:45:16 +08:00
Added getResolverString / putResolverString function in ConfigData
This commit is contained in:
@@ -23,9 +23,12 @@
|
||||
|
||||
package com.fankes.apperrorstracking.data
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.provider.Settings
|
||||
import android.widget.CompoundButton
|
||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||
import com.highcapable.yukihookapi.hook.log.loggerE
|
||||
import com.highcapable.yukihookapi.hook.log.loggerW
|
||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
||||
@@ -104,6 +107,27 @@ object ConfigData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 [ContentResolver] 字符串数据 (仅限 Hook 进程)
|
||||
* @param key 键值名称
|
||||
* @return [String]
|
||||
*/
|
||||
fun getResolverString(key: String) =
|
||||
runCatching { (instance as? PackageParam)?.appContext?.let { Settings.Secure.getString(it.contentResolver, key) } }.getOrNull() ?: ""
|
||||
|
||||
/**
|
||||
* 存入 [ContentResolver] 字符串数据 (仅限 Hook 进程)
|
||||
* @param key 键值名称
|
||||
* @param value 键值数据
|
||||
*/
|
||||
fun putResolverString(key: String, value: String) {
|
||||
runCatching {
|
||||
(instance as? PackageParam)?.appContext?.also { Settings.Secure.putString(it.contentResolver, key, value) }
|
||||
}.onFailure {
|
||||
loggerE(msg = "Write secure settings failed", e = it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否显示开发者提示
|
||||
* @return [Boolean]
|
||||
|
Reference in New Issue
Block a user