summaryrefslogtreecommitdiffstats
path: root/install.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--install.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/install.cpp b/install.cpp
index 482e0d755..078343332 100644
--- a/install.cpp
+++ b/install.cpp
@@ -34,9 +34,17 @@
#include "verifier.h"
#include "ui.h"
+extern RecoveryUI* ui;
+
#define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary"
#define PUBLIC_KEYS_FILE "/res/keys"
+// Default allocation of progress bar segments to operations
+static const int VERIFICATION_PROGRESS_TIME = 60;
+static const float VERIFICATION_PROGRESS_FRACTION = 0.25;
+static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4;
+static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1;
+
// If the package contains an update binary, extract it and run it.
static int
try_update_binary(const char *path, ZipArchive *zip, int* wipe_cache) {
@@ -134,18 +142,17 @@ try_update_binary(const char *path, ZipArchive *zip, int* wipe_cache) {
float fraction = strtof(fraction_s, NULL);
int seconds = strtol(seconds_s, NULL, 10);
- ui_show_progress(fraction * (1-VERIFICATION_PROGRESS_FRACTION),
- seconds);
+ ui->ShowProgress(fraction * (1-VERIFICATION_PROGRESS_FRACTION), seconds);
} else if (strcmp(command, "set_progress") == 0) {
char* fraction_s = strtok(NULL, " \n");
float fraction = strtof(fraction_s, NULL);
- ui_set_progress(fraction);
+ ui->SetProgress(fraction);
} else if (strcmp(command, "ui_print") == 0) {
char* str = strtok(NULL, "\n");
if (str) {
- ui_print("%s", str);
+ ui->Print("%s", str);
} else {
- ui_print("\n");
+ ui->Print("\n");
}
} else if (strcmp(command, "wipe_cache") == 0) {
*wipe_cache = 1;
@@ -244,9 +251,9 @@ exit:
static int
really_install_package(const char *path, int* wipe_cache)
{
- ui_set_background(BACKGROUND_ICON_INSTALLING);
- ui_print("Finding update package...\n");
- ui_show_indeterminate_progress();
+ ui->SetBackground(RecoveryUI::INSTALLING);
+ ui->Print("Finding update package...\n");
+ ui->SetProgressType(RecoveryUI::INDETERMINATE);
LOGI("Update location: %s\n", path);
if (ensure_path_mounted(path) != 0) {
@@ -254,7 +261,7 @@ really_install_package(const char *path, int* wipe_cache)
return INSTALL_CORRUPT;
}
- ui_print("Opening update package...\n");
+ ui->Print("Opening update package...\n");
int numKeys;
RSAPublicKey* loadedKeys = load_keys(PUBLIC_KEYS_FILE, &numKeys);
@@ -265,10 +272,9 @@ really_install_package(const char *path, int* wipe_cache)
LOGI("%d key(s) loaded from %s\n", numKeys, PUBLIC_KEYS_FILE);
// Give verification half the progress bar...
- ui_print("Verifying update package...\n");
- ui_show_progress(
- VERIFICATION_PROGRESS_FRACTION,
- VERIFICATION_PROGRESS_TIME);
+ ui->Print("Verifying update package...\n");
+ ui->SetProgressType(RecoveryUI::DETERMINATE);
+ ui->ShowProgress(VERIFICATION_PROGRESS_FRACTION, VERIFICATION_PROGRESS_TIME);
int err;
err = verify_file(path, loadedKeys, numKeys);
@@ -290,7 +296,7 @@ really_install_package(const char *path, int* wipe_cache)
/* Verify and install the contents of the package.
*/
- ui_print("Installing update...\n");
+ ui->Print("Installing update...\n");
return try_update_binary(path, &zip, wipe_cache);
}