Skip to content

Commit

Permalink
fix: MessagingStyleNotification redundant separator
Browse files Browse the repository at this point in the history
  • Loading branch information
klxiaoniu committed Jul 13, 2023
1 parent fdb0555 commit 94fce04
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/src/main/java/moe/zapic/hook/MessagingStyleNotification.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Intent
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationCompat.MessagingStyle
Expand All @@ -53,6 +52,7 @@ import io.github.qauxv.dsl.FunctionEntryRouter
import io.github.qauxv.hook.CommonSwitchFunctionHook
import io.github.qauxv.ui.ResUtils
import io.github.qauxv.util.LicenseStatus
import io.github.qauxv.util.Log
import io.github.qauxv.util.SyncUtils
import io.github.qauxv.util.hostInfo
import moe.zapic.util.QQAvatarHelper
Expand Down Expand Up @@ -81,20 +81,20 @@ object MessagingStyleNotification : CommonSwitchFunctionHook(SyncUtils.PROC_ANY)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createNotificationChannels()
}
val cNotificationFacede = "com.tencent.qqnt.notification.NotificationFacade".clazz!!
val cNotificationFacade = "com.tencent.qqnt.notification.NotificationFacade".clazz!!
val cAppRuntime = "mqq.app.AppRuntime".clazz!!
val cCommonInfo = "com.tencent.qqnt.kernel.nativeinterface.NotificationCommonInfo".clazz!!
val cRecentInfo = "com.tencent.qqnt.kernel.nativeinterface.RecentContactInfo".clazz!!
val postNotification = Reflex.findSingleMethod(
cNotificationFacede,
cNotificationFacade,
null,
false,
Notification::class.java,
Int::class.javaPrimitiveType
)
lateinit var buildNotification: Method
lateinit var recentInfoBuilder: Method
cNotificationFacede.declaredMethods.forEach {
cNotificationFacade.declaredMethods.forEach {
if (it.parameterTypes.size != 3) return@forEach
if (it.parameterTypes[0] != cAppRuntime) return@forEach
if (it.parameterTypes[2] == cCommonInfo) {
Expand Down Expand Up @@ -125,8 +125,8 @@ object MessagingStyleNotification : CommonSwitchFunctionHook(SyncUtils.PROC_ANY)
val pair = notificationInfoMap[oldNotification.contentIntent] ?: return@hookBeforeIfEnabled
val info = QQRecentContactInfo(pair.first)
notificationInfoMap.remove(oldNotification.contentIntent)
if (info.chatType == 1 || info.chatType == 2){
val content = info.abstractContent?.joinToString { it.get("content", String::class.java) ?: "[未解析消息]" } ?: return@hookBeforeIfEnabled
if (info.chatType == 1 || info.chatType == 2) {
val content = info.abstractContent?.joinToString(separator = "") { it.get("content", String::class.java) ?: "[未解析消息]" } ?: return@hookBeforeIfEnabled
val senderName = info.getUserName() ?: return@hookBeforeIfEnabled
val senderUin = info.senderUin ?: return@hookBeforeIfEnabled
val senderIcon: IconCompat
Expand Down Expand Up @@ -265,7 +265,7 @@ object MessagingStyleNotification : CommonSwitchFunctionHook(SyncUtils.PROC_ANY)
if (notificationChannels.any { notificationChannel ->
notificationManager.getNotificationChannel(notificationChannel.id) == null
}) {
Log.i("QNotifyEvolutionXp", "Creating channels...")
Log.i("QNotifyEvolutionXp: Creating channels...")
notificationManager.createNotificationChannelGroup(notificationChannelGroup)
notificationManager.createNotificationChannels(notificationChannels)
}
Expand Down

0 comments on commit 94fce04

Please sign in to comment.