Skip to content

Commit

Permalink
fix(messaging-style): apply missing patches
Browse files Browse the repository at this point in the history
  • Loading branch information
KawaiiZapic committed Jul 18, 2023
1 parent 3017a8e commit b6a73d4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ class NonNTMessageStyleNotification(private val parent: MessagingStyleNotificati
if (uinType != -1) {
param.result = null
val uin = intent.getStringExtra("TO_UIN") ?: return
val result = RemoteInput.getResultsFromIntent(intent)?.getString("KEY_REPLY") ?: return
val result = RemoteInput.getResultsFromIntent(intent)?.getCharSequence("KEY_REPLY") ?: return
val selfUin = AppRuntimeHelper.getAccount()
// send message
ChatActivityFacade.sendMessage(
AppRuntimeHelper.getQQAppInterface(),
hostInfo.application,
SessionInfoImpl.createSessionInfo(uin, uinType),
result
result.toString()
)

// update exist notification
Expand Down
34 changes: 19 additions & 15 deletions app/src/main/java/moe/zapic/hook/MessagingStyleNotification.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,20 @@ object MessagingStyleNotification : CommonSwitchFunctionHook(SyncUtils.PROC_ANY)
if (!HostInfo.requireMinQQVersion(QQVersion.QQ_8_9_63)) {
return NonNTMessageStyleNotification(this).hook()
}
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 @@ -143,19 +143,23 @@ object MessagingStyleNotification : CommonSwitchFunctionHook(SyncUtils.PROC_ANY)
var groupIcon: IconCompat? = null

// 好友消息
if (info.chatType == 1) {
senderIcon = IconCompat.createFromIcon(hostInfo.application, oldNotification.getLargeIcon()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap())
shortcut = getShortcut("private_$senderUin", senderName, senderIcon, pair.second)
} else if (info.chatType == 2) {
groupName = info.peerName ?: return@hookBeforeIfEnabled
groupUin = info.peerUin ?: return@hookBeforeIfEnabled
when (info.chatType) {
1 -> {
senderIcon = IconCompat.createFromIcon(hostInfo.application, oldNotification.getLargeIcon()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap())
shortcut = getShortcut("private_$senderUin", senderName, senderIcon, pair.second)
}
2 -> {
groupName = info.peerName ?: return@hookBeforeIfEnabled
groupUin = info.peerUin ?: return@hookBeforeIfEnabled

senderIcon = avatarHelper.getAvatar(senderUin.toString()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap())
groupIcon = IconCompat.createFromIcon(hostInfo.application, oldNotification.getLargeIcon()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap())
shortcut = getShortcut("group_$groupUin", groupName, groupIcon, pair.second)
} else {
// Impossible
throw Error("what the hell?")
senderIcon = avatarHelper.getAvatar(senderUin.toString()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap())
groupIcon = IconCompat.createFromIcon(hostInfo.application, oldNotification.getLargeIcon()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap())
shortcut = getShortcut("group_$groupUin", groupName, groupIcon, pair.second)
}
else -> {
// Impossible
throw Error("what the hell?")
}
}
val notification = createNotification(
content,
Expand Down

0 comments on commit b6a73d4

Please sign in to comment.