I'm developing an app where I get to retrieve current date in several places, by using new Date()
, I'd like that if the user has changed the date in the phone it's not allowed to take the date as it's wrong.
Due to the nature of the application, it's possible that when the operation that takes the date is done, there may be no internet connection, so instead of dealing with something like an NTP server, we can more and less ensure that the date is correct if the user has options Use network date/time and Use network timezone enabled and he has connectivity to telephony network (sure, if may be possible to tamper the date but it looks secure enough).
Problem is that it may be also be possible that there may be no telephony network where the phone is being used and I've checked the following:
You can disable Use network date/time and set a date of your liking.
You activate airplane mode (or similar no connectivity situation)
You restart the phone.
You enable Use network date/time.
Now, despite having set Use network date/time and Use network timezone, there's an incorrect date on the phone. Indeed, if I quit airplane mode date is properly set again.
Maybe a situation like the previous could be detected with something like a service that checks that the user has restarted the phone, and then a service at phone startup that determines date is taken again properly, so then app checks that service says that it's properly taken and so it allows the user to take it... But all this seems hard to do and we may bug honest users that had to restart their phones in a zone with no telephony connectivity and then try to use the app without trying to trick other date.
So, any idea on a not too complicated method and no bugging for honest users that could achieve getting the date with no connectivity of any class? Or is this impossible?