aboutsummaryrefslogtreecommitdiffstats
path: root/updater/install.c
diff options
context:
space:
mode:
authorDoug Zongker <dougz@google.com>2014-06-09 14:13:19 -0700
committerDoug Zongker <dougz@google.com>2014-06-09 14:15:22 -0700
commit43772d26a5d8d31fd092a21edfca346f3b3901e7 (patch)
tree4c8a510d4b395c6189ee01dfafe0b955bb7440d2 /updater/install.c
parent3fa26c9fa29bce2a89d8daebd5437912d6fe97ba (diff)
downloadbootable_recovery-43772d26a5d8d31fd092a21edfca346f3b3901e7.zip
bootable_recovery-43772d26a5d8d31fd092a21edfca346f3b3901e7.tar.gz
bootable_recovery-43772d26a5d8d31fd092a21edfca346f3b3901e7.tar.bz2
advance progress bar during block OTA installations
While executing syspatch and package_extract_file() calls with don't care maps (both of which are used to rewrite the system image in incremental and full block OTAs, respectively), pass a progress callback in and use it to update the visible progress bar. Change-Id: I1d3742d167c1bb2130571eb5103b7795c65ff371
Diffstat (limited to 'updater/install.c')
-rw-r--r--updater/install.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/updater/install.c b/updater/install.c
index e1071c9..42f2289 100644
--- a/updater/install.c
+++ b/updater/install.c
@@ -463,17 +463,31 @@ DontCareMap* ReadDontCareMapFromZip(ZipArchive* za, const char* path) {
map->region_count = strtoul(p, &p, 0);
map->regions = (int*) malloc(map->region_count * sizeof(int));
+ map->total_blocks = 0;
int i;
for (i = 0; i < map->region_count; ++i) {
map->regions[i] = strtoul(p, &p, 0);
+ map->total_blocks += map->regions[i];
}
return map;
}
+static FILE* mapwrite_cmd_pipe;
+
+static void progress_cb(long done, long total) {
+ if (total > 0) {
+ double frac = (double)done / total;
+ fprintf(mapwrite_cmd_pipe, "set_progress %f\n", frac);
+ fflush(mapwrite_cmd_pipe);
+ }
+}
+
+
+
bool MapWriter(const unsigned char* data, int dataLen, void* cookie) {
- return write_with_map(data, dataLen, (MapState*) cookie) == dataLen;
+ return write_with_map(data, dataLen, (MapState*) cookie, progress_cb) == dataLen;
}
// package_extract_file(package_path, destination_path, map_path)
@@ -490,6 +504,10 @@ Value* PackageExtractFileFn(const char* name, State* state,
name, argc);
}
bool success = false;
+
+ UpdaterInfo* ui = (UpdaterInfo*)(state->cookie);
+ mapwrite_cmd_pipe = ui->cmd_pipe;
+
if (argc >= 2) {
// The two-argument version extracts to a file; the three-arg
// version extracts to a file, skipping over regions in a
@@ -1185,6 +1203,9 @@ Value* SysPatchFn(const char* name, State* state, int argc, Expr* argv[]) {
return NULL;
}
+ UpdaterInfo* ui = (UpdaterInfo*)(state->cookie);
+ mapwrite_cmd_pipe = ui->cmd_pipe;
+
if (ParseSha1(target_sha1, target_digest) != 0) {
printf("%s(): failed to parse '%s' as target SHA-1", name, target_sha1);
memset(target_digest, 0, SHA_DIGEST_SIZE);
@@ -1220,7 +1241,7 @@ Value* SysPatchFn(const char* name, State* state, int argc, Expr* argv[]) {
FILE* tgt = fopen(filename, "r+");
- int ret = syspatch(src, init_map, patch_data, patch_len, tgt, target_map);
+ int ret = syspatch(src, init_map, patch_data, patch_len, tgt, target_map, progress_cb);
fclose(src);
fclose(tgt);