mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 09:45:19 +08:00
Refactor optimize code in YukiHookDataChannel, AppParasitics
This commit is contained in:
@@ -73,10 +73,13 @@ object YukiHookAPI {
|
||||
/** 标识是否从自定义 Hook API 装载 */
|
||||
internal var isLoadedFromBaseContext = false
|
||||
|
||||
/** 获取当前 [YukiHookAPI] 的版本 */
|
||||
// TODO
|
||||
const val TAG = ""
|
||||
|
||||
/** 版本名称 */
|
||||
const val API_VERSION_NAME = BuildConfig.API_VERSION_NAME
|
||||
|
||||
/** 获取当前 [YukiHookAPI] 的版本号 */
|
||||
/** 版本号 */
|
||||
const val API_VERSION_CODE = BuildConfig.API_VERSION_CODE
|
||||
|
||||
/**
|
||||
|
@@ -299,16 +299,20 @@ internal object AppParasitics {
|
||||
* @param result 回调 - ([Context] 当前实例, [Intent] 当前对象)
|
||||
*/
|
||||
fun IntentFilter.registerReceiver(result: (Context, Intent) -> Unit) {
|
||||
val receiver = object : BroadcastReceiver() {
|
||||
object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
if (context == null || intent == null) return
|
||||
result(context, intent)
|
||||
}
|
||||
}.also { receiver ->
|
||||
/**
|
||||
* 从 Android 14 (及预览版) 开始
|
||||
* 外部广播必须声明 [Context.RECEIVER_EXPORTED]
|
||||
*/
|
||||
if (Build.VERSION.SDK_INT >= 33)
|
||||
it.registerReceiver(receiver, this, Context.RECEIVER_EXPORTED)
|
||||
else it.registerReceiver(receiver, this)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
it.registerReceiver(receiver, this, Context.RECEIVER_EXPORTED)
|
||||
|
||||
} else it.registerReceiver(receiver, this)
|
||||
}
|
||||
hostApplication = it
|
||||
AppLifecycleCallback.onCreateCallback?.invoke(it)
|
||||
|
Reference in New Issue
Block a user