Replace EnsureDirExists with a call to setupAppDir
Test: Manually verified ownership of /storage/emulated/0/Android/data on cf_x86_phone-userdebug after enabling feature
Bug: 151455752
Change-Id: I75a1e3b769476e56094e41d82e7f8e1a72827ded
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 6a40a52..e4e5781 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -776,7 +776,8 @@
}
// Fork the process and remount storage
-static bool forkAndRemountStorage(int uid, int pid, const std::vector<std::string>& packageNames) {
+bool VolumeManager::forkAndRemountStorage(int uid, int pid,
+ const std::vector<std::string>& packageNames) {
userid_t userId = multiuser_get_user_id(uid);
std::string mnt_path = StringPrintf("/proc/%d/ns/mnt", pid);
android::base::unique_fd nsFd(
@@ -814,7 +815,8 @@
PLOG(ERROR) << "Failed to create dir: " << sources_cstr[i];
return false;
}
- status = EnsureDirExists(targets_cstr[i], 0771, AID_MEDIA_RW, AID_MEDIA_RW);
+ // Make sure /storage/emulated/... paths are setup correctly
+ status = setupAppDir(targets_cstr[i], uid, false /* fixupExistingOnly */);
if (status != OK) {
PLOG(ERROR) << "Failed to create dir: " << targets_cstr[i];
return false;
diff --git a/VolumeManager.h b/VolumeManager.h
index b83871e..a9087fd 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -130,6 +130,8 @@
int updateVirtualDisk();
int setDebug(bool enable);
+ bool forkAndRemountStorage(int uid, int pid, const std::vector<std::string>& packageNames);
+
static VolumeManager* Instance();
/*