FASTBOOT: Add recovery:wipe_data support and fix some init sequencing

An earlier change added a feature where fastboot would reboot to
recovery to wipe data if told to by board specific key command.

This change adds ability to do the same via a fastboot command, as
well as being passed this from the kernel.  This allows the following
to work:

$ fastboot oem recovery:wipe_data
$ adb shell reboot recovery:wipe_data

The latter may require root access because reboot is only root
executable.

Also fix some init sequencing problem.  We need to init priv state
earlier, otherwise we were calling saveenv() (to update flag to
reboot into recovery again on next boot in case it didn't complete)
but saving an uninitialized unlock state.

Make fbt_clear_recovery_flag() only saveenv() if the value
of FASTBOOT_RUN_RECOVERY_ENV_NAME had been set.  Otherwise,
make it a nop.  This removes unnecessary writes to env
partition when nothing has changed in the regular boot case.

Change-Id: Ia8c9e8c52178e2a7d7dad002135e616f8f6f4d53
Signed-off-by: Mike J. Chen <mjchen@google.com>
2 files changed