美文网首页
修改Android系统初始时间

修改Android系统初始时间

作者: Smart_Arvin | 来源:发表于2016-12-31 18:16 被阅读556次

在android系统的设备上,都有一个默认的开始日期,看过很多设备,有些设备在没有联网的时候没有同步到系统时间的时候,默认的一般是1970年或1969年,当然人为修改后可能就不同了。至于要怎么修改系统初始默认时间,看下文:

代码路径: frameworks\base\services\java\com\android\server\SystemServer.java
不多说了,逻辑简单,一眼就能理解了

 public static void main(String[] args) {

...
  if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) {
        // If a device's clock is before 1970 (before 0), a lot of
        // APIs crash dealing with negative numbers, notably
        // java.io.File#setLastModified, so instead we fake it and
        // hope that time from cell towers or NTP fixes it shortly.
        Slog.w(TAG, "System clock is before 1970; setting to 1970.");
        SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME);
    }

相关文章

网友评论

      本文标题:修改Android系统初始时间

      本文链接:https://www.haomeiwen.com/subject/vtqbvttx.html