summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--install.cpp13
-rw-r--r--uncrypt/uncrypt.cpp21
-rw-r--r--wear_ui.cpp56
-rw-r--r--wear_ui.h4
4 files changed, 40 insertions, 54 deletions
diff --git a/install.cpp b/install.cpp
index 02c845cb8..9227d5895 100644
--- a/install.cpp
+++ b/install.cpp
@@ -30,6 +30,8 @@
#include <string>
#include <vector>
+#include <android-base/file.h>
+#include <android-base/logging.h>
#include <android-base/parseint.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
@@ -54,6 +56,7 @@ static constexpr const char* AB_OTA_PAYLOAD_PROPERTIES = "payload_properties.txt
static constexpr const char* AB_OTA_PAYLOAD = "payload.bin";
#define PUBLIC_KEYS_FILE "/res/keys"
static constexpr const char* METADATA_PATH = "META-INF/com/android/metadata";
+static constexpr const char* UNCRYPT_STATUS = "/cache/recovery/uncrypt_status";
// Default allocation of progress bar segments to operations
static const int VERIFICATION_PROGRESS_TIME = 60;
@@ -539,6 +542,16 @@ install_package(const char* path, bool* wipe_cache, const char* install_file,
fprintf(install_log, "%s\n", s.c_str());
}
+ if (ensure_path_mounted(UNCRYPT_STATUS) != 0) {
+ LOG(WARNING) << "Can't mount " << UNCRYPT_STATUS;
+ } else {
+ std::string uncrypt_status;
+ if (!android::base::ReadFileToString(UNCRYPT_STATUS, &uncrypt_status)) {
+ PLOG(WARNING) << "failed to read uncrypt status";
+ } else {
+ fprintf(install_log, "%s\n", android::base::Trim(uncrypt_status).c_str());
+ }
+ }
fclose(install_log);
}
return result;
diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp
index 5e804bcca..c73107cca 100644
--- a/uncrypt/uncrypt.cpp
+++ b/uncrypt/uncrypt.cpp
@@ -134,6 +134,7 @@
// devices, on which /cache partitions always exist.
static const std::string CACHE_BLOCK_MAP = "/cache/recovery/block.map";
static const std::string UNCRYPT_PATH_FILE = "/cache/recovery/uncrypt_file";
+static const std::string UNCRYPT_STATUS = "/cache/recovery/uncrypt_status";
static const std::string UNCRYPT_SOCKET = "uncrypt";
static struct fstab* fstab = nullptr;
@@ -466,12 +467,32 @@ static bool uncrypt_wrapper(const char* input_path, const char* map_file, const
input_path = package.c_str();
}
CHECK(map_file != nullptr);
+
+#define UNCRYPT_TIME_HOLDER 0x7FFFFFFF
+ // Intialize the uncrypt time cost to a huge number so that we can tell from
+ // the statistics if an uncrypt fails to finish.
+ if (!android::base::WriteStringToFile(android::base::StringPrintf(
+ "uncrypt_time: %d\n", UNCRYPT_TIME_HOLDER), UNCRYPT_STATUS)) {
+ PLOG(WARNING) << "failed to write to " << UNCRYPT_STATUS;
+ }
+
+ auto start = std::chrono::system_clock::now();
int status = uncrypt(input_path, map_file, socket);
if (status != 0) {
write_status_to_socket(-1, socket);
return false;
}
+
+ std::chrono::duration<double> duration = std::chrono::system_clock::now() - start;
+ int count = static_cast<int>(duration.count());
+ // Overwrite the uncrypt_time if uncrypt finishes successfully.
+ if (!android::base::WriteStringToFile(
+ android::base::StringPrintf("uncrypt_time: %d\n", count), UNCRYPT_STATUS)) {
+ PLOG(WARNING) << "failed to write to " << UNCRYPT_STATUS;
+ }
+
write_status_to_socket(100, socket);
+
return true;
}
diff --git a/wear_ui.cpp b/wear_ui.cpp
index 3550992ac..bfa7097ea 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -184,55 +184,10 @@ void WearRecoveryUI::draw_screen_locked()
}
}
-// Keeps the progress bar updated, even when the process is otherwise busy.
-void* WearRecoveryUI::progress_thread(void *cookie) {
- self->progress_loop();
- return NULL;
-}
-
-void WearRecoveryUI::progress_loop() {
- double interval = 1.0 / animation_fps;
- for (;;) {
- double start = now();
- pthread_mutex_lock(&updateMutex);
- bool redraw = false;
-
- if ((currentIcon == INSTALLING_UPDATE || currentIcon == ERASING)
- && !show_text) {
- if (!intro_done) {
- if (current_frame >= intro_frames - 1) {
- intro_done = true;
- current_frame = 0;
- } else {
- current_frame++;
- }
- } else {
- current_frame = (current_frame + 1) % loop_frames;
- }
- redraw = true;
- }
-
- // move the progress bar forward on timed intervals, if configured
- int duration = progressScopeDuration;
- if (progressBarType == DETERMINATE && duration > 0) {
- double elapsed = now() - progressScopeTime;
- float p = 1.0 * elapsed / duration;
- if (p > 1.0) p = 1.0;
- if (p > progress) {
- progress = p;
- redraw = true;
- }
- }
-
- if (redraw) update_screen_locked();
-
- pthread_mutex_unlock(&updateMutex);
- double end = now();
- // minimum of 20ms delay between frames
- double delay = interval - (end-start);
- if (delay < 0.02) delay = 0.02;
- usleep((long)(delay * 1000000));
- }
+// TODO merge drawing routines with screen_ui
+void WearRecoveryUI::update_progress_locked() {
+ draw_screen_locked();
+ gr_flip();
}
void WearRecoveryUI::InitTextParams() {
@@ -253,9 +208,6 @@ void WearRecoveryUI::Init() {
backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
LoadBitmap("icon_error", &backgroundIcon[ERROR]);
backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];
-
- pthread_create(&progress_t, NULL, progress_thread, NULL);
-
}
void WearRecoveryUI::SetStage(int current, int max)
diff --git a/wear_ui.h b/wear_ui.h
index dadf32449..9351d4166 100644
--- a/wear_ui.h
+++ b/wear_ui.h
@@ -54,6 +54,8 @@ class WearRecoveryUI : public ScreenRecoveryUI {
void InitTextParams() override;
+ void update_progress_locked() override;
+
void PrintV(const char*, bool, va_list) override;
private:
@@ -74,8 +76,6 @@ class WearRecoveryUI : public ScreenRecoveryUI {
void draw_screen_locked() override;
void draw_progress_locked();
- static void* progress_thread(void* cookie);
- void progress_loop();
void PutChar(char);
void ClearText();
};