recovery: use __android_log_pmsg_file_write for log files

- Add call to __android_log_pmsg_file_write for recovery logging.
- Add call to refresh pmsg if we reboot back into recovery and then
  allow overwrite of those logs.
- Add a new one-time executable recovery-refresh that refreshes pmsg
  in post-fs phase of init. We rely on pmsg eventually scrolling off
  to age the content after recovery-persist has done its job.
- Add a new one-time executable recovery-persist that transfers from
  pmsg to /data/misc/recovery/ directory if /cache is not mounted
  in post-fs-data phase of init.
- Build and appropriately trigger the above two as required if
  BOARD_CACHEIMAGE_PARTITION_SIZE is undefined.
- Add some simple unit tests

NB: Test failure is expected on systems that do not deliver either
the recovery-persist or recovery-refresh executables, e.g. systems
with /cache. Tests also require a timely reboot sequence of test
to truly verify, tests provide guidance on stderr to direct.

Bug: 27176738
Change-Id: I17bb95980234984f6b2087fd5941b0a3126b706b
8 files changed
tree: eff3803e6756b19290d2f9c5277262227b5892f0
  1. Android.mk
  2. CleanSpec.mk
  3. NOTICE
  4. README.md
  5. adb_install.cpp
  6. adb_install.h
  7. applypatch/
  8. asn1_decoder.cpp
  9. asn1_decoder.h
  10. bootloader.cpp
  11. bootloader.h
  12. common.h
  13. default_device.cpp
  14. device.cpp
  15. device.h
  16. edify/
  17. etc/
  18. fonts/
  19. fuse_sdcard_provider.cpp
  20. fuse_sdcard_provider.h
  21. fuse_sideload.cpp
  22. fuse_sideload.h
  23. install.cpp
  24. install.h
  25. interlace-frames.py
  26. minadbd/
  27. minui/
  28. minzip/
  29. mtdutils/
  30. otafault/
  31. print_sha1.h
  32. recovery-persist.cpp
  33. recovery-persist.rc
  34. recovery-refresh.cpp
  35. recovery-refresh.rc
  36. recovery.cpp
  37. res-hdpi/
  38. res-mdpi/
  39. res-xhdpi/
  40. res-xxhdpi/
  41. res-xxxhdpi/
  42. roots.cpp
  43. roots.h
  44. screen_ui.cpp
  45. screen_ui.h
  46. tests/
  47. tools/
  48. ui.cpp
  49. ui.h
  50. uncrypt/
  51. unique_fd.h
  52. update_verifier/
  53. updater/
  54. verifier.cpp
  55. verifier.h
  56. wear_ui.cpp
  57. wear_ui.h
README.md

The Recovery Image

Quick turn-around testing

mm -j && m ramdisk-nodeps && m recoveryimage-nodeps

# To boot into the new recovery image
# without flashing the recovery partition:
adb reboot bootloader
fastboot boot $ANDROID_PRODUCT_OUT/recovery.img

Running the tests

# After setting up environment and lunch.
mmma -j bootable/recovery

# Running the tests on device.
adb root
adb sync data

# 32-bit device
adb shell /data/nativetest/recovery_unit_test/recovery_unit_test
adb shell /data/nativetest/recovery_component_test/recovery_component_test

# Or 64-bit device
adb shell /data/nativetest64/recovery_unit_test/recovery_unit_test
adb shell /data/nativetest64/recovery_component_test/recovery_component_test