Don't corrupt ssd when encrypting and power fails

Stop encryption when battery is low, mark position, and continue on reboot.

Note - support for multiple encrypted volumes removed as no devices seem
to exist with an fstab that uses this feature. If you want support for such
a device, contact me and we will re-add it with appropriate testing.

Bug: 13284213
Change-Id: I1f7178e4f7dd8ea816cbc03ab5c4f6543e98acaa
diff --git a/Android.mk b/Android.mk
index 7f93229..6d665df 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,6 +14,7 @@
 	Loop.cpp \
 	Devmapper.cpp \
 	ResponseCode.cpp \
+	CheckBattery.cpp \
 	VoldUtil.c \
 	fstrim.c \
 	cryptfs.c
@@ -23,11 +24,13 @@
 	external/openssl/include \
 	external/stlport/stlport \
 	bionic \
-	external/scrypt/lib/crypto
+	external/scrypt/lib/crypto \
+	frameworks/native/include
 
 common_shared_libraries := \
 	libsysutils \
 	libstlport \
+	libbinder \
 	libcutils \
 	liblog \
 	libdiskconfig \
@@ -35,12 +38,14 @@
 	liblogwrap \
 	libext4_utils \
 	libcrypto \
-	libselinux
+	libselinux \
+	libutils
 
 common_static_libraries := \
 	libfs_mgr \
 	libscrypt_static \
-	libmincrypt
+	libmincrypt \
+	libbatteryservice
 
 include $(CLEAR_VARS)