summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2018-12-12 19:10:20 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-12-12 19:10:20 +0000
commit1ba453986c21eda78e5512e574a3c6f4cab2fb78 (patch)
tree86acbf80bfe5a87e79d9f0888bebdaaf0a7c3cff
parent3dc2f1ef5963695131f8524ff52a8a3a4ecb124c (diff)
parent3d65d4d59533d6a789b5c9e901ee89cbff665a23 (diff)
Merge "Be more comprehensive about boot time RTC check"
-rw-r--r--services/core/java/com/android/server/AlarmManagerService.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index 854c03f128dd..08034f734bea 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -48,6 +48,7 @@ import android.content.pm.PermissionInfo;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Binder;
+import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
@@ -1306,8 +1307,12 @@ class AlarmManagerService extends SystemService {
// because kernel doesn't keep this after reboot
setTimeZoneImpl(SystemProperties.get(TIMEZONE_PROPERTY));
- // Also sure that we're booting with a halfway sensible current time
- final long systemBuildTime = Environment.getRootDirectory().lastModified();
+ // Ensure that we're booting with a halfway sensible current time. Use the
+ // most recent of Build.TIME, the root file system's timestamp, and the
+ // value of the ro.build.date.utc system property (which is in seconds).
+ final long systemBuildTime = Long.max(
+ 1000L * SystemProperties.getLong("ro.build.date.utc", -1L),
+ Long.max(Environment.getRootDirectory().lastModified(), Build.TIME));
if (mInjector.getCurrentTimeMillis() < systemBuildTime) {
Slog.i(TAG, "Current time only " + mInjector.getCurrentTimeMillis()
+ ", advancing to build time " + systemBuildTime);