diff options
author | Elliott Hughes <enh@google.com> | 2017-11-10 08:42:17 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2017-11-10 08:43:16 -0800 |
commit | 23af112314e4edbed9a2fb61b7dbff6db2b92b60 (patch) | |
tree | 053f133b52347f272f3ac74d0bb5f5d81bafa346 /fastboot/fastboot.cpp | |
parent | 93e5cd85d1aa5d3075281093c07a3acee67b0b11 (diff) | |
download | core-23af112314e4edbed9a2fb61b7dbff6db2b92b60.tar.gz core-23af112314e4edbed9a2fb61b7dbff6db2b92b60.tar.bz2 core-23af112314e4edbed9a2fb61b7dbff6db2b92b60.zip |
fastboot: show how long extraction takes.
Before:
extracting android-info.txt (0 MB)...
extracting boot.img (29 MB)...
target reported max download size of 536870912 bytes
archive does not contain 'boot.sig'
archive does not contain 'boot_other.img'
archive does not contain 'dtbo.img'
archive does not contain 'dt.img'
archive does not contain 'recovery.img'
extracting system.img (1928 MB)...
archive does not contain 'system.sig'
extracting system_other.img (574 MB)...
archive does not contain 'system.sig'
archive does not contain 'vbmeta.img'
After:
extracting android-info.txt (0 MB) to RAM...
extracting boot.img (29 MB) to disk... took 0.232s
target reported max download size of 536870912 bytes
archive does not contain 'boot.sig'
archive does not contain 'boot_other.img'
archive does not contain 'dtbo.img'
archive does not contain 'dt.img'
archive does not contain 'recovery.img'
extracting system.img (1928 MB) to disk... took 10.122s
archive does not contain 'system.sig'
extracting system_other.img (574 MB) to disk... took 3.424s
archive does not contain 'system.sig'
archive does not contain 'vbmeta.img'
Bug: http://b/69128980
Test: ran manually
Change-Id: Ib190d1cc56ad9da06a4f9a9e822f7dad4a9a53b7
Diffstat (limited to 'fastboot/fastboot.cpp')
-rw-r--r-- | fastboot/fastboot.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 40c18e002..6175f59ef 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -485,7 +485,7 @@ static void* load_bootable_image(const std::string& kernel, const std::string& r return bdata; } -static void* unzip_file(ZipArchiveHandle zip, const char* entry_name, int64_t* sz) { +static void* unzip_to_memory(ZipArchiveHandle zip, const char* entry_name, int64_t* sz) { ZipString zip_entry_name(entry_name); ZipEntry zip_entry; if (FindEntry(zip, zip_entry_name, &zip_entry) != 0) { @@ -495,7 +495,7 @@ static void* unzip_file(ZipArchiveHandle zip, const char* entry_name, int64_t* s *sz = zip_entry.uncompressed_length; - fprintf(stderr, "extracting %s (%" PRId64 " MB)...\n", entry_name, *sz / 1024 / 1024); + fprintf(stderr, "extracting %s (%" PRId64 " MB) to RAM...\n", entry_name, *sz / 1024 / 1024); uint8_t* data = reinterpret_cast<uint8_t*>(malloc(zip_entry.uncompressed_length)); if (data == nullptr) die("failed to allocate %" PRId64 " bytes for '%s'", *sz, entry_name); @@ -613,17 +613,20 @@ static int unzip_to_file(ZipArchiveHandle zip, const char* entry_name) { return -1; } - fprintf(stderr, "extracting %s (%" PRIu32 " MB)...\n", entry_name, + fprintf(stderr, "extracting %s (%" PRIu32 " MB) to disk...", entry_name, zip_entry.uncompressed_length / 1024 / 1024); + double start = now(); int error = ExtractEntryToFile(zip, &zip_entry, fd); if (error != 0) { - die("failed to extract '%s': %s", entry_name, ErrorCodeString(error)); + die("\nfailed to extract '%s': %s", entry_name, ErrorCodeString(error)); } if (lseek(fd, 0, SEEK_SET) != 0) { - die("lseek on extracted file '%s' failed: %s", entry_name, strerror(errno)); + die("\nlseek on extracted file '%s' failed: %s", entry_name, strerror(errno)); } + fprintf(stderr, " took %.3fs\n", now() - start); + return fd.release(); } @@ -1091,7 +1094,7 @@ static void do_flash(Transport* transport, const char* pname, const char* fname) static void do_update_signature(ZipArchiveHandle zip, const char* filename) { int64_t sz; - void* data = unzip_file(zip, filename, &sz); + void* data = unzip_to_memory(zip, filename, &sz); if (data == nullptr) return; fb_queue_download("signature", data, sz); fb_queue_command("signature", "installing signature"); @@ -1130,7 +1133,7 @@ static void do_update(Transport* transport, const char* filename, const std::str } int64_t sz; - void* data = unzip_file(zip, "android-info.txt", &sz); + void* data = unzip_to_memory(zip, "android-info.txt", &sz); if (data == nullptr) { die("update package '%s' has no android-info.txt", filename); } |