Merge "Destroy vold socket interface completely."
diff --git a/model/EmulatedVolume.cpp b/model/EmulatedVolume.cpp
index 21b290a..d40cf3f 100644
--- a/model/EmulatedVolume.cpp
+++ b/model/EmulatedVolume.cpp
@@ -21,6 +21,7 @@
 #include <android-base/logging.h>
 #include <cutils/fs.h>
 #include <private/android_filesystem_config.h>
+#include <utils/Timers.h>
 
 #include <fcntl.h>
 #include <stdlib.h>
@@ -100,9 +101,16 @@
         return -errno;
     }
 
+    nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
     while (before == GetDevice(mFuseWrite)) {
         LOG(VERBOSE) << "Waiting for FUSE to spin up...";
         usleep(50000); // 50ms
+
+        nsecs_t now = systemTime(SYSTEM_TIME_BOOTTIME);
+        if (nanoseconds_to_milliseconds(now - start) > 5000) {
+            LOG(WARNING) << "Timed out while waiting for FUSE to spin up";
+            return -ETIMEDOUT;
+        }
     }
     /* sdcardfs will have exited already. FUSE will still be running */
     TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, WNOHANG));
diff --git a/model/PublicVolume.cpp b/model/PublicVolume.cpp
index 569203c..f80f59e 100644
--- a/model/PublicVolume.cpp
+++ b/model/PublicVolume.cpp
@@ -23,6 +23,7 @@
 #include <android-base/logging.h>
 #include <cutils/fs.h>
 #include <private/android_filesystem_config.h>
+#include <utils/Timers.h>
 
 #include <fcntl.h>
 #include <stdlib.h>
@@ -186,9 +187,16 @@
         return -errno;
     }
 
+    nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
     while (before == GetDevice(mFuseWrite)) {
         LOG(VERBOSE) << "Waiting for FUSE to spin up...";
         usleep(50000); // 50ms
+
+        nsecs_t now = systemTime(SYSTEM_TIME_BOOTTIME);
+        if (nanoseconds_to_milliseconds(now - start) > 5000) {
+            LOG(WARNING) << "Timed out while waiting for FUSE to spin up";
+            return -ETIMEDOUT;
+        }
     }
     /* sdcardfs will have exited already. FUSE will still be running */
     TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, WNOHANG));
diff --git a/vdc.cpp b/vdc.cpp
index b249987..4eb988d 100644
--- a/vdc.cpp
+++ b/vdc.cpp
@@ -84,6 +84,8 @@
         int encryptionFlags = android::os::IVold::ENCRYPTION_FLAG_IN_PLACE
                 | android::os::IVold::ENCRYPTION_FLAG_NO_UI;
         exit(vold->fdeEnable(passwordType, "", encryptionFlags).isOk() ? 0 : ENOTTY);
+    } else if (arg1 == "cryptfs" && arg2 == "mountdefaultencrypted") {
+        exit(vold->mountDefaultEncrypted().isOk() ? 0 : ENOTTY);
     } else if (arg1 == "volume" && arg2 == "shutdown") {
         exit(vold->shutdown().isOk() ? 0 : ENOTTY);
     } else {