|
@@ -78,6 +78,37 @@ public class XCrashUtils {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ // callback for ANR
|
|
|
+ private final ICrashCallback anrCallback = new ICrashCallback() {
|
|
|
+ @Override
|
|
|
+ public void onCrash(String logPath, String emergency) {
|
|
|
+ Log.d(TAG, "log path: " + (logPath != null ? logPath : "(null)") + ", emergency: " + (emergency != null ? emergency : "(null)"));
|
|
|
+
|
|
|
+ if (emergency != null) {
|
|
|
+ debug(logPath, emergency);
|
|
|
+
|
|
|
+ // Disk is exhausted, send crash report immediately.
|
|
|
+ //sendThenDeleteCrashLog(logPath, emergency);
|
|
|
+ } else {
|
|
|
+ // Add some expanded sections. Send crash report at the next time APP startup.
|
|
|
+
|
|
|
+ // OK
|
|
|
+ TombstoneManager.appendSection(logPath, "expanded_key_1", "expanded_content");
|
|
|
+ TombstoneManager.appendSection(logPath, "expanded_key_2", "expanded_content_row_1\nexpanded_content_row_2");
|
|
|
+
|
|
|
+ // Invalid. (Do NOT include multiple consecutive newline characters ("\n\n") in the content string.)
|
|
|
+ // TombstoneManager.appendSection(logPath, "expanded_key_3", "expanded_content_row_1\n\nexpanded_content_row_2");
|
|
|
+
|
|
|
+ debug(logPath, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Disk is exhausted, send crash report immediately.
|
|
|
+ //sendThenDeleteCrashLog(logPath, emergency);
|
|
|
+
|
|
|
+ AppUtils.relaunchApp(true);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
public void init(Application application) {
|
|
|
Log.d(TAG, "xCrash SDK init: start");
|
|
|
app = application;
|
|
@@ -97,7 +128,7 @@ public class XCrashUtils {
|
|
|
.setNativeCallback(callback)
|
|
|
.setAnrRethrow(true)
|
|
|
.setAnrLogCountMax(10)
|
|
|
- .setAnrCallback(callback)
|
|
|
+ .setAnrCallback(anrCallback)
|
|
|
.setPlaceholderCountMax(3)
|
|
|
.setPlaceholderSizeKb(512)
|
|
|
.setLogDir(application.getExternalFilesDir("xcrash").toString())
|