[Verizon Samsung Galaxy S III] androcheck:
Hi!

I'm the developer of "SMS Sent Time". I haven't been active here on xda for some time now but I got noticed about your thread via Google Alerts and I thought I will use this occasion to bring some light into the overall situation:

Sorry, the post got much longer than intended, but there was so much to explain... :)

How SMS receiving works in general:

Your mobile network sends you a PDU (protocol data unit) packet containing a SMS message. This PDU format also contains a timestamp field which is filled by the SMSC server of the SMS sender. In most of the times this timestamp == sent time (the time when the SMSC of the sender's mobile network received the message by the sender's phone). However some obscure mobile network providers around the world seem to insert a wrong time into this field (mostly because of wrong set timezone settings, UTC time vs. local time, applying wrong timezone values, etc., you can imagine.. ).

How SMS are received/stored in Android

In Android there exists a system wide database where the received SMS messages get stored into. When a SMS arrives, a system service parses the raw PDU packet it received from the modem part of your phone and stores the SMS data into the system database. The user then can use any SMS application he likes (the default one, GoSMS, HandcentSMS, etc..) to display the messages from this global system SMS database. All SMS apps access the same underlying Android system SMS database.

The problem:

When implementing this SMS database and the receiving service Google made 2 decisions:

they decided that the timestamp from the provider might not be reliable and

they initially only included ONE "date" field in the system database (you can see the structure of this database table in old Android 2.2 here: Android 2.2 SMS database structure).

As a result we ended up having only one time field for a SMS and the SMS receiver service filled this time field with the current time when it receives the SMS (because it doesn't trust the SMSC timestamp).

What SMS Sent Time does:

Given this situation (and not liking it) I realized a few years ago that it is possible for any application in Android (of course only with the according permissions) to register for incoming SMS Intents (simply register a rceiver for "android.provider.Telephony.SMS_RECEIVED" in the app). When doing this the Android system informs the app on any incoming SMS and also lets it access the data from the raw PDU packet received from the network provider (more or less).

So in this moment (when receiving the SMS) the information about the SMSC timestamp is still available!! This was all I needed to build the SMS Sent Time application. But first I had some troubles when modifying the SMS database, mostly because of the fact, that my app first needs to wait until the system service has stored the SMS into the database and then my app has to reliably find the very same sms in the database. But when the message is found the app can modify it (prior to Android 4.4). So the app also could easily change the date field (instead appending it to the text). I was thinking about doing this, but then I got unsure that this might mess up the sort order in some SMS apps when I receive some SMS with a really completly wrong timestamp. So - just to be on the safe side - I decided to append it to the text (which didn't bother me personally).

I also have to say that at this point in time I had no intentions to make this application ever public. This was just meant as a quick hack for myself. Only some time later when I realized that a lot of more people are facing the same problem I decided to publish it. But it still was and is a quick hack for myself. I have not the resources (mostly time) to invest more work. I develop on Android only in my free time and never made a single cent with this app (no donations, no ads) but spent over the years hundreds of hours (including answering a lot of users' mails). So I was glad when people started asking me for the source code (it's public on GitHub: SMS Sent Time on Github) hoping different/improved solutions might arise...

What Google learned about this:

There existed a loooong time bug-report on exact this issue (sorry cannot find the link at the moment) where a lot of users where complaining about exactly this problem (sent time != received time). So Google finally listened to its users and changed the format of the SMS system database beginning Android 4 (AFAIK). You can see it here, if we look at the same database code as above in Version 4.0.3: Android 4.0.3 SMS database structure you will notice that now there is an additional field "date_sent" in the database table! Hooray! :victory: Finally! :)

Unfortunately the Android world is very fragmented and every phone manufacturer seems to go its own ways. So not all phones with Android >4.0 did implement this change or even if they did inherit this part of the Android core system they often did not update their SMS applications! :(

The same applies for 3rd party SMS apps. For example: I have a Nexus 4 running a cyanogen-based 4.4.1 and I can confirm that in my system database both date fields are filled correctly. So the sent time is definitely there! But neither "Go SMS Pro" nor "Handcent SMS" seem to display this second field (please correct me if I am wrong, I just made a quick test, I normally don't use these apps). Only the original AOSP SMS app and Google Hangout (when used as SMS app) seem to display both times (sent and received) in message details.

New limitations with Android KitKat (4.4):

Additionally another change came along the road when Google introduced Android 4.4 (KitKat). Suddenly a lot of users reported that SMS Sent Time stopped working for them. The background: Starting with Android 4.4 Google introduced the concept of a "default SMS app". The user has to choose, which app should be the default application for handling incoming SMS on the phone. While other SMS apps (for example like my SMS Sent Time) still are able to receive incoming SMS (and read the sent time) they are no longer allowed to modify the content of the system's SMS database (even with the correct permissions in place). The database update silently fails. :( Sad enough this is a fact and there is nothing I can do in my app to change this. It's a security feature of Android which I cannot change. (And the reason why I am writing a lot of feedback mails to users lately.)

Workaround:

But at least there is a known "workaround" to overcome this new KitKat limitation (altough it seems that Google decided to remove this possibility with the update from 4.4.1 to 4.4.2). In Android 4.4 there exists a hidden settings screen ("AppOps") which allows you to grant or deny specific permissions to applications. You cannot open this settings screen directly from the system settings, but there are some apps in the Play Store which do nothing else, than just opening this (already existing but hidden) settings screen. For example, I used the app App Ops Starter. This simple app needs no permissions and does nothing else then opening Android's hidden "app ops" settings screen. Once opened, on the tab "Messaging", you see a list with all your installed apps which have sms-permissions. If you open the settings page for one specific app you can grant the permission "Write SMS/MMS" again and the system will behave again like it did before Android 4.4.

So, long story short:

It's been a long time with this problem in the Android world. Hopefully workarounds like my app should not be needed in future (when all SMS apps make use of the "date_sent" field in the SMS database).

Until then it would be possible to modify the SMS Sent Time app to overwrite the datestamp field in the database (instead appending the time to the message text). Any develper should feel free to take the source code and modify it accordingly. :)

[edit]

corrected spelling

[/edit]