Skip to content

Commit 83b5810

Browse files
authored
Merge pull request #149 from tom93/fix-deletion
Fix deletion of random SMS when trying to update threads
2 parents 207596d + 9d60c51 commit 83b5810

File tree

1 file changed

+5
-3
lines changed
  • app/src/main/kotlin/org/fossify/messages/extensions

1 file changed

+5
-3
lines changed

app/src/main/kotlin/org/fossify/messages/extensions/Context.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,11 +989,13 @@ fun Context.deleteSmsDraft(threadId: Long) {
989989
}
990990

991991
fun Context.updateLastConversationMessage(threadId: Long) {
992+
// update the date and the snippet of the thread, by triggering the
993+
// following Android code (which runs even if no messages are deleted):
994+
// https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/android14-release/src/com/android/providers/telephony/MmsSmsProvider.java#1409
992995
val uri = Threads.CONTENT_URI
993-
val selection = "${Threads._ID} = ?"
994-
val selectionArgs = arrayOf(threadId.toString())
996+
val selection = "1 = 0" // always-false condition, because we don't actually want to delete any messages
995997
try {
996-
contentResolver.delete(uri, selection, selectionArgs)
998+
contentResolver.delete(uri, selection, null)
997999
val newConversation = getConversations(threadId)[0]
9981000
insertOrUpdateConversation(newConversation)
9991001
} catch (e: Exception) {

0 commit comments

Comments
 (0)