Problems of time and time zones in Android and ways to solve them

Suppose you have been using Android for a long time, and therefore it may seem that it copes with the tasks of time synchronization perfectly - alarms are triggered on time, there are no obvious time deviations, etc. However, are you completely sure where Android comes from actually gets the exact time and time zone data? If you have any doubts about how this works, welcome to cat.

In Android, there are two problems with time: it is its unpredictable synchronization and the need for updating data on time zones even in the latest version of the OS.

Background: Android is a Linux-based mobile OS, it connects quietly to the Internet and, of course, we can assume that time synchronization is carried out using NTP, However, it is not. Historically, Android was intended to be used exclusively in mobile phones (remember version 1.6). At the same time, only in the 3 major version did he acquire an interface for tablets and other progress began to unify the interface and the filling of the OS. However, even versions 4.4 and Android L receive accurate time signals using the same methods that Nokia 3310 and other earlier GSM / 3GPP phones received, i.e. from cell towers when registering on the network (when connected to the tower). In this case, tablets or other devices without a communication module, in principle, are not able to synchronize time automatically.

Unfortunately, to teach Android to synchronize time completely automatically using NTP, we need root access because the API for setting the exact time in Android is now missing.

Let's get started. The first thing to do is turn off the time synchronization with the mobile network. At the same time, I recommend setting the time zone in automatic mode, but you should turn it off only if there is a guarantee that the device will work in stationary mode.

Screenshot of the settings window "Settings -> Date and time" version of Android 4.x:

Next, you need to install the ClockSync application , which will act for us as an alternative to the time synchronization daemon using NTP.

Screenshots of ClockSync window before synchronization (left) and after (right):

The screenshots show that the difference with the exact time turned out to be quite small, however, there are different situations, for some the time on the device may even float back and forth since the operator did not bother to clean up his BS.

After making sure that everything works, set up automatic synchronization in ClockSync. To increase accuracy, I recommend turning on the options “High Accuracy Mode” and “Only via WI-FI”. If everything is clear with the first option from the description in the program (see the screenshot below), then I recommend that you turn on the second option not primarily for reasons of saving mobile traffic, but because the mobile Internet is not able to guarantee at least some stability delays.

A bit more about accuracy:
The still widespread 2nd Mobile Internet (GPRS / EDGE), in principle, is not able to provide stable transmission delays. Even the Internet of the 3rd (3G) and, to some extent, the 4th (LTE / LTE-advanced) generations with a heavy load of the network or communication channels between the BSs, which is a typical situation for large settlements, cannot guarantee stable delays. Therefore, even with approximation, the final accuracy of the time setting can be worse than a fraction of a second and even easily reach a few seconds.

In addition, I recommend that you turn on the “When you turn it on” option so that you do not once again take your device out of deep sleep and thereby save energy.

Screenshot of automatic synchronization settings in ClockSync:

In connection with the large-scale changes in time zones in the Russian Federation in the autumn of this year, it is already necessary to think about updating information on them on all devices and if there are no problems with supported desktop OSs, then in Android even the latest version of the OS contains outdated data. In order to make sure of this, install TimeZone Fixer and observe an unsightly picture.

A screenshot of the TimeZone Fixer program running on Android 4.4.4 (Cyanogenmod firmware dated August 4, 2014), which clearly shows that the data in the firmware is irrelevant:

A bit of common concern and concern for users:
The author of the program TimeZone Fixer warns us that updating time zone data files can completely “break” the device and even gives recommendations on how to protect yourself from additional problems, although there are isolated and very specific cases of problems - this is really a good concern for ordinary users.

That’s why I included this piece in the article, although it is not directly related to the problem, it’s a really good example of caring for users. At the same time, the warning about versions 4.3+ is caused by only a small number of reviews about the program for devices with new versions of the OS, so please, after use, be sure to write a review about this application.

After updating the time zone data, the program suggests restarting, however, I recommend rebooting the device yourself through the system menu since the program reboots is practically equivalent to reset, which, albeit with a low probability, can lead to problems and data loss.

I will be happy to answer any questions or make additions that the community considers necessary, however, I want to avoid overloading the article with additional information in order to adhere to the format of a compact guide to solving a specific problem.

UPD: This instruction completely solves the problem of time zones only for versions under 4.4. Since version 4.4, additional patching is needed, while the question is at the stage of exploring the possibilities for creating a user-friendly solution.

Also popular now: