Minor update to decrypt device routine for Nexus 6P decrypt
Move property setting of ro.crypto.state to after mounting any
needed partitions so that we can use this property as a trigger
for running services in init. Check to see if the property is
already set so that we do not set it and sleep multiple times if
the user enters an incorrect password.
Change-Id: I55558c5e227377381101b6305569d9eb31040790
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index ad17fe4..945a96c 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -1436,12 +1436,10 @@
int TWPartitionManager::Decrypt_Device(string Password) {
#ifdef TW_INCLUDE_CRYPTO
int ret_val, password_len;
- char crypto_blkdev[255], cPassword[255];
+ char crypto_state[PROPERTY_VALUE_MAX], crypto_blkdev[PROPERTY_VALUE_MAX], cPassword[255];
size_t result;
std::vector<TWPartition*>::iterator iter;
- property_set("ro.crypto.state", "encrypted");
-
// Mount any partitions that need to be mounted for decrypt
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Mount_To_Decrypt) {
@@ -1449,6 +1447,13 @@
}
}
+ property_get("ro.crypto.state", crypto_state, "error");
+ if (strcmp(crypto_state, "error") == 0) {
+ property_set("ro.crypto.state", "encrypted");
+ // Sleep for a bit so that services can start if needed
+ sleep(1);
+ }
+
strcpy(cPassword, Password.c_str());
int pwret = cryptfs_check_passwd(cPassword);