Add runtime crash information to sysprops

- sys.system_server.crash_java
How many times the system server has crashed within
Java layer. sys.system_server.start_count is the time
that system_server has started.

Normally, (start_count - 1 - crash_java) is the count of
native crash or the other native processes triggered
system_server restart.

We expect the start_count is 1, and the crash_java is 0.

$ getprop | grep system_server
[sys.system_server.start_count]: [5]
[sys.system_server.crash_java]: [2]
...

Signed-off-by: duguowei <duguowei@xiaomi.corp-partner.google.com>
Change-Id: I14af2025def1ad8cb937b9e0dbd6d3a9d34c8558
This commit is contained in:
duguowei
2022-05-26 17:42:24 +08:00
committed by Guowei Du
parent 089c119f4d
commit a7cb994b6f

View File

@@ -62,6 +62,8 @@ public class RuntimeInit {
private static IBinder mApplicationObject;
private static volatile boolean mCrashing = false;
private static final String SYSPROP_CRASH_COUNT = "sys.system_server.crash_java";
private static int mCrashCount;
private static volatile ApplicationWtfHandler sDefaultApplicationWtfHandler;
@@ -105,6 +107,8 @@ public class RuntimeInit {
// first clause in either of these two cases, only for system_server.
if (mApplicationObject == null && (Process.SYSTEM_UID == Process.myUid())) {
Clog_e(TAG, "*** FATAL EXCEPTION IN SYSTEM PROCESS: " + t.getName(), e);
mCrashCount = SystemProperties.getInt(SYSPROP_CRASH_COUNT, 0) + 1;
SystemProperties.set(SYSPROP_CRASH_COUNT, String.valueOf(mCrashCount));
} else {
logUncaught(t.getName(), ActivityThread.currentProcessName(), Process.myPid(), e);
}