搜索

430

主题

515

帖子

2136

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2136
QQ
发表于 2020-8-17 20:00:08 8046 浏览 0 回复

MTK 如何更改NTP 服务器地址

How to add custom NTP server

[DESCRIPTION]
       When use AUTO-Time through network, Android will update system time from NTP server. The default server is "time.android.com". In some region handset can't connect to this server every time, Then handset will take several minutes to synchronize time or even failed. We may want to change to an internal server to get better performance.

[SOLUTION]
How to change server address?
There are three ways:
1. Change Android default server address. Replace value "config_ntpServer" in "/frameworks/base/core/res/res/values/config.xml" with your own server address.
2. Overlay Android default server address. Add new file in "/device/mediatek/system/common/overlay/ntp/frameworks/base/core/res/res/values/config.xml", overlay value "config_ntpServer" with your own server address, add this path to PRODUCT_PACKAGE_OVERLAYS in device.mk.
3. Add your server in NetworkTimeUpdateService.java. use ((NtpTrustedTime) mTime).setServer(custom_server) to set custom NTP server before call mTime.forceRefresh(). Then
      NtpTrustedTime will connect to custom_server to update time.

How to verify modify?
initialization:
       Make sure handset can access internet, enter settings -> Date & time, enable Automatic time from network. Disable Automatic time zone.
      
test:
       reboot phone, check mainlog/syslog:
  1. 07-12 08:56:09.770370   943   943 D NtpTrustedTime: getServer:[time.android.com]   // this address should be custom server
  2. 07-12 08:57:07.184321   943  1172 D NetworkTimeUpdateService: New default network 100; checking time.
  3. 07-12 08:57:07.184816   943  1172 D NetworkTimeUpdateService: onPollNetworkTime start
  4. 07-12 08:57:07.191897   943  1172 D NetworkTimeUpdateService: Stale NTP fix; forcing refresh
  5. 07-12 08:57:07.192420   943  1172 D NetworkTimeUpdateService: mTryAgainCounter = 0;mNtpServers.size() = 3;index = 0;mNtpServers = time.android.com
  6. 07-12 08:57:07.192835   943  1172 D NtpTrustedTime: setServer:[time.android.com]
  7. 07-12 08:57:07.555810   943  1172 D SntpClient: round trip: 84ms, clock offset: 200ms  // means success
复制代码



手机微信同号:13682654092
回复

使用道具 举报

返回列表
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


登录或注册
快速回复 返回顶部 返回列表