当前位置:   article > 正文

Android7.1修改NTP地址_android7.1 修改当前默认的ntp服务器url

android7.1 修改当前默认的ntp服务器url

说明

    android系统默认的请求更新系统时间的服务器是谷歌的时间服务器,国内谷歌服务器用不了,那么我们想要更新系统时间,就需要更改NTP服务器地址为阿里的。

实现

  

  1. zhoujy@TP:~/data/android/sc826_cn_01_00/msm_8953_git/frameworks$ git show 287e1af59248e9a8b45c7b11b1a13ceb55695661
  2. commit 287e1af59248e9a8b45c7b11b1a13ceb55695661
  3. Author: zhoujinyan <zhoujy@ibumobile.com>
  4. Date: Sun Jun 28 19:43:06 2020 +0800
  5. [frameworks]修改NTP地址
  6. diff --git a/frameworks/base/core/java/android/util/NtpTrustedTime.java b/frameworks/base/core/java/android/util/NtpTrustedTime.java
  7. index ed2d3c6..7b822d0 100644
  8. --- a/frameworks/base/core/java/android/util/NtpTrustedTime.java
  9. +++ b/frameworks/base/core/java/android/util/NtpTrustedTime.java
  10. @@ -99,7 +99,7 @@ public class NtpTrustedTime implements TrustedTime {
  11. }
  12. - if (LOGD) Log.d(TAG, "forceRefresh() from cache miss");
  13. + if (LOGD) Log.d(TAG, "forceRefresh() from cache miss mTimeout = " + mTimeout);
  14. final SntpClient client = new SntpClient();
  15. if (client.requestTime(mServer, (int) mTimeout)) {
  16. mHasCache = true;
  17. @@ -108,6 +108,16 @@ public class NtpTrustedTime implements TrustedTime {
  18. mCachedNtpCertainty = client.getRoundTripTime() / 2;
  19. return true;
  20. } else {
  21. + Log.d(TAG, "mServer = " + mServer + " false");
  22. + String mServerSecond = "3.cn.pool.ntp.org";
  23. + if (client.requestTime(mServerSecond, (int) mTimeout)) {
  24. + mHasCache = true;
  25. + mCachedNtpTime = client.getNtpTime();
  26. + mCachedNtpElapsedRealtime = client.getNtpTimeReference();
  27. + mCachedNtpCertainty = client.getRoundTripTime() / 2;
  28. + return true;
  29. + }
  30. + Log.d(TAG, "mServerSecond = " + mServerSecond + " false");
  31. return false;
  32. }
  33. }
  34. diff --git a/frameworks/base/core/res/res/values/config.xml b/frameworks/base/core/res/res/values/config.xml
  35. index 528d037..5231937e 100755
  36. --- a/frameworks/base/core/res/res/values/config.xml
  37. +++ b/frameworks/base/core/res/res/values/config.xml
  38. @@ -1701,14 +1701,15 @@
  39. <bool name="config_actionMenuItemAllCaps">true</bool>
  40. <!-- Remote server that can provide NTP responses. -->
  41. - <string translatable="false" name="config_ntpServer">2.android.pool.ntp.org</string>
  42. + <!--<string translatable="false" name="config_ntpServer">2.android.pool.ntp.org</string>-->
  43. + <string translatable="false" name="config_ntpServer">ntp-sz.chl.la</string>
  44. <!-- Normal polling frequency in milliseconds -->
  45. <integer name="config_ntpPollingInterval">86400000</integer>
  46. <!-- Try-again polling interval in milliseconds, in case the network request failed -->
  47. <integer name="config_ntpPollingIntervalShorter">60000</integer>
  48. <!-- Number of times to try again with the shorter interval, before backing
  49. off until the normal polling interval. A value < 0 indicates infinite. -->
  50. - <integer name="config_ntpRetry">3</integer>
  51. + <integer name="config_ntpRetry">-1</integer>
  52. <!-- If the time difference is greater than this threshold in milliseconds,
  53. then update the time. -->
  54. <integer name="config_ntpThreshold">5000</integer>

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/797965
推荐阅读
相关标签
  

闽ICP备14008679号