首页 > 其他分享 >android NTP服务器设置

android NTP服务器设置

时间:2022-12-16 14:24:21浏览次数:75  
标签:https NTP aliyun ntp 服务器 android com final

更改 Android 设备 NTP 服务器

adb shell setprop persist.sys.timezone Asia/Shanghai

adb shell settings put global ntp_server ntp.aliyun.com
adb shell settings get global ntp_server
adb reboot

手机重启联网自动校时


NPT 服务器列表
Area           HostName

Worldwide       pool.ntp.org
Asia         asia.pool.ntp.org
Europe       europe.pool.ntp.org
North America    north-america.pool.ntp.org
Oceania        oceania.pool.ntp.org
South America      south-america.pool.ntp.org

阿里云

https://help.aliyun.com/document_detail/92704.html

  • ntp.aliyun.com
  • ntp1.aliyun.com
  • ntp2.aliyun.com
  • ntp3.aliyun.com
  • ntp4.aliyun.com
  • ntp5.aliyun.com
  • ntp6.aliyun.com
  • ntp7.aliyun.com

Google

https://developers.google.com/time

  • time1.google.com
  • time2.google.com
  • time3.google.com
  • time4.google.com

CloudFlare

https://www.cloudflare.com/time/

  • time.cloudflare.com

Microsoft

  • time.windows.com

 

ntp android source code and configs:

https://android.googlesource.com/platform/frameworks/base/+/android-6.0.1_r21/core/res/res/values/config.xml

<string translatable="false" name="config_ntpServer">2.android.pool.ntp.org</string>

https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/util/NtpTrustedTime.java

public class NtpTrustedTime implements TrustedTime {
    ...
    public static synchronized NtpTrustedTime getInstance(Context context) {
        if (sSingleton == null) {
            final Resources res = context.getResources();
            final ContentResolver resolver = context.getContentResolver();
            final String defaultServer = res.getString(
                    com.android.internal.R.string.config_ntpServer);
            final long defaultTimeout = res.getInteger(
                    com.android.internal.R.integer.config_ntpTimeout);
            final String secureServer = Settings.Global.getString(
                    resolver, Settings.Global.NTP_SERVER);
            final long timeout = Settings.Global.getLong(
                    resolver, Settings.Global.NTP_TIMEOUT, defaultTimeout);
            final String server = secureServer != null ? secureServer : defaultServer;
            sSingleton = new NtpTrustedTime(server, timeout);
            sContext = context;
        }
        return sSingleton;
    }
}

refs:

https://liuzesen.com/2020/05/10/%E6%9B%B4%E6%94%B9Android%E8%AE%BE%E5%A4%87NTP%E6%9C%8D%E5%8A%A1%E5%99%A8/

https://zhuanlan.zhihu.com/p/32518769

标签:https,NTP,aliyun,ntp,服务器,android,com,final
From: https://www.cnblogs.com/bluestorm/p/16987248.html

相关文章