修改Android系统初始时间

在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);
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容