Add lollipop decrypt support

Kang in cryptfs.c and cryptfs.h from vold.
Use TW_INCLUDE_L_CRYPTO := true to enable.
Ramdisk must contain the normal fstab file in the root in the
usual format of:
fstab.{ro.hardware}
For examble for Nexus 5:
fstab.hammerhead
Or on many Qualcomm devices:
fstab.qcom

Tested against Android 5.0 lollipop on Nexus 7 2012 grouper. Not
sure if or how this will work when we are dealing with a device
with a hardware keystore. Long term we need to add a GUI element
to allow entering a pattern. For now you can decrypt a pattern
unlock by converting the dots to numbers in the following format:
123
456
789

So an upper-case L would translate to 14789 as a password entered
on the keyboard.

Change-Id: I02c29e1f1c2eb29bf002c9fe0fc118357300b5b3
diff --git a/partition.cpp b/partition.cpp
index 2195d9d..642c3dd 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -55,6 +55,8 @@
 #ifdef TW_INCLUDE_CRYPTO
 	#ifdef TW_INCLUDE_JB_CRYPTO
 		#include "crypto/jb/cryptfs.h"
+	#elif defined(TW_INCLUDE_L_CRYPTO)
+		#include "crypto/lollipop/cryptfs.h"
 	#else
 		#include "crypto/ics/cryptfs.h"
 	#endif
@@ -276,6 +278,21 @@
 				Setup_Data_Media();
 #ifdef TW_INCLUDE_CRYPTO
 			Can_Be_Encrypted = true;
+#ifdef TW_INCLUDE_L_CRYPTO
+			int password_type = cryptfs_get_password_type();
+			if (password_type == CRYPT_TYPE_DEFAULT) {
+				LOGINFO("Device is encrypted with the default password, attempting to decrypt.\n");
+				property_set("ro.crypto.state", "encrypted");
+				if (cryptfs_check_passwd("default_password") == 0) {
+					gui_print("Successfully decrypted with default password.\n");
+				} else {
+					LOGERR("Unable to decrypt with default password.");
+					LOGERR("You may need to perform a Format Data.\n");
+				}
+			} else {
+				DataManager::SetValue("TW_CRYPTO_TYPE", password_type);
+			}
+#endif
 			char crypto_blkdev[255];
 			property_get("ro.crypto.fs_crypto_blkdev", crypto_blkdev, "error");
 			if (strcmp(crypto_blkdev, "error") != 0) {
@@ -287,7 +304,7 @@
 				LOGINFO("Data already decrypted, new block device: '%s'\n", crypto_blkdev);
 			} else if (!Mount(false)) {
 				if (Is_Present) {
-#ifdef TW_INCLUDE_JB_CRYPTO
+#if defined(TW_INCLUDE_JB_CRYPTO) || defined(TW_INCLUDE_L_CRYPTO)
 					// No extra flags needed
 #else
 					property_set("ro.crypto.fs_type", CRYPTO_FS_TYPE);