Android 10.0 framework设备联网后系统时间没有自动同步更新的修改

在定制化10.0的产品开发中,在产品联网后会自动同步时间,开始以为是设备的网络问题,咨询同事和百度发现谷歌服务器
会出现在大陆时间同步更新延迟的情况 所以需要增加一些国内的域名来更新系统时间
在NtpTrustedTime.java中 专门负责更新系统时间
首选看下它的源码
路径: /frameworks/base/core/java/android/util/NtpTrustedTime.java

public boolean forceRefresh() {
   
    
    
// We can't do this at initialization time: ConnectivityService might not be running yet.
synchronized (this) {
if (mCM == null) {
mCM = sContext.getSystemService(ConnectivityManager.class);
}
}
    final Network network = mCM == null ? null : mCM.getActiveNetwork();
    return forceRefresh(network);
}

public boolean forceRefresh(Network network) {
    if (TextUtils.isEmpty(mServer)) {
        // missing server, so no trusted time availabl

猜你喜欢

转载自blog.csdn.net/baidu_41666295/article/details/124716894