Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2af4c51e authored by Brad Fitzpatrick's avatar Brad Fitzpatrick Committed by Android Git Automerger
Browse files

am 6bb7a4a6: Go one day into 1970 for timezone code.

Merge commit '6bb7a4a6' into gingerbread-plus-aosp

* commit '6bb7a4a6':
  Go one day into 1970 for timezone code.
parents 14d151bf 6bb7a4a6
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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()) {