summaryrefslogtreecommitdiffstats
path: root/updater/install.c
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2009-06-25 02:39:16 +0200
committerThe Android Open Source Project <initial-contribution@android.com>2009-06-25 02:39:16 +0200
commit4275c3cfc828ac2df143d353a4e27e8dda20b4a9 (patch)
treef36a4716573ef9d73f445a73c06bfa7b74054606 /updater/install.c
parentadd device extension mechanism to updater (diff)
parentimprove updater progress bar (diff)
downloadandroid_bootable_recovery-4275c3cfc828ac2df143d353a4e27e8dda20b4a9.tar
android_bootable_recovery-4275c3cfc828ac2df143d353a4e27e8dda20b4a9.tar.gz
android_bootable_recovery-4275c3cfc828ac2df143d353a4e27e8dda20b4a9.tar.bz2
android_bootable_recovery-4275c3cfc828ac2df143d353a4e27e8dda20b4a9.tar.lz
android_bootable_recovery-4275c3cfc828ac2df143d353a4e27e8dda20b4a9.tar.xz
android_bootable_recovery-4275c3cfc828ac2df143d353a4e27e8dda20b4a9.tar.zst
android_bootable_recovery-4275c3cfc828ac2df143d353a4e27e8dda20b4a9.zip
Diffstat (limited to 'updater/install.c')
-rw-r--r--updater/install.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/updater/install.c b/updater/install.c
index 0bd09399c..e1f3c9acf 100644
--- a/updater/install.c
+++ b/updater/install.c
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-#include <stdio.h>
+#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
@@ -265,9 +266,25 @@ char* ShowProgressFn(const char* name, State* state, int argc, Expr* argv[]) {
UpdaterInfo* ui = (UpdaterInfo*)(state->cookie);
fprintf(ui->cmd_pipe, "progress %f %d\n", frac, sec);
- free(frac_str);
free(sec_str);
- return strdup("");
+ return frac_str;
+}
+
+char* SetProgressFn(const char* name, State* state, int argc, Expr* argv[]) {
+ if (argc != 1) {
+ return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc);
+ }
+ char* frac_str;
+ if (ReadArgs(state, argv, 1, &frac_str) < 0) {
+ return NULL;
+ }
+
+ double frac = strtod(frac_str, NULL);
+
+ UpdaterInfo* ui = (UpdaterInfo*)(state->cookie);
+ fprintf(ui->cmd_pipe, "set_progress %f\n", frac);
+
+ return frac_str;
}
// package_extract_dir(package_path, destination_path)
@@ -749,6 +766,7 @@ void RegisterInstallFunctions() {
RegisterFunction("unmount", UnmountFn);
RegisterFunction("format", FormatFn);
RegisterFunction("show_progress", ShowProgressFn);
+ RegisterFunction("set_progress", SetProgressFn);
RegisterFunction("delete", DeleteFn);
RegisterFunction("delete_recursive", DeleteFn);
RegisterFunction("package_extract_dir", PackageExtractDirFn);