|
发表于 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:
- 07-12 08:56:09.770370 943 943 D NtpTrustedTime: getServer:[time.android.com] // this address should be custom server
- 07-12 08:57:07.184321 943 1172 D NetworkTimeUpdateService: New default network 100; checking time.
- 07-12 08:57:07.184816 943 1172 D NetworkTimeUpdateService: onPollNetworkTime start
- 07-12 08:57:07.191897 943 1172 D NetworkTimeUpdateService: Stale NTP fix; forcing refresh
- 07-12 08:57:07.192420 943 1172 D NetworkTimeUpdateService: mTryAgainCounter = 0;mNtpServers.size() = 3;index = 0;mNtpServers = time.android.com
- 07-12 08:57:07.192835 943 1172 D NtpTrustedTime: setServer:[time.android.com]
- 07-12 08:57:07.555810 943 1172 D SntpClient: round trip: 84ms, clock offset: 200ms // means success
复制代码
|
|
手机微信同号:13682654092
|
|
|
|
|
登录或注册
|