Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imported conversations have incorrect timestamps #146

Closed
7 tasks done
tom93 opened this issue Mar 22, 2024 · 5 comments
Closed
7 tasks done

Imported conversations have incorrect timestamps #146

tom93 opened this issue Mar 22, 2024 · 5 comments
Labels
duplicate This issue or pull request already exists

Comments

@tom93
Copy link
Contributor

tom93 commented Mar 22, 2024

Checklist

  • I can reproduce the bug with the latest version given here.
  • I made sure that there are no existing issues - open or closed - to which I could contribute my information.
  • I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
  • I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
  • I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
  • This issue contains only one bug.
  • I have read and understood the contribution guidelines.

Affected app version

1.0.1

Affected Android/Custom ROM version

Android 8.1, Android 14

Affected device model

Moto G5 Plus, emulator

How did you install the app?

Built from source

Steps to reproduce the bug

Import messages from a .json backup (Settings > Import messages). Sample file:

[
 {"subscriptionId":1,"address":"6505551","body":"Message 1","date":1704067200000,"dateSent":0,"locked":0,"protocol":null,"read":1,"status":-1,"type":1,"serviceCenter":null,"backupType":"sms"}
,{"subscriptionId":1,"address":"6505552","body":"Message 2","date":1704070800000,"dateSent":0,"locked":0,"protocol":null,"read":1,"status":-1,"type":2,"serviceCenter":null,"backupType":"sms"}
,{"subscriptionId":1,"address":"6505553","body":"Message 3","date":1704074400000,"dateSent":0,"locked":0,"protocol":null,"read":1,"status":-1,"type":1,"serviceCenter":null,"backupType":"sms"}
]

(This has three conversations with messages dated 1 Jan 2024.)

Expected behavior

In the main view, the conversations should be sorted by the time of the last message (as usual).

Actual behavior

The timestamps of the conversations are set to the time of the import rather than the time of the last message in the conversation, so the conversations appear in a random order.

Screenshots/Screen recordings

See #88 (comment)

Analysis and workarounds

This is a bug in Android, see Stack Overflow. The suggested workaround is to insert a dummy message and then delete it, because that causes the conversation's date to be recalculated.

One of the answers uses getContentResolver().delete(Uri.parse("content://sms/conversations/-1"), null, null);, which works on Android 8.1, however it fails on Android 14 with

java.lang.IllegalArgumentException: Unknown URL
	at com.android.providers.telephony.SmsProvider.delete(SmsProvider.java:1138)
	at android.content.ContentProvider.delete(ContentProvider.java:1995)
	at android.content.ContentProvider$Transport.delete(ContentProvider.java:546)
	at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:227)
	at android.os.Binder.execTransactInternal(Binder.java:1339)
	at android.os.Binder.execTransact(Binder.java:1275)

Looking at the Android source, I think we'd have to actually insert a dummy message. One idea is to insert & delete a dummy message in each conversation. But it might be possible to update all the conversations using a single dummy message -- see the SMS_ALL branch. I'm still investigating.

Update: I found a workaround (comment, rough commit), turns out there is another way to update threads and the app's code already made use of it, but it had a bug that needed to be fixed. I need to do some more work on my patch (make it faster and document it), then I'll open a PR.

Credit

Issue originally reported by @Abcd1234-dot in #88 (comment)

@tom93 tom93 added bug Something is not working needs triage Issue is not yet ready for PR authors to take up labels Mar 22, 2024
@Aga-C
Copy link
Member

Aga-C commented Mar 22, 2024

It looks like another case of already reported bug: #42.

@Aga-C Aga-C closed this as not planned Won't fix, can't repro, duplicate, stale Mar 22, 2024
@Aga-C Aga-C added duplicate This issue or pull request already exists and removed bug Something is not working needs triage Issue is not yet ready for PR authors to take up labels Mar 22, 2024
@tom93
Copy link
Contributor Author

tom93 commented Mar 22, 2024

Oops, I missed it.

@tom93
Copy link
Contributor Author

tom93 commented Mar 22, 2024

Actually, I'm not sure if it's the same -- this issue is about importing from a .json file using Settings > Import messages, while the others seem to be about automatic import when the app is opened for the first time. (I've edited this issue to clarify.) Edit: The conversation in the linked issue does mention .json files, not sure if it's relevant.

@Aga-C
Copy link
Member

Aga-C commented Mar 22, 2024

The problem there wasn't about auto-importing on the first run. They imported messages from backup in another app and had wrong dates on conversation list in Simple/Fossify Messages. I think it's the same problem, just reproduction steps doesn't involve another app.

@tom93
Copy link
Contributor Author

tom93 commented Mar 22, 2024

I see, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants