summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2016-11-12 02:17:03 +0100
committerandroid-build-merger <android-build-merger@google.com>2016-11-12 02:17:03 +0100
commit0b2be22f01ee0ebbf805725f334e8ed2168af5e8 (patch)
treee2eeedfdaa5433e3d3c11fc7cf753cc3f3a0fa5d
parentMerge "Add 'reboot bootloader' to bootloader_message." am: a5538b87e8 am: 118e814bfe (diff)
parentMerge "Allow uncrypt to work without socket communication" am: 4c1f3eda98 (diff)
downloadandroid_bootable_recovery-0b2be22f01ee0ebbf805725f334e8ed2168af5e8.tar
android_bootable_recovery-0b2be22f01ee0ebbf805725f334e8ed2168af5e8.tar.gz
android_bootable_recovery-0b2be22f01ee0ebbf805725f334e8ed2168af5e8.tar.bz2
android_bootable_recovery-0b2be22f01ee0ebbf805725f334e8ed2168af5e8.tar.lz
android_bootable_recovery-0b2be22f01ee0ebbf805725f334e8ed2168af5e8.tar.xz
android_bootable_recovery-0b2be22f01ee0ebbf805725f334e8ed2168af5e8.tar.zst
android_bootable_recovery-0b2be22f01ee0ebbf805725f334e8ed2168af5e8.zip
-rw-r--r--uncrypt/uncrypt.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp
index f31d55aa8..38b25abc7 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));
}
@@ -567,7 +572,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();
@@ -580,7 +585,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;
@@ -591,6 +596,17 @@ int main(int argc, char** argv) {
return 1;
}
+ if (action == UNCRYPT_DEBUG) {
+ LOG(INFO) << "uncrypt called in debug mode, skip socket communication\n";
+ bool success = uncrypt_wrapper(input_path, map_file, -1);
+ if (success) {
+ LOG(INFO) << "uncrypt succeeded\n";
+ } else{
+ LOG(INFO) << "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()));