crypto: only set crypto state and type if not already set

Move setting crypto state and type to functions and call those
functions rather than arbitrarily setting those props in every
case. This cleans up all the log spam from trying to set
read-only props, since they will now only get set if
they aren't already.

Change-Id: I392bee060d71c6ee50d0d92bf1b118d9049be41a
This commit is contained in:
Captain Throwback
2021-10-06 22:27:49 +00:00
committed by bigbiff
parent 8a8e56cd60
commit 37c3aef4e8
3 changed files with 24 additions and 15 deletions
+3 -3
View File
@@ -737,8 +737,8 @@ bool TWPartition::Decrypt_FBE_DE() {
if (TWFunc::Path_Exists("/data/unencrypted/key/version")) {
DataManager::SetValue(TW_IS_FBE, 1);
DataManager::SetValue(TW_CRYPTO_PWTYPE, "0"); // Set initial value so that recovery will not be confused when using unencrypted data or failed to decrypt data
property_set("ro.crypto.state", "encrypted");
property_set("ro.crypto.type", "file");
PartitionManager.Set_Crypto_State();
PartitionManager.Set_Crypto_Type("file");
LOGINFO("File Based Encryption is present\n");
#ifdef TW_INCLUDE_FBE
Is_FBE = true;
@@ -765,7 +765,7 @@ bool TWPartition::Decrypt_FBE_DE() {
while (!Decrypt_DE() && --retry_count)
usleep(2000);
if (retry_count > 0) {
property_set("ro.crypto.state", "encrypted");
PartitionManager.Set_Crypto_State();
Is_Encrypted = true;
Is_Decrypted = false;
DataManager::SetValue(TW_IS_ENCRYPTED, 1);