bootstat: allow kernel_panic,sysrq to propagate subreason

Allow for a daemon to write to last kmsg to propagate a detailed
subreason to kernel_panic,sysrq actions.  A minor refactor moves
common code into a helper function getSubreason for retrieval and
bit error correction operations.

A sysrq crash generally produces a kernel-provided message:
    SysRq : Trigger a crash
which is used to generate a canonical boot reason kernel_panic,sysrq.
A user daemon could write to /dev/kmsg just prior to the sysrq with
    SysRq : Trigger a crash : '<subreason>'
to change the canonical boot reason to kernel_panic,sysrq,<subreason>.

Administration added pending kBootReasonMap entries present in TRON.

Test: manual echo into /dev/kmsg and /proc/sysrq-trigger and check
Test: boot_reason_test.sh
Bug: 33808187
Bug: 63736262
Change-Id: Ibf5432737e5a3449ebe40a8c6cf2d3e912ed6bbc
1 file changed