summaryrefslogtreecommitdiff
path: root/fastboot/fastboot.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2016-01-19 23:08:28 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-01-19 23:08:28 +0000
commit08550d5cc98e66aeb5f0dad9a24e1f477f47721c (patch)
tree7951171bb7a7923ba4c52893dfebbb0776a69174 /fastboot/fastboot.cpp
parent163b83d01ce5fdd4733661cdc12eb40df44bd223 (diff)
parent69c9274c3ea023a7d3505592fab99f87144a61dd (diff)
Merge "fastboot: show progress when sending sparse images." am: 6a27196516
am: 69c9274c3e * commit '69c9274c3ea023a7d3505592fab99f87144a61dd': fastboot: show progress when sending sparse images.
Diffstat (limited to 'fastboot/fastboot.cpp')
-rw-r--r--fastboot/fastboot.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index a66a45a8e..e409bf643 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -43,6 +43,8 @@
#include <sys/types.h>
#include <unistd.h>
#include <functional>
+#include <utility>
+#include <vector>
#include <android-base/parseint.h>
#include <android-base/strings.h>
@@ -765,13 +767,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<std::pair<sparse_file*, int64_t>> sparse_files;
s = reinterpret_cast<sparse_file**>(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;