Parse postinstall program progress updates.
In Android postinstall is expected to take a long time in common cases.
This patch allows the postinstall program to report back to the updater
a progress indication, which will then be forwarded to all the clients
listening. These progress updates are part of the FINALIZING status.
Bug: 27880754
TEST=Added unittests. Deployed an update to an edison-eng and post-install reported progress back with the postinstall_example.
(cherry picked from commit 0d29854cf5bb05a22cf161b50052539aa420a36e)
Change-Id: I003e996bd5a9acccfc83012345351174d269107c
diff --git a/common/utils.h b/common/utils.h
index 55d8a80..686f117 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -75,6 +75,14 @@
size_t count,
off_t offset);
+// Calls read() repeatedly until |count| bytes are read or EOF or EWOULDBLOCK
+// is reached. Returns whether all read() calls succeeded (including EWOULDBLOCK
+// as a success case), sets |eof| to whether the eof was reached and sets
+// |out_bytes_read| to the actual number of bytes read regardless of the return
+// value.
+bool ReadAll(
+ int fd, void* buf, size_t count, size_t* out_bytes_read, bool* eof);
+
// Calls pread() repeatedly until count bytes are read, or EOF is reached.
// Returns number of bytes read in *bytes_read. Returns true on success.
bool PReadAll(int fd, void* buf, size_t count, off_t offset,