Closed KruziikG closed 6 years ago
Fixed in 52c99faed130c3dcce899983e24cb6354da06e98
@KruziikG If you delete the conversation and then receive a message from it again, does it show up in the app normally or do you need to sync it?
@moezbhatti I need to sync it
@KruziikG QKSMS will only be able to stay in sync if it's set as the default SMS app
On Xiaomi devices when you open the default messaging app, it automatically assigns itself as the default SMS app, which means QKSMS won't receive your messages
I just tested this on my personal Xiaomi device using two different phones, and I can confirm that while it didn't work on 3.2.2, it works fine on 3.3.3
@moezbhatti QKSMS is always the default SMS app. I think this only happen on some HUAWEI devices.
I added a log here:
when add message to existing conversation, everything is OK
but when start a new conversation, threadId is 0, and this is an error: (error message means : W/System.err: java.io.IOException: Do not send same content again.)
Then I run this version using Android emulator. This app can start new conversation , and the difference is that the threadId for new conversation is not 0. like this
@KruziikG thank you for the detail! I'll make sure this gets fixed
Weirdly, this issue doesn't happen on my P9 Lite. If I delete the conversation and then receive a new message from it, then the conversation appears as normal
@KruziikG @gkomarnicki would you mind trying this APK and seeing if it resolves the issue for you?
@moezbhatti The bug's still there. Android Messages and Pulse both got the SMS, while QKSMS didn't. QKSMS is the default SMS app
@gkomarnicki hmmm, perhaps this one?
@moezbhatti Yes, so weird. In fact, The android 8.0 of my P9 Plus is still a beta version. So I'm not sure whether it is a system bug. Nova 2i got android 8.0 beta 2 months before P9, and huawei has released Final version On 1 Jun. Maybe this problem is caused by huawei, and only happens in its EMUI 8.0 systems, who knows.
Another wired thing may be relatied. When using AOSP messaging app, All messages display as 'unknown sender'. But google messages works fine.
and today I tried to debug qksms, and find that not only the 'threadId' is 0, but also the conversation is null,
and I tried both apks just now, this problen is still there. Here are the logs
@KruziikG can you try replacing the insertReceivedSms
method with this
override fun insertReceivedSms(subId: Int, address: String, body: String, sentTime: Long): Message {
// Insert the message to the native content provider
val uri = contentValuesOf(
Pair(Telephony.Sms.ADDRESS, address),
Pair(Telephony.Sms.BODY, body),
Pair(Telephony.Sms.DATE_SENT, sentTime),
Pair(Telephony.Sms.SUBSCRIPTION_ID, subId))
.let { values -> context.contentResolver.insert(Telephony.Sms.Inbox.CONTENT_URI, values) }
// Insert the message to Realm
return Message().apply {
this.address = address
this.body = body
this.dateSent = sentTime
this.date = System.currentTimeMillis()
this.subId = subId
id = messageIds.newId()
threadId = TelephonyCompat.getOrCreateThreadId(context, address)
contentId = uri?.lastPathSegment?.toLong() ?: 0L
boxId = Telephony.Sms.MESSAGE_TYPE_INBOX
type = "sms"
insertOrUpdate()
}
}
And can you let me know the value of uri.toString()
and the value of threadId
I see your last message just now,, let me have a try.
@KruziikG no worries, I assume that all of the affected devices will be affected in the same way. I'll send you code snippets and ask you to obtain certain values for me, this should help us resolve the issue by the end of the day :)
@moezbhatti Working on my end now. Thanks!
@KruziikG Your P9 Plus is running 8.0 Oreo beta? I guess it's a weird bug on Huawei's end.
Oh hm, that's interesting that it worked for you @gkomarnicki but not @KruziikG
@KruziikG let me know what the results are when you try that code snippet!
OK. And while syncing gradle files, I tried the second apk again, and I'm sure it not work for me. @gkomarnicki did you delete previous messages before test?
@moezbhatti both 'contentValuesOf' and 'values ' are not defined,don't know how to fix this.
@KruziikG you'll need to update to the latest version of the dev branch first
@KruziikG I deleted most of the conversations from unknown numbers before testing, but not all of them.
In this thread where I received 2FA verification codes, there was no notification for the first two messages, but I got a notification for the third message after installing the most recent APK linked above.
@KruziikG which version of android studio are you using? You may need to be on 3.2
@moezbhatti problem solved, I tried to imported 2 packages using alt+enter. But I think this project cannot be build on windows. I will check this later.
@KruziikG thanks. let me know what you end up getting for those values
06-22 10:37:12.460 9566-9676/com.moez.QKSMS D/QKSMS: ------>content://sms/inbox//871 06-22 10:37:12.581 9566-9676/com.moez.QKSMS D/QKSMS: threadId-->522
now threadid below also has a value. but this message still not displayed.
@KruziikG can you try this and share the logs
constructor
class MessageRepositoryImpl @Inject constructor(
private val context: Context,
private val cursorToConversation: CursorToConversation,
private val messageIds: KeyManager,
private val imageRepository: ImageRepository,
private val prefs: Preferences) : MessageRepository {
insertReceivedSms
override fun insertReceivedSms(subId: Int, address: String, body: String, sentTime: Long): Message {
// Insert the message to the native content provider
val uri = contentValuesOf(
Pair(Telephony.Sms.ADDRESS, address),
Pair(Telephony.Sms.BODY, body),
Pair(Telephony.Sms.DATE_SENT, sentTime),
Pair(Telephony.Sms.SUBSCRIPTION_ID, subId))
.let { values -> context.contentResolver.insert(Telephony.Sms.Inbox.CONTENT_URI, values) }
val threadId = TelephonyCompat.getOrCreateThreadId(context, address)
val conversation1 = cursorToConversation.getConversationCursor(threadId)
?.map(cursorToConversation::map)
?.firstOrNull()
val conversation2 = cursorToConversation.getConversationsCursor()
?.map(cursorToConversation::map)
?.firstOrNull { it.id == threadId }
Timber.d("threadId: $threadId")
Timber.d("conversation found via method 1: ${conversation1 != null}")
Timber.d("conversation found via method 2: ${conversation2 != null}")
// Insert the message to Realm
return Message().apply {
this.threadId = threadId
this.address = address
this.body = body
this.dateSent = sentTime
this.date = System.currentTimeMillis()
this.subId = subId
id = messageIds.newId()
contentId = uri?.lastPathSegment?.toLong() ?: 0L
boxId = Telephony.Sms.MESSAGE_TYPE_INBOX
type = "sms"
insertOrUpdate()
}
}
OK, here is the result 06-22 11:15:47.161 12557-12646/com.moez.QKSMS D/MessageRepositoryImpl: threadId: 522 06-22 11:15:47.162 12557-12646/com.moez.QKSMS D/MessageRepositoryImpl: conversation found via method 1: false conversation found via method 2: true
and i found something before,in this function, the paremeter is valid, but it return null. And this issue is quite same as the comment said.
@KruziikG okay, I believe this should fix the issue!
MessageRepositoryImpl.insertReceivedSms()
override fun insertReceivedSms(subId: Int, address: String, body: String, sentTime: Long): Message {
// Insert the message to the native content provider
val uri = contentValuesOf(
Pair(Telephony.Sms.ADDRESS, address),
Pair(Telephony.Sms.BODY, body),
Pair(Telephony.Sms.DATE_SENT, sentTime),
Pair(Telephony.Sms.SUBSCRIPTION_ID, subId))
.let { values -> context.contentResolver.insert(Telephony.Sms.Inbox.CONTENT_URI, values) }
// Insert the message to Realm
return Message().apply {
this.address = address
this.body = body
this.dateSent = sentTime
this.date = System.currentTimeMillis()
this.subId = subId
id = messageIds.newId()
threadId = TelephonyCompat.getOrCreateThreadId(context, address)
contentId = uri?.lastPathSegment?.toLong() ?: 0L
boxId = Telephony.Sms.MESSAGE_TYPE_INBOX
type = "sms"
insertOrUpdate()
}
}
ConversationRepositoryImpl.getConversationFromCp()
private fun getConversationFromCp(threadId: Long): Conversation? {
return cursorToConversation.getConversationsCursor()
?.map(cursorToConversation::map)
?.firstOrNull { it.id == threadId }
?.let { conversation ->
val realm = Realm.getDefaultInstance()
val contacts = realm.copyFromRealm(realm.where(Contact::class.java).findAll())
val recipients = conversation.recipients
.map { recipient -> recipient.id }
.map { id -> cursorToRecipient.getRecipientCursor(id) }
.mapNotNull { recipientCursor ->
// Map the recipient cursor to a list of recipients
recipientCursor?.use { recipientCursor.map { cursorToRecipient.map(recipientCursor) } }
}
.flatten()
.map { recipient ->
recipient.apply {
contact = contacts.firstOrNull {
it.numbers.any { PhoneNumberUtils.compare(recipient.address, it.address) }
}
}
}
conversation.recipients.clear()
conversation.recipients.addAll(recipients)
realm.executeTransaction { it.insertOrUpdate(conversation) }
realm.close()
conversation
}
}
It Work! Great! But.....Let me come up with a new issue about display, hahaha
Hi there, I can see here that this issue has been closed with version 3.3.4 but I didn't find any update in F-Droid. When I chceked the vsersion info in F-Droid wiki, it say's they couldn't build the vsersion 3.3.4. Can you please check the issue?
@fazlerabbi37 it gives the following reason, Reason: uses com.android.tools.build:gradle:3.2.0-alpha18
In 3.3.6 I've updated to 3.2.0-beta01
. Hopefully this helps, though I'm not sure what requirements they have for their automated builds
DESCRIPTION
I noticed that sometimes QKSMS will not show new message in sms list and also there in no notification in status bar. Only if I chose Settings->Sync messages then these messages will show in QKSMS. I tried several different situations and finally know it only happens when you haven't have a conversion with the sender. device: Huawei P9 Plus, running Android 8.0
STEPS
EXPECTED
The phone should produce a sound ringtone, and the new message should show in both notification bar and the QKSMS app.
OBSERVATIONS
I will attach two logs, the first one is captured in this situation: Screen is locked. I send three messages in this consequence :1. phone number A(new number) 2. phone number B(I have had conversion with this number privously)3.phone number C(another new number). Message 1 & 3 are now shown in QKSMS, but message 2 did. the second log is captured when phone is Waked up and QKSMS is in foreground. I Send a message using phone number A. This time the message is also now shown in QKSMS. qksms_log1.txt qksms_log2.txt
this gif shows that when I finished send there 4 messages, I can only manual re-sync message.