vold_decrypt: FDE Keymaster 3.0 support

* HTC U11 Oreo is using keymaster3 FDE encryption which requires
  the new services:
    1- /system/bin/hwservicemanager
    2- /vendor/bin/hw/android.hardware.keymaster@3.0-service
    3- /vendor/bin/qseecomd (instead of /system/bin/qseecomd)
  So in addition to /vendor/lib and /vendor/lib64 also
  symlink /system/vendor/bin to /vendor/bin.

* vold_decrypt services now have separate prefixes:
    1- 'sys_' referring to /system/bin
    2- 'ven_' referring to /vendor/bin

* The additional (hwservicemanager, keymaster-3-0) and modified
  (qseecomd) .rc files have been updated in the vold_decrypt
  directory.
  Comments were added directly in the .rc files, please check
  them.

* /etc/recovery.fstab needs to be temporarily moved since
  vold will use it if it finds the '/sbin/recovery' file
  (refer to fs_mgr for the fstab load code https://goo.gl/8KaZyf).
  Since fs_mgr cannot parse TWRP style fstab, we 'hide' it
  and attempt to create a symlink to /fstab.{ro.hardware}.

Also remove shell dependencies, code cleanup, new error codes:
* Critical sections of vold_decrypt should not rely on the external
  shell (and the available binaries) provided by TWFunc::Exec_Cmd.
  Doing so may lead to failures resulting from different shell
  provided binaries not working properly, especially since busybox
  can be inconsistent across different trees.

  In particular the following functions have been changed:
  * run_vdc() no longer uses daisy chained commands, instead
    it now forks and executes vdc directly including a 30 second
    built in timeout.
  * Symlink_Firmware_Files() no longer relies on the shell 'find'
    command to retrieve the list of firmware/vendor files and instead
    uses a built in function, Find_Firmware_Files(), which traverses
    the system partition to retrieve the list of files.

* The code has also been cleaned up a little for better consistency,
  and vold_decrypt will now return various error codes for the
  different failures, as defined in vold_decrypt.h, which allows the
  gui_msg to be moved back to partitionmanager.cpp.

Notes regarding pre Android 8.0 builds:
* Service names in .rc files cannot exceed 16 characters (including
  the prepended 'sys_' or 'ven_') in Android 7.1 and below, so a
  service name such as 'sys_hwservicemanager' is out of the question
  for 7.1 and below.
* hwservicemanager will check ACLs on 'hwservicemanager' and 'ITokenManager'
  if they are even allowed to run, otherwise the interfaces will fail.
  The policies have only been introduced in 8.0, and although it is possible
  to manually add them to the 7.1 policies it's not recommended.
* Therefore the best course of action is to build in 8.0.

* SIDE NOTE: On the HTC U11 we are actually using omni-7.1 with some changes
  in the device tree to support both Nougat and Oreo decryption, please
  refer to:
    1- https://gerrit.twrp.me/c/2756/ for the necessary sepolicy and
       BoardConfig changes.
    2- The Android.mk file for vold_decrypt was modified to truncate
       greater than 16 character service names (as mentioned therein)

Other changes:
* TW_CRYPTO_SYSTEM_VOLD_DISABLE_TIMEOUT is now deprecated due to built-
  in fork and timeout.
* Output_dmesg_to_recovery_log() is also deprecated so upon a failed
  decryption the recovery.log will no longer append it, instead you can
  just use 'adb shell dmesg' to check it. Nonetheless if a true debug
  build is needed use the original TW_CRYPTO_SYSTEM_VOLD_DEBUG flag as
  outlined in the original commit message (see below).

Usage info:
This is an update to the initial vold_decrypt, for more info refer to
https://github.com/omnirom/android_bootable_recovery/commit/71c6c50d0da1f32dd18a749797e88de2358c5ba1

Change-Id: Id7129d125ae7f5dcba0779489825add718022ba3
7 files changed
tree: 654075439f74c31051af4b3fa130afad243d8be1
  1. adbbu/
  2. applypatch/
  3. attr/
  4. bmlutils/
  5. bootloader_message/
  6. bootloader_message_twrp/
  7. crypto/
  8. dosfstools/
  9. edify/
  10. etc/
  11. exfat/
  12. fb2png/
  13. flashutils/
  14. fonts/
  15. fuse/
  16. gpt/
  17. gui/
  18. htcdumlock/
  19. injecttwrp/
  20. libblkid/
  21. libcrecovery/
  22. libmincrypt/
  23. libpixelflinger/
  24. libtar/
  25. minadbd/
  26. minadbd21/
  27. minui/
  28. minui21/
  29. minuitwrp/
  30. minzip/
  31. mmcutils/
  32. mtdutils/
  33. mtp/
  34. openaes/
  35. orscmd/
  36. otafault/
  37. otautil/
  38. pigz/
  39. prebuilt/
  40. private/
  41. res/
  42. res-hdpi/
  43. res-mdpi/
  44. res-xhdpi/
  45. res-xxhdpi/
  46. res-xxxhdpi/
  47. scripts/
  48. sepolicy/
  49. simg2img/
  50. tests/
  51. toolbox/
  52. tools/
  53. toybox/
  54. twrpDigest/
  55. twrpTarMain/
  56. uncrypt/
  57. update_verifier/
  58. updater/
  59. verifier24/
  60. .clang-format
  61. .gitignore
  62. adb_install.cpp
  63. adb_install.h
  64. Android.mk
  65. asn1_decoder.cpp
  66. asn1_decoder.h
  67. bootloader.h
  68. CleanSpec.mk
  69. common.h
  70. data.cpp
  71. data.hpp
  72. default_device.cpp
  73. device.cpp
  74. device.h
  75. error_code.h
  76. exclude.cpp
  77. exclude.hpp
  78. find_file.cpp
  79. find_file.hpp
  80. fixContexts.cpp
  81. fixContexts.hpp
  82. fuse.h
  83. fuse_sdcard_provider.cpp
  84. fuse_sdcard_provider.h
  85. fuse_sideload.cpp
  86. fuse_sideload.h
  87. infomanager.cpp
  88. infomanager.hpp
  89. install.cpp
  90. install.h
  91. installcommand.cpp
  92. installcommand.h
  93. interlace-frames.py
  94. legacy_properties.h
  95. legacy_property_service.cpp
  96. legacy_property_service.h
  97. mounts.c
  98. mounts.cpp
  99. mounts.h
  100. mounts.h~HEAD
  101. NOTICE
  102. openrecoveryscript.cpp
  103. openrecoveryscript.hpp
  104. partition.cpp
  105. partitionmanager.cpp
  106. partitions.hpp
  107. print_sha1.h
  108. progresstracking.cpp
  109. progresstracking.hpp
  110. README.md
  111. recovery-persist.cpp
  112. recovery-persist.rc
  113. recovery-refresh.cpp
  114. recovery-refresh.rc
  115. recovery.cpp
  116. recovery_ui.h
  117. roots.cpp
  118. roots.h
  119. rotate_logs.cpp
  120. rotate_logs.h
  121. screen_ui.cpp
  122. screen_ui.h
  123. set_metadata.cpp
  124. set_metadata.h
  125. stub_ui.h
  126. tarWrite.c
  127. tarWrite.h
  128. tw_atomic.cpp
  129. tw_atomic.hpp
  130. twcommon.h
  131. twinstall.cpp
  132. twinstall.h
  133. twinstallorig.cpp
  134. twinstallorig.h
  135. twrp-functions.cpp
  136. twrp-functions.hpp
  137. twrp.cpp
  138. twrpAdbBuFifo.cpp
  139. twrpAdbBuFifo.hpp
  140. twrpDigestDriver.cpp
  141. twrpDigestDriver.hpp
  142. twrpTar.cpp
  143. twrpTar.h
  144. twrpTar.hpp
  145. ui.cpp
  146. ui.h
  147. variables.h
  148. verifier.cpp
  149. verifier.h
  150. wear_touch.cpp
  151. wear_touch.h
  152. wear_ui.cpp
  153. wear_ui.h
  154. zipwrap.cpp
  155. zipwrap.hpp
README.md

Team Win Recovery Project (TWRP)

You can find a compiling guide here.