Add support for multi-user decryption
* Add CLI support using the command "twrp decrypt <PASSWORD> [USER ID]"
* Add GUI support using the menu Advanced --> Decrypt User
multiuser: Parse users only when Decrypt_DE runs successfully
multiuser: Warn when not all users are decrypted
Change-Id: Ia5e943b13c2d5ec5c34ae97661133c19ff471e6d
diff --git a/gui/action.cpp b/gui/action.cpp
index bf7af74..9bf66f4 100755
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -66,6 +66,7 @@
static string zip_queue[10];
static int zip_queue_index;
pid_t sideload_child_pid;
+extern std::vector<users_struct> Users_List;
static void *ActionThread_work_wrapper(void *data);
@@ -1531,12 +1532,31 @@
simulate_progress_bar();
} else {
string Password;
+ string userID;
DataManager::GetValue("tw_crypto_password", Password);
- op_status = PartitionManager.Decrypt_Device(Password);
+
+ if (DataManager::GetIntValue(TW_IS_FBE)) { // for FBE
+ DataManager::GetValue("tw_crypto_user_id", userID);
+ if (userID != "") {
+ op_status = PartitionManager.Decrypt_Device(Password, atoi(userID.c_str()));
+ if (userID != "0") {
+ if (op_status != 0)
+ op_status = 1;
+ operation_end(op_status);
+ return 0;
+ }
+ } else {
+ LOGINFO("User ID not found\n");
+ op_status = 1;
+ }
+ ::sleep(1);
+ } else { // for FDE
+ op_status = PartitionManager.Decrypt_Device(Password);
+ }
+
if (op_status != 0)
op_status = 1;
else {
-
DataManager::SetValue(TW_IS_ENCRYPTED, 0);
int has_datamedia;