From 8dfcf2a18699684232ee6f45ce04ee9be0349dcd Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 15 Dec 2020 01:58:55 +0100 Subject: [PATCH] Update lock pattern types for android 11 The stored id for the different types of the lock pattern was chnaged with Android 11. You can find the updated list in the LockPatternUtils: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-11.0.0_r25/core/java/com/android/internal/widget/LockPatternUtils.java#113 It was changed in 5e891bcc04556a3595ab349381acc2a2e36a69d1: https://android.googlesource.com/platform/frameworks/base/+/5e891bcc04556a3595ab349381acc2a2e36a69d1 The old CREDENTIAL_TYPE_PASSWORD_OR_PIN was essentialy split in CREDENTIAL_TYPE_PASSWORD and CREDENTIAL_TYPE_PASSWORD_OR_PIN. This code updates the matching in twrp, so that the correct unlocking method for file base decryption can be found. Without these changes twrp always try to use the default password and obviously fails. With these changes the usual password dialog is shown and the decryption is successfully. Change-Id: Ia8d47223b30a5301d4b9d2230241039612055ebb Signed-off-by: Alexander Sulfrian Co-authored-by: althafvly --- crypto/ext4crypt/Decrypt.cpp | 4 +++- crypto/fscrypt/Decrypt.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crypto/ext4crypt/Decrypt.cpp b/crypto/ext4crypt/Decrypt.cpp index d486aa4a..3f82aa17 100755 --- a/crypto/ext4crypt/Decrypt.cpp +++ b/crypto/ext4crypt/Decrypt.cpp @@ -1203,7 +1203,9 @@ int Get_Password_Type(const userid_t user_id, std::string& filename) { } if (pwd.password_type == 1) // In Android this means pattern return 2; // In TWRP this means pattern - else if (pwd.password_type == 2) // In Android this means PIN or password + // In Android <11 type 2 is PIN or password + // In Android 11 type 3 is PIN and type 4 is password + else if (pwd.password_type > 1) return 1; // In TWRP this means PIN or password return 0; // We'll try the default password #else diff --git a/crypto/fscrypt/Decrypt.cpp b/crypto/fscrypt/Decrypt.cpp index ef46535f..44eae081 100755 --- a/crypto/fscrypt/Decrypt.cpp +++ b/crypto/fscrypt/Decrypt.cpp @@ -1045,7 +1045,9 @@ int Get_Password_Type(const userid_t user_id, std::string& filename) { printf("password type: pattern\n"); return 2; // In TWRP this means pattern } - else if (pwd.password_type == 2) { // In Android this means PIN or password + // In Android <11 type 2 is PIN or password + // In Android 11 type 3 is PIN and type 4 is password + else if (pwd.password_type > 1) { printf("password type: pin\n"); return 1; // In TWRP this means PIN or password }