Support writing FEC.

After hash tree is written, we re-read the partition to encode FEC,
this cannot be done incrementally for each Update() like the hash
tree, because the data needed to encode each rs block are spreaded
across entire partition, and we can not afford to use that much
memory.

For each round, we encode block_size number of rs blocks, which will
produce block_size * fec_roots bytes of FEC data, this will allow us
to read one block at a time instead of one byte.

Bug: 28171891
Test: update_engine_unittests
Test: brillo_update_payload generate
Test: brillo_update_payload verify

Change-Id: I35ba7e0647b9ee5a97b972dc480deef60d813676
diff --git a/Android.mk b/Android.mk
index 062babb..4b06c27 100644
--- a/Android.mk
+++ b/Android.mk
@@ -108,12 +108,14 @@
     libbz \
     libbspatch \
     libbrotli \
+    libfec_rs \
     libpuffpatch \
     libverity_tree \
     $(ue_update_metadata_protos_exported_static_libraries)
 ue_libpayload_consumer_exported_shared_libraries := \
     libbase \
     libcrypto \
+    libfec \
     $(ue_update_metadata_protos_exported_shared_libraries)
 
 ue_libpayload_consumer_src_files := \
@@ -157,8 +159,6 @@
 ifeq ($(local_use_fec),1)
 ue_libpayload_consumer_src_files += \
     payload_consumer/fec_file_descriptor.cc
-ue_libpayload_consumer_exported_shared_libraries += \
-    libfec
 endif  # local_use_fec == 1
 
 ifeq ($(HOST_OS),linux)