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

Change-Id: Id2681bc2b1012a0571417f7a6e0b980b1b25c61c
(cherry picked from commit 5a79f67a1b1bd1bcadeca0a4896a871646652534)
This commit is contained in:
Noah Jacobson
2020-05-20 19:11:15 -04:00
committed by bigbiff
parent 784073e9fe
commit 0b25b1d79b
18 changed files with 640 additions and 655 deletions
+22 -2
View File
@@ -64,6 +64,7 @@ std::set<string> GUIAction::setActionsRunningInCallerThread;
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);
@@ -1502,12 +1503,31 @@ int GUIAction::decrypt(std::string arg __unused)
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;