mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 01:35:17 +08:00
Refactor optimize code in YukiHookDataChannel
This commit is contained in:
@@ -208,15 +208,17 @@ class YukiHookDataChannel private constructor() {
|
||||
internal fun register(context: Context?, packageName: String = context?.packageName ?: "") {
|
||||
if (YukiHookAPI.Configs.isEnableDataChannel.not() || context == null) return
|
||||
receiverContext = context
|
||||
|
||||
val filter = IntentFilter().apply {
|
||||
IntentFilter().apply {
|
||||
addAction(if (isXposedEnvironment) hostActionName(packageName) else moduleActionName(context))
|
||||
}.also { filter ->
|
||||
/**
|
||||
* 从 Android 14 (及预览版) 开始
|
||||
* 外部广播必须声明 [Context.RECEIVER_EXPORTED]
|
||||
*/
|
||||
if (Build.VERSION.SDK_INT >= 33)
|
||||
context.registerReceiver(handlerReceiver, filter, Context.RECEIVER_EXPORTED)
|
||||
else context.registerReceiver(handlerReceiver, filter)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
context.registerReceiver(handlerReceiver, filter, Context.RECEIVER_EXPORTED)
|
||||
|
||||
} else context.registerReceiver(handlerReceiver, filter)
|
||||
|
||||
/** 排除模块环境下模块注册自身广播 */
|
||||
if (isXposedEnvironment.not()) return
|
||||
nameSpace(context, packageName).with {
|
||||
|
Reference in New Issue
Block a user