From 923c4a26eb691e3f7cd6527ea1dae70ec6bbeec2 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 11 Jul 2020 15:09:32 +0200 Subject: [PATCH] Log exit reasons Android 11 --- app/src/main/java/eu/faircode/email/Log.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/Log.java b/app/src/main/java/eu/faircode/email/Log.java index f4251cac14..155142875e 100644 --- a/app/src/main/java/eu/faircode/email/Log.java +++ b/app/src/main/java/eu/faircode/email/Log.java @@ -20,6 +20,7 @@ package eu.faircode.email; */ import android.app.ActivityManager; +import android.app.ApplicationExitInfo; import android.app.Dialog; import android.app.usage.UsageStatsManager; import android.content.Context; @@ -1156,6 +1157,23 @@ public class Log { sb.append("\r\n"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + try { + // https://developer.android.com/reference/android/app/ApplicationExitInfo + List infos = am.getHistoricalProcessExitReasons( + context.getPackageName(), 0, 20); + for (ApplicationExitInfo info : infos) + sb.append(String.format("%s: %s %s/%s reason=%d status=%d importance=%d\r\n", + new Date(info.getTimestamp()), info.getDescription(), + Helper.humanReadableByteCount(info.getPss() * 1024L), + Helper.humanReadableByteCount(info.getRss() * 1024L), + info.getReason(), info.getStatus(), info.getReason())); + } catch (Throwable ex) { + Log.e(ex); + } + sb.append("\r\n"); + } + sb.append(new Date(Helper.getInstallTime(context))).append("\r\n"); sb.append(new Date()).append("\r\n");