Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Android using NTP to sync time?

Do Android Devices use the network time protocol (NTP) to synchronize the time?

In my Device-Settings I see a checkbox with the following text "synchronize with network", but I don't know if they are using NTP.

I need this for my Bachelor Thesis for which I use GPS. To get an accurate GPS-signal the receiver should have an exact clock.

I have found this blog-entry on the web, but I'm not sure if he tells the truth: Speeding up NTP, GPS Lock in Android

like image 242
iTamp Avatar asked Jan 17 '13 14:01

iTamp


People also ask

What time server does Android use?

This page focuses on the Network Time Protocol (NTP) and Network Identity and Time Zone (NITZ) automatic time sources. By default in Android 12 or higher, the framework prioritizes NTP as the time source over NITZ because NTP is more accurate and reliable than NITZ.

How do I set NTP time on my phone?

Tap on the hamburger menu and then on Generator. Choose the DeviceConfig file, then expand the following options: 'DeviceConfig' > 'System' > 'Date and Time' Set the value of 'auto_time' to 1. Set the value of 'ntp_server' to the required NTP server name or IP address.


2 Answers

I know about Android ICS that it uses a custom service called: NetworkTimeUpdateService. This service also implements a NTP time synchronization via the NtpTrustedTime singleton.

In NtpTrustedTime the default NTP server is requested from the Android system string source:

final Resources res = context.getResources();  final String defaultServer = res.getString(                                 com.android.internal.R.string.config_ntpServer); 

If the automatic time sync option in the system settings is checked and no NITZ time service is available then the time will be synchronized with the NTP server from com.android.internal.R.string.config_ntpServer.

To get the value of com.android.internal.R.string.config_ntpServer you can use the following method:

    final Resources res = this.getResources();     final int id = Resources.getSystem().getIdentifier(                        "config_ntpServer", "string","android");     final String defaultServer = res.getString(id); 
like image 157
Dyonisos Avatar answered Sep 19 '22 19:09

Dyonisos


i wanted to ask if Android Devices uses the network time protocol (ntp) to synchronize the time.

For general time synchronization, devices with telephony capability, where the wireless provider provides NITZ information, will use NITZ. My understanding is that NTP is used in other circumstances: NITZ-free wireless providers, WiFi-only, etc.

Your cited blog post suggests another circumstance: on-demand time synchronization in support of GPS. That is certainly conceivable, though I do not know whether it is used or not.

like image 20
CommonsWare Avatar answered Sep 18 '22 19:09

CommonsWare