From 27a513ef38c6ef680d62d765c9be154d515ec705 Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Wed, 25 May 2022 03:46:20 +0800 Subject: [PATCH] Fix non-null context when YukiHookDataChannel sending broadcast --- .../hook/xposed/channel/YukiHookDataChannel.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/channel/YukiHookDataChannel.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/channel/YukiHookDataChannel.kt index 1178862b..5eddeef0 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/channel/YukiHookDataChannel.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/channel/YukiHookDataChannel.kt @@ -37,10 +37,12 @@ import android.content.IntentFilter import android.os.Bundle import android.os.Parcelable import com.highcapable.yukihookapi.YukiHookAPI +import com.highcapable.yukihookapi.hook.log.yLoggerW import com.highcapable.yukihookapi.hook.utils.putIfAbsentCompat import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge import com.highcapable.yukihookapi.hook.xposed.channel.data.ChannelData +import com.highcapable.yukihookapi.hook.xposed.helper.YukiHookAppHelper import java.io.Serializable /** @@ -147,7 +149,7 @@ class YukiHookDataChannel private constructor() { */ internal fun nameSpace(context: Context? = null, packageName: String): NameSpace { checkApi() - return NameSpace(context = context ?: receiverContext, packageName) + return NameSpace(context = context ?: receiverContext ?: YukiHookAppHelper.currentApplication(), packageName) } /** @@ -279,7 +281,10 @@ class YukiHookDataChannel private constructor() { else -> error("Key-Value type ${it.value?.javaClass?.name} is not allowed") } } - }) + }) ?: yLoggerW( + msg = "Failed to sendBroadcast like \"${data.takeIf { it.isNotEmpty() }?.get(0)?.key ?: "unknown"}\", " + + "because got non-null context in \"$packageName\"" + ) } } } \ No newline at end of file