mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 01:35:17 +08:00
Fixed context-registered receivers
This commit is contained in:
@@ -208,11 +208,15 @@ class YukiHookDataChannel private constructor() {
|
||||
internal fun register(context: Context?, packageName: String = context?.packageName ?: "") {
|
||||
if (YukiHookAPI.Configs.isEnableDataChannel.not() || context == null) return
|
||||
receiverContext = context
|
||||
context.registerReceiver(
|
||||
handlerReceiver, IntentFilter().apply {
|
||||
addAction(if (isXposedEnvironment) hostActionName(packageName) else moduleActionName(context))
|
||||
}
|
||||
)
|
||||
|
||||
val filter = IntentFilter().apply {
|
||||
addAction(if (isXposedEnvironment) hostActionName(packageName) else moduleActionName(context))
|
||||
}
|
||||
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 {
|
||||
|
@@ -299,12 +299,16 @@ internal object AppParasitics {
|
||||
* @param result 回调 - ([Context] 当前实例, [Intent] 当前对象)
|
||||
*/
|
||||
fun IntentFilter.registerReceiver(result: (Context, Intent) -> Unit) {
|
||||
it.registerReceiver(object : BroadcastReceiver() {
|
||||
val receiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
if (context == null || intent == null) return
|
||||
result(context, intent)
|
||||
}
|
||||
}, 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