summaryrefslogtreecommitdiffstats
path: root/updater/install.c
diff options
context:
space:
mode:
authorDoug Zongker <dougz@google.com>2014-06-09 23:13:19 +0200
committerDoug Zongker <dougz@google.com>2014-06-09 23:15:22 +0200
commit43772d26a5d8d31fd092a21edfca346f3b3901e7 (patch)
tree4c8a510d4b395c6189ee01dfafe0b955bb7440d2 /updater/install.c
parentam dff8afe1: (-s ours) restore holo UI in recovery -- DO NOT MERGE (diff)
downloadandroid_bootable_recovery-43772d26a5d8d31fd092a21edfca346f3b3901e7.tar
android_bootable_recovery-43772d26a5d8d31fd092a21edfca346f3b3901e7.tar.gz
android_bootable_recovery-43772d26a5d8d31fd092a21edfca346f3b3901e7.tar.bz2
android_bootable_recovery-43772d26a5d8d31fd092a21edfca346f3b3901e7.tar.lz
android_bootable_recovery-43772d26a5d8d31fd092a21edfca346f3b3901e7.tar.xz
android_bootable_recovery-43772d26a5d8d31fd092a21edfca346f3b3901e7.tar.zst
android_bootable_recovery-43772d26a5d8d31fd092a21edfca346f3b3901e7.zip
Diffstat (limited to '')
-rw-r--r--updater/install.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/updater/install.c b/updater/install.c
index e1071c90c..42f228972 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);