diff --git a/fastboot/engine.cpp b/fastboot/engine.cpp index ac5a17a06..47567c041 100644 --- a/fastboot/engine.cpp +++ b/fastboot/engine.cpp @@ -157,17 +157,17 @@ void fb_queue_flash(const char *ptn, void *data, unsigned sz) a->msg = mkmsg("writing '%s'", ptn); } -void fb_queue_flash_sparse(const char *ptn, struct sparse_file *s, unsigned sz) -{ +void fb_queue_flash_sparse(const char* ptn, struct sparse_file* s, unsigned sz, size_t current, + size_t total) { Action *a; a = queue_action(OP_DOWNLOAD_SPARSE, ""); a->data = s; a->size = 0; - a->msg = mkmsg("sending sparse '%s' (%d KB)", ptn, sz / 1024); + a->msg = mkmsg("sending sparse '%s' %zu/%zu (%d KB)", ptn, current, total, sz / 1024); a = queue_action(OP_COMMAND, "flash:%s", ptn); - a->msg = mkmsg("writing '%s'", ptn); + a->msg = mkmsg("writing '%s' %zu/%zu", ptn, current, total); } static int match(const char* str, const char** value, unsigned count) { diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index bd1748580..4573da052 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -705,13 +707,22 @@ static void flash_buf(const char *pname, struct fastboot_buffer *buf) sparse_file** s; switch (buf->type) { - case FB_BUFFER_SPARSE: + case FB_BUFFER_SPARSE: { + std::vector> sparse_files; s = reinterpret_cast(buf->data); while (*s) { int64_t sz = sparse_file_len(*s, true, false); - fb_queue_flash_sparse(pname, *s++, sz); + sparse_files.emplace_back(*s, sz); + ++s; + } + + for (size_t i = 0; i < sparse_files.size(); ++i) { + const auto& pair = sparse_files[i]; + fb_queue_flash_sparse(pname, pair.first, pair.second, i + 1, sparse_files.size()); } break; + } + case FB_BUFFER: fb_queue_flash(pname, buf->data, buf->sz); break; diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h index acfbc1352..1932bab73 100644 --- a/fastboot/fastboot.h +++ b/fastboot/fastboot.h @@ -51,7 +51,8 @@ char *fb_get_error(void); /* engine.c - high level command queue engine */ bool fb_getvar(Transport* transport, const std::string& key, std::string* value); void fb_queue_flash(const char *ptn, void *data, uint32_t sz); -void fb_queue_flash_sparse(const char *ptn, struct sparse_file *s, uint32_t sz); +void fb_queue_flash_sparse(const char* ptn, struct sparse_file* s, uint32_t sz, size_t current, + size_t total); void fb_queue_erase(const char *ptn); void fb_queue_format(const char *ptn, int skip_if_not_supported, int32_t max_chunk_sz); void fb_queue_require(const char *prod, const char *var, bool invert,