Merge "Don\'t show UI on default encryption" into mnc-dr-dev
am: 2309f76d17

* commit '2309f76d17171a4e9b2593ff248861eb3a41ec5a':
  Don't show UI on default encryption
diff --git a/Android.mk b/Android.mk
index 1d36312..d83e650 100644
--- a/Android.mk
+++ b/Android.mk
@@ -52,10 +52,12 @@
 	libutils \
 	libhardware \
 	libsoftkeymaster \
-	libbase \
+	libbase
 
 common_static_libraries := \
 	libfs_mgr \
+	libfec \
+	libfec_rs \
 	libsquashfs_utils \
 	libscrypt_static \
 	libmincrypt \
@@ -88,6 +90,8 @@
 	main.cpp \
 	$(common_src_files)
 
+LOCAL_INIT_RC := vold.rc
+
 LOCAL_C_INCLUDES := $(common_c_includes)
 LOCAL_CFLAGS := $(vold_cflags)
 LOCAL_CONLYFLAGS := $(vold_conlyflags)
@@ -107,11 +111,12 @@
 
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 LOCAL_CLANG := true
-LOCAL_SRC_FILES:= vdc.c
+LOCAL_SRC_FILES:= vdc.cpp
 LOCAL_MODULE:= vdc
 LOCAL_SHARED_LIBRARIES := libcutils
 LOCAL_CFLAGS := $(vold_cflags)
 LOCAL_CONLYFLAGS := $(vold_conlyflags)
+LOCAL_INIT_RC := vdc.rc
 
 include $(BUILD_EXECUTABLE)
 
diff --git a/CommandListener.cpp b/CommandListener.cpp
index 36d2950..a9a8031 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -44,6 +44,7 @@
 #include "Process.h"
 #include "Loop.h"
 #include "Devmapper.h"
+#include "Ext4Crypt.h"
 #include "cryptfs.h"
 #include "MoveTask.h"
 #include "TrimTask.h"
diff --git a/Loop.cpp b/Loop.cpp
index 8872d7a..059b963 100644
--- a/Loop.cpp
+++ b/Loop.cpp
@@ -103,10 +103,11 @@
         }
 
         rc = ioctl(fd, LOOP_GET_STATUS64, &li);
-        close(fd);
         if (rc < 0 && errno == ENXIO) {
+            close(fd);
             continue;
         }
+        close(fd);
 
         if (rc < 0) {
             SLOGE("Unable to get loop status for %s (%s)", filename,
diff --git a/fs/Vfat.cpp b/fs/Vfat.cpp
index faff763..7bd05ec 100644
--- a/fs/Vfat.cpp
+++ b/fs/Vfat.cpp
@@ -134,20 +134,6 @@
     flags |= (ro ? MS_RDONLY : 0);
     flags |= (remount ? MS_REMOUNT : 0);
 
-    /*
-     * Note: This is a temporary hack. If the sampling profiler is enabled,
-     * we make the SD card world-writable so any process can write snapshots.
-     *
-     * TODO: Remove this code once we have a drop box in system_server.
-     */
-    char value[PROPERTY_VALUE_MAX];
-    property_get("persist.sampling_profiler", value, "");
-    if (value[0] == '1') {
-        SLOGW("The SD card is world-writable because the"
-            " 'persist.sampling_profiler' system property is set to '1'.");
-        permMask = 0;
-    }
-
     sprintf(mountData,
             "utf8,uid=%d,gid=%d,fmask=%o,dmask=%o,shortname=mixed",
             ownerUid, ownerGid, permMask, permMask);
diff --git a/vdc.c b/vdc.cpp
similarity index 98%
rename from vdc.c
rename to vdc.cpp
index c6b2c92..d8476b7 100644
--- a/vdc.c
+++ b/vdc.cpp
@@ -106,7 +106,7 @@
 }
 
 static int do_monitor(int sock, int stop_after_cmd) {
-    char *buffer = malloc(4096);
+    char *buffer = (char *) malloc(4096);
 
     if (!stop_after_cmd)
         printf("[Connected to Vold]\n");
diff --git a/vdc.rc b/vdc.rc
new file mode 100644
index 0000000..e842869
--- /dev/null
+++ b/vdc.rc
@@ -0,0 +1,13 @@
+# One shot invocation to deal with encrypted volume.
+service defaultcrypto /system/bin/vdc --wait cryptfs mountdefaultencrypted
+    disabled
+    oneshot
+    # vold will set vold.decrypt to trigger_restart_framework (default
+    # encryption) or trigger_restart_min_framework (other encryption)
+
+# One shot invocation to encrypt unencrypted volumes
+service encrypt /system/bin/vdc --wait cryptfs enablecrypto inplace default
+    disabled
+    oneshot
+    # vold will set vold.decrypt to trigger_restart_framework (default
+    # encryption)
diff --git a/vold.rc b/vold.rc
new file mode 100644
index 0000000..7719e0b
--- /dev/null
+++ b/vold.rc
@@ -0,0 +1,7 @@
+service vold /system/bin/vold \
+        --blkid_context=u:r:blkid:s0 --blkid_untrusted_context=u:r:blkid_untrusted:s0 \
+        --fsck_context=u:r:fsck:s0 --fsck_untrusted_context=u:r:fsck_untrusted:s0
+    class core
+    socket vold stream 0660 root mount
+    socket cryptd stream 0660 root mount
+    ioprio be 2