rethink-app icon indicating copy to clipboard operation
rethink-app copied to clipboard

Gather tombstones on Android 11+

Open ignoramous opened this issue 4 years ago • 1 comments

11: Android 11 has a sterner limited API to fetch app kill reasons: ActivityManager#getHistoricalProcessExitReasons. Apps can set a last-known-state via ActivityManager#setProcessStateSummary that can be upto 128 bytes in size.

12: Android 12 introduces an new API for an app to fetch its own tombstones as protocol buffers: ApplicationExitInfo#getTraceInputStream.


May be show a prompt to user who can then agree to email fetched exit-reasons and tombstones, while we deliberate doing something more substantial for #119

ignoramous avatar Jul 22 '21 20:07 ignoramous

For android version 30 (11), ActivityManager#getHistoricalProcessExitReasons has a predefined set of kill reasons, viz.

REASON_ANR = 6;
REASON_CRASH = 4;
REASON_CRASH_NATIVE = 5;
REASON_DEPENDENCY_DIED = 12;
REASON_EXCESSIVE_RESOURCE_USAGE = 9;
REASON_EXIT_SELF = 1;
REASON_INITIALIZATION_FAILURE = 7;
REASON_LOW_MEMORY = 3;
REASON_OTHER = 13;
REASON_PERMISSION_CHANGE = 8;
REASON_SIGNALED = 2;
REASON_UNKNOWN = 0;
REASON_USER_REQUESTED = 10;
REASON_USER_STOPPED = 11;

Out of which, only ANRs are of interest and provide the traces with the API -> #getTraceInputStream(), for all the other cases, it returns null.

Example output of the crash data:

`/*crash reason */5 ,
/* uid */11194, 
/* description */ crash ,
/* importance */ 125, 
/* definingUid */ 11194, 
/* rss */ 262436, 
/* status */ 6, 
/* timestamp */ 1627488765471, 
/* processStateSummary */ null, 
/* traceInputStream */ null, 
/* pss */169742`.

Hopefully, the Android 12 API getTraceInputStream fares better.

hussainmohd-a avatar Jul 28 '21 21:07 hussainmohd-a

Fix: 3978356c

hussainmohd-a avatar Aug 04 '23 16:08 hussainmohd-a