summaryrefslogtreecommitdiffstats
path: root/uncrypt/uncrypt.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2016-09-13 01:01:28 +0200
committerandroid-build-merger <android-build-merger@google.com>2016-09-13 01:01:28 +0200
commit6048138e10b46918864dac06f0e94882d523078c (patch)
treec384a11d41d2ce932a2dba8b791e72dcabdb7111 /uncrypt/uncrypt.cpp
parentMerge "Switch recovery to libbase logging" (diff)
parentMerge "save uncrypt status to last_install" (diff)
downloadandroid_bootable_recovery-6048138e10b46918864dac06f0e94882d523078c.tar
android_bootable_recovery-6048138e10b46918864dac06f0e94882d523078c.tar.gz
android_bootable_recovery-6048138e10b46918864dac06f0e94882d523078c.tar.bz2
android_bootable_recovery-6048138e10b46918864dac06f0e94882d523078c.tar.lz
android_bootable_recovery-6048138e10b46918864dac06f0e94882d523078c.tar.xz
android_bootable_recovery-6048138e10b46918864dac06f0e94882d523078c.tar.zst
android_bootable_recovery-6048138e10b46918864dac06f0e94882d523078c.zip
Diffstat (limited to 'uncrypt/uncrypt.cpp')
-rw-r--r--uncrypt/uncrypt.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp
index 7adf88cac..96edfd781 100644
--- a/uncrypt/uncrypt.cpp
+++ b/uncrypt/uncrypt.cpp
@@ -130,6 +130,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;
@@ -461,12 +462,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;
}