-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Importing messages silently skips some based on sub_id #128
Comments
Thanks for reporting this - I have confirmed the problem. I see that others have reported similar problems and solutions with the SMS Backup and Restore app (which was an inspiration for SMS Import / Export) - see this thread, and this message and this one in particular. This is apparently a new problem with Android 14 / API level 34 - I reproduced the problem with the file you provided on an API level 34 AVD, but all three messages imported properly on an API level 31 AVD. I'm not sure what to do with this - at this point, it seems to be an Android problem rather than an app problem, but it may be worth implementing some sort of workaround. I'll have to keep an eye on that thread and the internet in general to see how this shakes out. |
I experienced a very similar issue. I tried exporting a few years worth of SMS/MMS messages from a Pixel 3a running stock Android 12 to a Pixel 7 running Grapheneos Android 14. I used version 2.2.0 of the app (installed via the APK provided in the GitHub Releases section of this repo). I exported several thousuand SMS and MMSs from the Pixel 3a, copied the ZIP file over to the Pixel 7, and ran the Import Messages function, which shows that the same number of SMS and MMS were imported. I checked the data in the zip file and it appears to all be present. However, when I then opened the messaging app, only 3 messages from one sender were successfully imported. All the other messages appear to be missing. I tried clearing the app storage and cache, re-exporting and importing, and using another messaging app (initially using the default Grapheneos Messaging app, then tried QKSMS) and all produced the same results, with only the same 3 messages showing up. The only difference in my case is that the 3 messages which were imported all had To fix this, I followed these steps:
This worked, and all my SMS and MMS messages were now visible in both the default Messaging app and QKSMS. I'm not sure what the intended use and meaning of |
I think I know what's going on: the
It seems that up until Android 14, Android would happily insert messages regardless of their One solution would therefore be to just automatically (perhaps controlled by a settings toggle) set all |
Previously, sub_ids were included in message import. On Android 14 (API level 34), this causes messages with certain sub_ids to (silently) fail to import. Preservation of sub_ids is of limited benefit anyway, since the sub_ids on the target device may not correspond to those of the source device. The default behavior has therefore been changed to set all sub_ids to "-1" upon import, since negative values indicate that "the sub_id cannot be determined": https://developer.android.com/reference/android/provider/Telephony.TextBasedSmsColumns#SUBSCRIPTION_ID The old behavior is still available via a settings toggle. Addresses: #118, #128
I've pushed a commit that sets all sub_ids to |
So my guess is that the new api behavior only imports the messages for the sub id that exist on the phone? For example: If you had two sims turned on, with sub id 1 and 2 respectively, I suspect that Android would import messages with sub id 1 and 2 just fine. But if the device only contained 1 sim, then it would only import the messages corresponding with that Sim's sub id. Haven't tested this out |
Another data point as this seems the most comprehensive coverage of this issue (I use SMS Backup and Restore, but came across this app while investigating the issue). Unlike most reports, I wasn't restoring or migrating, but only noticed the behaviour while backing up post Android 14, so I think it's worth documenting that it's not just about trying to restore new messages:
Open questions:
|
This is a great contribution toward figuring out this issue - thank you!
I'll bet it's indeed a caching issue - see here (paragraph beginning "Note").
I suspect #1 or #3 - this would explain something that's been bothering me about this whole issue: if Android 14 has simply begun to refuse to insert messages with "improper" Subscription IDs into the message databases, why isn't it reporting this failure in response to the insert call? Based on your analysis, it seems that it's not actually the import that's failing; rather, Android is subsequently deleting or hiding messages with Subscription IDs that it doesn't like. |
Yes, I was hoping another would come to the same conclusion - it may also explain the Chomp behaviour, as the counts may be reflecting hidden duplicates with bad sub_ids |
https://xdaforums.com/t/solved-sms-backup-restoring-to-wrong-sim.4580147/ Might be worth digging into this db? |
You can check whether the problem is due to caching or something else by clearing the cache, as per the link I posted above, and seeing whether the discrepancy remains.
See also here. |
It actually never occurred to me to have messages associated to a SIM card (vs phone number which makes a bit more sense to me). If they are being suppressed due to a missing entry in the sub db then an alternative solution might be to add that entry in the db. Edit: I just cleared the data from Chomp and the counts are still incorrect (but make sense if the bad sub_id messages are still being counted) |
I'm not sure what that would mean. Android has the |
Sorry about the delay, but I finally got around to testing, and the update fixed my issue. I see that there has been some discussion after the fix was pushed, so I'm not sure if you still want this open for tracking something with that, but as far as my original issue goes, I'm content to close the issue. |
Some MMS part metadata apparently contain a sub_id field (despite the absence of any mention of this in the API documentation at https://developer.android.com/reference/android/provider/Telephony.Mms.Part), and attempting to import these sub_ids can cause the app to crash with a FileNotFoundException: No entry for content. This is probably related to #128. In any event, this commit fixes the problem by extending the solution to that issue (c56fa0e) to MMS part metadata sub_ids. Addresses: #142 Related: #128
The issue and the solution(the app converting all sub_id to -1) also makes SMS apps to show imported messages timestamps to fall on the date of import rather the date of sent/received in the list view. Upon opening the message, it shows correct date time. |
Thanks for reporting this; I'm looking into it. |
I'm not sure if I should create a separate issue, because it's not strictly related to sub IDs, but I found that messages having spaces in the |
Thank you for reporting this - I'll take a look. |
I would like to suggest that the meaning of the new setting "Include Subscription IDs in import" is too obscure to be a generally visible setting without further explanation. I came across this when setting up for a restore for the first time, and it took me quite some digging to find this issue where the problem and work-around is discussed, and even then I'm not 100% sure whether it will work in my current case. If we can come up with an attached explanation, something simple but complete enough, then that explanation should be included. Otherwise, I should think the option should be in the "Debugging options" section. A really good solution might involve scanning the sub-IDs present in a requested import, comparing them with the sub-IDs reported by the phone, and taking different actions or warn/ask the user what to do based on whether that looks like a good enough match. (Details to be fleshed out.) |
The "Include Subscription IDs in import" setting is clearly documented in the README.
If someone wants to flesh out the details and / or write some code, I'll be happy to take a look :) |
Don't skip messages whose addresses contain spaces upon insertion. Commit 2f07074 (don't insert SMS messages whose addresses contain spaces, since they're assumed to be group SMS messages which we don't know how to handle correctly) introduced a regression of single recipient SMS messages whose addresses contain spaces being skipped upon insertion. Revert this change. Addresses: #159, #205, #128
Some MMS address metadata apparently contain a sub_id field (despite the absence of any mention of this in the API documentation at https://developer.android.com/reference/android/provider/Telephony.Mms.Addr), and attempting to import these sub_ids can cause address import failure. This is probably related to #128. In any event, this commit fixes the problem by extending the solution to that issue (c56fa0e) to MMS address metadata sub_ids. This commit also corrects a coding error that caused MMS addresses to be inserted multiple times. Closes: #213 Related: #128, #142
I exported my messages to transfer them to another device, and the app specified how many SMS and MMS messages were exported, and on the other device it said that same number of messages were imported, but when I went to my SMS app, I noticed it was missing messages. I then tried exporting the messages from the new device, and it said it exported less messages than before.
I did some digging in the export files to compare the difference between messages that got imported and those that failed, and I found that if sub_id was set to 2, they didn't import. I found a mix of -1, 1, and 2 for the values. I'm not sure what that means, but the import skipped 2 for some reason.
I created a sample file to test:
As I expected, when I imported, it reported 3 SMS imported, but my SMS app only showed the 2 messages with sub_id set to -1 and 1, but skipped the one set to 2.
I did a simple find and replace on my original export to change all
"sub_id":"2"
to"sub_id":"1"
, and I was able to do the import successfully with that.The text was updated successfully, but these errors were encountered: