diff options
| author | 2010-10-11 13:41:10 -0700 | |
|---|---|---|
| committer | 2010-10-11 13:43:51 -0700 | |
| commit | 6bb7a4a68ae79dab56b23d1c7111bf7eb3aa55fe (patch) | |
| tree | 6ea95ac2e49bc512f183c22324c40f37db77964f | |
| parent | ce2f1909c74a1b90995f06a865d21260b062300b (diff) | |
Go one day into 1970 for timezone code.
Change-Id: I80251de79db6684ef3fa1ec835b400d9e3547401
| -rw-r--r-- | services/java/com/android/server/SystemServer.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index a7785e2fdf30..26071ae7e91d 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -578,6 +578,10 @@ public class SystemServer static Timer timer; static final long SNAPSHOT_INTERVAL = 60 * 60 * 1000; // 1hr + // The earliest supported time. We pick one day into 1970, to + // give any timezone code room without going into negative time. + private static final long EARLIEST_SUPPORTED_TIME = 86400 * 1000; + /** * This method is called from Zygote to initialize the system. This will cause the native * services (SurfaceFlinger, AudioFlinger, etc..) to be started. After that it will call back @@ -586,14 +590,14 @@ public class SystemServer native public static void init1(String[] args); public static void main(String[] args) { - if (System.currentTimeMillis() < 0) { + 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(1); // 0 isn't allowed + SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME); } if (SamplingProfilerIntegration.isEnabled()) { |