在android系統(tǒng)的設(shè)備上,都有一個(gè)默認(rèn)的開始日期衷佃,看過很多設(shè)備锌历,有些設(shè)備在沒有聯(lián)網(wǎng)的時(shí)候沒有同步到系統(tǒng)時(shí)間的時(shí)候鼎俘,默認(rèn)的一般是1970年或1969年,當(dāng)然人為修改后可能就不同了辩涝。至于要怎么修改系統(tǒng)初始默認(rèn)時(shí)間贸伐,看下文:
代碼路徑: frameworks\base\services\java\com\android\server\SystemServer.java
不多說了,邏輯簡(jiǎn)單怔揩,一眼就能理解了
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);
}