Commit d0f67c58 by zhangchengbo

fix:解决收到新的短信消息,未读状态未更新

parent a4433c7a
...@@ -185,18 +185,18 @@ class SmsReceiver : BroadcastReceiver() { ...@@ -185,18 +185,18 @@ class SmsReceiver : BroadcastReceiver() {
var notificationUserName = ""//通讯录如果有备注则优先展示备注,其次手机号 var notificationUserName = ""//通讯录如果有备注则优先展示备注,其次手机号
Handler(Looper.getMainLooper()).post { Handler(Looper.getMainLooper()).post {
//最新消息会话
val conversation: Conversation = context.getConversations(threadId).firstOrNull() ?: return@post
Log.d(TAG, "handleMessage: conversation toJson = ${Gson().toJson(conversation)} ")
if(!PhoneFromUtil.isNumeric(conversation.userName)){
notificationUserName = conversation.userName
}
if (!context.isNumberBlocked(address)) { if (!context.isNumberBlocked(address)) {
val privateCursor = context.getMyContactsCursor(favoritesOnly = false, withPhoneNumbersOnly = true) val privateCursor = context.getMyContactsCursor(favoritesOnly = false, withPhoneNumbersOnly = true)
ensureBackgroundThread { ensureBackgroundThread {
val newMessageId: Long = context.insertNewSMS(address, subject, body, date, read, threadId, type, subscriptionId) val newMessageId: Long = context.insertNewSMS(address, subject, body, date, read, threadId, type, subscriptionId)
//最新消息会话 必须在insertNewSMS 后获取,否则读取的read状态不生效
val conversation: Conversation = context.getConversations(threadId).firstOrNull() ?: return@ensureBackgroundThread
Log.d(TAG, "handleMessage: conversation toJson = ${Gson().toJson(conversation)} ")
if(!PhoneFromUtil.isNumeric(conversation.userName)){
notificationUserName = conversation.userName
}
if (aesPhoneNumber.isNotBlank() || body.contains("\u200B")) { if (aesPhoneNumber.isNotBlank() || body.contains("\u200B")) {
conversation.title = aesPhoneNumber conversation.title = aesPhoneNumber
conversation.isSFNumber = true conversation.isSFNumber = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment