summaryrefslogtreecommitdiffstats
path: root/uncrypt
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2016-07-01 00:31:51 +0200
committerTianjie Xu <xunchang@google.com>2016-07-01 04:46:01 +0200
commit28c1e5d3aa9610db6e141380b1435937fc7f07db (patch)
tree1402910f85af3b8ea245a08751b61418588cfede /uncrypt
parentresolve merge conflicts of 2f272c0 to nyc-mr1-dev-plus-aosp (diff)
downloadandroid_bootable_recovery-28c1e5d3aa9610db6e141380b1435937fc7f07db.tar
android_bootable_recovery-28c1e5d3aa9610db6e141380b1435937fc7f07db.tar.gz
android_bootable_recovery-28c1e5d3aa9610db6e141380b1435937fc7f07db.tar.bz2
android_bootable_recovery-28c1e5d3aa9610db6e141380b1435937fc7f07db.tar.lz
android_bootable_recovery-28c1e5d3aa9610db6e141380b1435937fc7f07db.tar.xz
android_bootable_recovery-28c1e5d3aa9610db6e141380b1435937fc7f07db.tar.zst
android_bootable_recovery-28c1e5d3aa9610db6e141380b1435937fc7f07db.zip
Diffstat (limited to 'uncrypt')
-rw-r--r--uncrypt/uncrypt.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp
index c19943fa7..ba45946aa 100644
--- a/uncrypt/uncrypt.cpp
+++ b/uncrypt/uncrypt.cpp
@@ -210,6 +210,11 @@ static const char* find_block_device(const char* path, bool* encryptable, bool*
}
static bool write_status_to_socket(int status, int socket) {
+ // If socket equals -1, uncrypt is in debug mode without socket communication.
+ // Skip writing and return success.
+ if (socket == -1) {
+ return true;
+ }
int status_out = htonl(status);
return android::base::WriteFully(socket, &status_out, sizeof(int));
}
@@ -539,7 +544,7 @@ static void usage(const char* exename) {
}
int main(int argc, char** argv) {
- enum { UNCRYPT, SETUP_BCB, CLEAR_BCB } action;
+ enum { UNCRYPT, SETUP_BCB, CLEAR_BCB, UNCRYPT_DEBUG } action;
const char* input_path = nullptr;
const char* map_file = CACHE_BLOCK_MAP.c_str();
@@ -552,7 +557,7 @@ int main(int argc, char** argv) {
} else if (argc == 3) {
input_path = argv[1];
map_file = argv[2];
- action = UNCRYPT;
+ action = UNCRYPT_DEBUG;
} else {
usage(argv[0]);
return 2;
@@ -562,6 +567,17 @@ int main(int argc, char** argv) {
return 1;
}
+ if (action == UNCRYPT_DEBUG) {
+ ALOGI("uncrypt called in debug mode, skip socket communication\n");
+ bool success = uncrypt_wrapper(input_path, map_file, -1);
+ if (success) {
+ ALOGI("uncrypt succeeded\n");
+ } else{
+ ALOGI("uncrypt failed\n");
+ }
+ return success ? 0 : 1;
+ }
+
// c3. The socket is created by init when starting the service. uncrypt
// will use the socket to communicate with its caller.
android::base::unique_fd service_socket(android_get_control_socket(UNCRYPT_SOCKET.c_str()));