diff options
3 files changed, 47 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java index d066056145da..8ce4e64b1925 100644 --- a/services/core/java/com/android/server/AlarmManagerService.java +++ b/services/core/java/com/android/server/AlarmManagerService.java @@ -1868,6 +1868,7 @@ class AlarmManagerService extends SystemService { final long nowRTC = System.currentTimeMillis(); final long nowELAPSED = SystemClock.elapsedRealtime(); + final long nowUPTIME = SystemClock.uptimeMillis(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); pw.print(" nowRTC="); pw.print(nowRTC); @@ -1883,6 +1884,25 @@ class AlarmManagerService extends SystemService { pw.print(" mLastTickSet="); pw.println(sdf.format(new Date(mLastTickSet))); pw.print(" mLastTickAdded="); pw.println(sdf.format(new Date(mLastTickAdded))); pw.print(" mLastTickRemoved="); pw.println(sdf.format(new Date(mLastTickRemoved))); + + SystemServiceManager ssm = LocalServices.getService(SystemServiceManager.class); + if (ssm != null) { + pw.println(); + pw.print(" RuntimeStarted="); + pw.print(sdf.format( + new Date(nowRTC - nowELAPSED + ssm.getRuntimeStartElapsedTime()))); + if (ssm.isRuntimeRestarted()) { + pw.print(" (Runtime restarted)"); + } + pw.println(); + pw.print(" Runtime uptime (elapsed): "); + TimeUtils.formatDuration(nowELAPSED, ssm.getRuntimeStartElapsedTime(), pw); + pw.println(); + pw.print(" Runtime uptime (uptime): "); + TimeUtils.formatDuration(nowUPTIME, ssm.getRuntimeStartUptime(), pw); + pw.println(); + } + pw.println(); if (!mInteractive) { pw.print(" Time since non-interactive: "); diff --git a/services/core/java/com/android/server/SystemServiceManager.java b/services/core/java/com/android/server/SystemServiceManager.java index 581914db4bfa..63584d9e43e5 100644 --- a/services/core/java/com/android/server/SystemServiceManager.java +++ b/services/core/java/com/android/server/SystemServiceManager.java @@ -39,6 +39,8 @@ public class SystemServiceManager { private final Context mContext; private boolean mSafeMode; private boolean mRuntimeRestarted; + private long mRuntimeStartElapsedTime; + private long mRuntimeStartUptime; // Services that should receive lifecycle events. private final ArrayList<SystemService> mServices = new ArrayList<SystemService>(); @@ -287,8 +289,25 @@ public class SystemServiceManager { return mRuntimeRestarted; } - void setRuntimeRestarted(boolean runtimeRestarted) { + /** + * @return Time when SystemServer was started, in elapsed realtime. + */ + public long getRuntimeStartElapsedTime() { + return mRuntimeStartElapsedTime; + } + + /** + * @return Time when SystemServer was started, in uptime. + */ + public long getRuntimeStartUptime() { + return mRuntimeStartUptime; + } + + void setStartInfo(boolean runtimeRestarted, + long runtimeStartElapsedTime, long runtimeStartUptime) { mRuntimeRestarted = runtimeRestarted; + mRuntimeStartElapsedTime = runtimeStartElapsedTime; + mRuntimeStartUptime = runtimeStartUptime; } private void warnIfTooLong(long duration, SystemService service, String operation) { diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 625992633213..165aaac6a42c 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -261,6 +261,8 @@ public final class SystemServer { private boolean mOnlyCore; private boolean mFirstBoot; private final boolean mRuntimeRestart; + private final long mRuntimeStartElapsedTime; + private final long mRuntimeStartUptime; private static final String START_SENSOR_SERVICE = "StartSensorService"; private static final String START_HIDL_SERVICES = "StartHidlServices"; @@ -292,6 +294,9 @@ public final class SystemServer { mFactoryTestMode = FactoryTest.getMode(); // Remember if it's runtime restart(when sys.boot_completed is already set) or reboot mRuntimeRestart = "1".equals(SystemProperties.get("sys.boot_completed")); + + mRuntimeStartElapsedTime = SystemClock.elapsedRealtime(); + mRuntimeStartUptime = SystemClock.uptimeMillis(); } private void run() { @@ -402,7 +407,8 @@ public final class SystemServer { // Create the system service manager. mSystemServiceManager = new SystemServiceManager(mSystemContext); - mSystemServiceManager.setRuntimeRestarted(mRuntimeRestart); + mSystemServiceManager.setStartInfo(mRuntimeRestart, + mRuntimeStartElapsedTime, mRuntimeStartUptime); LocalServices.addService(SystemServiceManager.class, mSystemServiceManager); // Prepare the thread pool for init tasks that can be parallelized SystemServerInitThreadPool.get(); |