Reads the system's record of why this app's processes died, so an ANR that killed the process is recoverable on the next launch (#906).
getHistoricalProcessExitReasons is API 30 and minSdk here is 24, so the path reports itself unsupported below that rather than failing. The query and the trace reads run on a background executor: #334 is the leading hypothesis for these ANRs, so a collector that blocked the main thread would add to the problem it exists to measure.
A trace is not guaranteed even for REASON_ANR. AOSP keeps traces in a circular buffer shared across all applications, so another app's crash can evict ours, and a trace can ride on a record whose reason is something else. So the read is attempted on every record and absence is an ordinary outcome, not an error. getTraceInputStream() is declared throws IOException, so the call itself is inside the try, not only the reads on the stream it returns.
REASON_CRASH_NATIVE yields a protobuf tombstone rather than text from API 31, so its bytes are deliberately left alone and only the metadata is recorded.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>