summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@android.com>2010-10-11 13:00:51 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-10-11 13:00:51 -0700
commitce2f1909c74a1b90995f06a865d21260b062300b (patch)
treefc01499a53e89cbe47ee129149da601ab60b95d3 /services/java
parenta7c76d8307a3b49bf5b8fdda3543455b0e5dd64c (diff)
parent35ca9d8a357d3e8c514740ebdbab154e865fdbbf (diff)
downloadframeworks_base-ce2f1909c74a1b90995f06a865d21260b062300b.zip
frameworks_base-ce2f1909c74a1b90995f06a865d21260b062300b.tar.gz
frameworks_base-ce2f1909c74a1b90995f06a865d21260b062300b.tar.bz2
Merge "On boot, advance time to at least 1970." into gingerbread
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/SystemServer.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 7f42429..a7785e2 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -35,7 +35,12 @@ import android.content.pm.IPackageManager;
import android.database.ContentObserver;
import android.database.Cursor;
import android.media.AudioService;
-import android.os.*;
+import android.os.Looper;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.StrictMode;
+import android.os.SystemClock;
+import android.os.SystemProperties;
import android.provider.Contacts.People;
import android.provider.Settings;
import android.server.BluetoothA2dpService;
@@ -581,6 +586,16 @@ public class SystemServer
native public static void init1(String[] args);
public static void main(String[] args) {
+ if (System.currentTimeMillis() < 0) {
+ // 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
+ }
+
if (SamplingProfilerIntegration.isEnabled()) {
SamplingProfilerIntegration.start();
timer = new Timer();