Merge "Pre-create userdata metadata encryption device."
diff --git a/MetadataCrypt.cpp b/MetadataCrypt.cpp
index ef4c41e..8b2b960 100644
--- a/MetadataCrypt.cpp
+++ b/MetadataCrypt.cpp
@@ -125,7 +125,9 @@
auto dir = metadata_key_dir + "/key";
LOG(DEBUG) << "metadata_key_dir/key: " << dir;
if (!MkdirsSync(dir, 0700)) return false;
- if (!pathExists(dir)) {
+ auto in_dsu = android::base::GetBoolProperty("ro.gsid.image_running", false);
+ // !pathExists(dir) does not imply there's a factory reset when in DSU mode.
+ if (!pathExists(dir) && !in_dsu) {
auto delete_all = android::base::GetBoolProperty(
"ro.crypto.metadata_init_delete_all_keys.enabled", false);
if (delete_all) {