Merge changes Ibd98dfae,Ib350094b

* changes:
  Asan_extract: Set access flags.
  Asan_extract: Add FDE check
diff --git a/rootdir/asan_extract.sh b/rootdir/asan_extract.sh
index c7d2fdf..8d626b3 100644
--- a/rootdir/asan_extract.sh
+++ b/rootdir/asan_extract.sh
@@ -26,6 +26,24 @@
 SRC=/system/asan.tar.bz2
 MD5_FILE=/data/asan.md5sum
 ASAN_DIR=/data/asan
+# Minimum /data size in blocks. Arbitrarily 512M.
+MIN_DATA_SIZE=131072
+
+# Checks for FDE pre-decrypt state.
+
+VOLD_STATUS=$(getprop vold.decrypt)
+if [ "$VOLD_STATUS" = "trigger_restart_min_framework" ] ; then
+  log -p i -t asan_install "Pre-decrypt FDE detected (by vold property)!"
+  exit 1
+fi
+
+STATFS_BLOCKS=$(stat -f -c '%b' /data)
+if [ "$STATFS_BLOCKS" -le "$MIN_DATA_SIZE" ] ; then
+  log -p i -t asan_install "Pre-decrypt FDE detected (by /data size)!"
+  exit 1
+fi
+
+# Check for ASAN source.
 
 if ! test -f $SRC ; then
   log -p i -t asan_install "Did not find $SRC!"
@@ -34,6 +52,8 @@
 
 log -p i -t asan_install "Found $SRC, checking whether we need to apply it."
 
+# Checksum check.
+
 ASAN_TAR_MD5=$(md5sum $SRC)
 if test -f $MD5_FILE ; then
   INSTALLED_MD5=$(cat $MD5_FILE)
@@ -43,6 +63,8 @@
   fi
 fi
 
+# Actually apply the source.
+
 # Just clean up, helps with restorecon.
 rm -rf $ASAN_DIR
 
@@ -53,10 +75,16 @@
 
 # Cannot log here, log would run with system_data_file.
 
+# Set correct permission bits.
+chmod -R 744 $ASAN_DIR
+cd $ASAN_DIR ; find . -type d -exec chmod 755 {} \;
+
 restorecon -R -F $ASAN_DIR/*/lib*
 
 log -p i -t asan_install "Fixed selinux labels..."
 
+
+# Now write down our checksum to mark the extraction complete.
 echo "$ASAN_TAR_MD5" > $MD5_FILE
 
 # We want to reboot now. It seems it is not possible to run "reboot" here, the device will