summaryrefslogtreecommitdiffstats
path: root/install.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2016-05-13 21:13:15 +0200
committerTianjie Xu <xunchang@google.com>2016-05-16 23:54:37 +0200
commitdd874b1c87eb04f28db0db2629df0adde568a74c (patch)
tree9d62a7c64f5e383021178dfefaad5163d2decf26 /install.cpp
parentMake text for recovery larger on angler (diff)
downloadandroid_bootable_recovery-dd874b1c87eb04f28db0db2629df0adde568a74c.tar
android_bootable_recovery-dd874b1c87eb04f28db0db2629df0adde568a74c.tar.gz
android_bootable_recovery-dd874b1c87eb04f28db0db2629df0adde568a74c.tar.bz2
android_bootable_recovery-dd874b1c87eb04f28db0db2629df0adde568a74c.tar.lz
android_bootable_recovery-dd874b1c87eb04f28db0db2629df0adde568a74c.tar.xz
android_bootable_recovery-dd874b1c87eb04f28db0db2629df0adde568a74c.tar.zst
android_bootable_recovery-dd874b1c87eb04f28db0db2629df0adde568a74c.zip
Diffstat (limited to 'install.cpp')
-rw-r--r--install.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/install.cpp b/install.cpp
index d009513c3..d725c7b88 100644
--- a/install.cpp
+++ b/install.cpp
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <chrono>
+#include <string>
#include <vector>
#include "common.h"
@@ -50,7 +51,9 @@ 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, bool* wipe_cache) {
+try_update_binary(const char* path, ZipArchive* zip, bool* wipe_cache,
+ std::vector<std::string>& log_buffer)
+{
const ZipEntry* binary_entry =
mzFindZipEntry(zip, ASSUMED_UPDATE_BINARY_NAME);
if (binary_entry == NULL) {
@@ -183,6 +186,10 @@ try_update_binary(const char* path, ZipArchive* zip, bool* wipe_cache) {
ui->SetEnableReboot(true);
} else if (strcmp(command, "retry_update") == 0) {
retry_update = true;
+ } else if (strcmp(command, "log") == 0) {
+ // Save the logging request from updater and write to
+ // last_install later.
+ log_buffer.push_back(std::string(strtok(NULL, "\n")));
} else {
LOGE("unknown command [%s]\n", command);
}
@@ -203,7 +210,8 @@ try_update_binary(const char* path, ZipArchive* zip, bool* wipe_cache) {
}
static int
-really_install_package(const char *path, bool* wipe_cache, bool needs_mount)
+really_install_package(const char *path, bool* wipe_cache, bool needs_mount,
+ std::vector<std::string>& log_buffer)
{
ui->SetBackground(RecoveryUI::INSTALLING_UPDATE);
ui->Print("Finding update package...\n");
@@ -261,7 +269,7 @@ really_install_package(const char *path, bool* wipe_cache, bool needs_mount)
// Verify and install the contents of the package.
ui->Print("Installing update...\n");
ui->SetEnableReboot(false);
- int result = try_update_binary(path, &zip, wipe_cache);
+ int result = try_update_binary(path, &zip, wipe_cache, log_buffer);
ui->SetEnableReboot(true);
ui->Print("\n");
@@ -275,6 +283,7 @@ install_package(const char* path, bool* wipe_cache, const char* install_file,
bool needs_mount)
{
modified_flash = true;
+ auto start = std::chrono::system_clock::now();
FILE* install_log = fopen_path(install_file, "w");
if (install_log) {
@@ -284,15 +293,25 @@ install_package(const char* path, bool* wipe_cache, const char* install_file,
LOGE("failed to open last_install: %s\n", strerror(errno));
}
int result;
+ std::vector<std::string> log_buffer;
if (setup_install_mounts() != 0) {
LOGE("failed to set up expected mounts for install; aborting\n");
result = INSTALL_ERROR;
} else {
- result = really_install_package(path, wipe_cache, needs_mount);
+ result = really_install_package(path, wipe_cache, needs_mount, log_buffer);
}
if (install_log) {
fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log);
fputc('\n', install_log);
+ std::chrono::duration<double> duration = std::chrono::system_clock::now() - start;
+ int count = static_cast<int>(duration.count());
+ // Report the time spent to apply OTA update in seconds.
+ fprintf(install_log, "time_total: %d\n", count);
+
+ for (const auto& s : log_buffer) {
+ fprintf(install_log, "%s\n", s.c_str());
+ }
+
fclose(install_log);
}
return result;