summaryrefslogtreecommitdiff
path: root/services/java/com
diff options
context:
space:
mode:
author Makoto Onuki <omakoto@google.com> 2019-02-15 15:22:04 -0800
committer Makoto Onuki <omakoto@google.com> 2019-02-20 11:24:28 -0800
commitb4739d9d14d55ce6193f54b3cb248196facf947f (patch)
tree21a5b2f9f496edde1538a117c857e11b8f81df7f /services/java/com
parent32981ff4d406cd44c5e57814088028fecb9bf72f (diff)
Add runtime restart information to sysprops and eventlog
Added 3 more system props: - sys.system_server.start_count How many times the system server has started, 1-based. - sys.system_server.start_elapsed Elapsed time when the system server started most recently - sys.system_server.start_uptime Uptime when the system server started most recently Also log the same information on event log, as 'system_server_start'. Bug: 124022170 Test: manual $ adb logcat -b events -s system_server_start 02-15 23:35:06.151 1222 1222 I system_server_start: [1,4714,4714] (killed the system server) 02-15 23:35:24.673 4209 4209 I system_server_start: [2,23236,23236] $ getprop | grep system_server [sys.system_server.start_count]: [2] [sys.system_server.start_elapsed]: [23236] [sys.system_server.start_uptime]: [23236] Change-Id: Ie3e77903e723eb5b7e79b545d4287d9b07c4b379
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/SystemServer.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index aae159c2edcb..14a0a58ccfbc 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -308,6 +308,7 @@ public final class SystemServer {
private boolean mOnlyCore;
private boolean mFirstBoot;
+ private final int mStartCount;
private final boolean mRuntimeRestart;
private final long mRuntimeStartElapsedTime;
private final long mRuntimeStartUptime;
@@ -315,6 +316,9 @@ public final class SystemServer {
private static final String START_SENSOR_SERVICE = "StartSensorService";
private static final String START_HIDL_SERVICES = "StartHidlServices";
+ private static final String SYSPROP_START_COUNT = "sys.system_server.start_count";
+ private static final String SYSPROP_START_ELAPSED = "sys.system_server.start_elapsed";
+ private static final String SYSPROP_START_UPTIME = "sys.system_server.start_uptime";
private Future<?> mSensorServiceStart;
private Future<?> mZygotePreload;
@@ -344,16 +348,33 @@ public final class SystemServer {
public SystemServer() {
// Check for factory test mode.
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"));
+ // Record process start information.
+ // Note SYSPROP_START_COUNT will increment by *2* on a FDE device when it fully boots;
+ // one for the password screen, second for the actual boot.
+ mStartCount = SystemProperties.getInt(SYSPROP_START_COUNT, 0) + 1;
mRuntimeStartElapsedTime = SystemClock.elapsedRealtime();
mRuntimeStartUptime = SystemClock.uptimeMillis();
+
+ // Remember if it's runtime restart(when sys.boot_completed is already set) or reboot
+ // We don't use "mStartCount > 1" here because it'll be wrong on a FDE device.
+ // TODO: mRuntimeRestart will *not* be set to true if the proccess crashes before
+ // sys.boot_completed is set. Fix it.
+ mRuntimeRestart = "1".equals(SystemProperties.get("sys.boot_completed"));
}
private void run() {
try {
traceBeginAndSlog("InitBeforeStartServices");
+
+ // Record the process start information in sys props.
+ SystemProperties.set(SYSPROP_START_COUNT, String.valueOf(mStartCount));
+ SystemProperties.set(SYSPROP_START_ELAPSED, String.valueOf(mRuntimeStartElapsedTime));
+ SystemProperties.set(SYSPROP_START_UPTIME, String.valueOf(mRuntimeStartUptime));
+
+ EventLog.writeEvent(EventLogTags.SYSTEM_SERVER_START,
+ mStartCount, mRuntimeStartUptime, mRuntimeStartElapsedTime);
+
// 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