Add reboot step to Rescue Party

Before showing a factory reset prompt in Rescue Party, first
perform a reboot. This will lead to a better UX if the reboot
mitigates the issue, rather than showing a factory reset
prompt right away.

This implementation is resilient against fs-checkpointing by
storing the mitigation count in /metadata whenever the mitigation
count is incremented. This file will be deleted after reading,
so that the mitigation count will be reset after 2 reboots.

Added new property to track if Rescue Party is trying to reboot,
and extended isAttemptingFactoryReset to handle this property.
Without this method returning true, the device will not reboot
since PowerManager uses this method to give Rescue Party an
exception to reboot early in the boot cycle.

This change will slightly break the functionality of
debug.crash_sysui and debug.crash_system, since those properties
will be cleared by the reboot and the device will not continue
crashing after reboot. This will be fixed in a future CL.

Test: atest RescuePartyTest
Test: setprop debug.crash_system, adb shell stop, adb shell start
Bug: 171951174
Change-Id: Ied4d86b9f7608e273c2b396a201fdc8029878a28
3 files changed