Merge "vold: fix the range of stopped state of idleMaint" into tm-dev
diff --git a/FsCrypt.cpp b/FsCrypt.cpp
index 42df78b..6c08177 100644
--- a/FsCrypt.cpp
+++ b/FsCrypt.cpp
@@ -812,6 +812,23 @@
LOG(DEBUG) << "fscrypt_prepare_user_storage for volume " << escape_empty(volume_uuid)
<< ", user " << user_id << ", serial " << serial << ", flags " << flags;
+ // Internal storage must be prepared before adoptable storage, since the
+ // user's volume keys are stored in their internal storage.
+ if (!volume_uuid.empty()) {
+ if ((flags & android::os::IVold::STORAGE_FLAG_DE) &&
+ !android::vold::pathExists(android::vold::BuildDataMiscDePath("", user_id))) {
+ LOG(ERROR) << "Cannot prepare DE storage for user " << user_id << " on volume "
+ << volume_uuid << " before internal storage";
+ return false;
+ }
+ if ((flags & android::os::IVold::STORAGE_FLAG_CE) &&
+ !android::vold::pathExists(android::vold::BuildDataMiscCePath("", user_id))) {
+ LOG(ERROR) << "Cannot prepare CE storage for user " << user_id << " on volume "
+ << volume_uuid << " before internal storage";
+ return false;
+ }
+ }
+
if (flags & android::os::IVold::STORAGE_FLAG_DE) {
// DE_sys key
auto system_legacy_path = android::vold::BuildDataSystemLegacyPath(user_id);
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index bc556ef..a7d39c1 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -914,6 +914,10 @@
updateVirtualDisk();
mAddedUsers.clear();
mStartedUsers.clear();
+
+ // Abort all FUSE connections to avoid deadlocks if the FUSE daemon was killed
+ // with FUSE fds open.
+ abortFuse();
return 0;
}