Fix emulated volumes not created for secondary users Ifabaa12368e5a591fbcdce4ee71c83ff35fdac6b introduced individual emulated volumes for each Android user. The change however didn't create the volumes for the secondary users on user start in vold without the persist.sys.fuse flag Now we always create the volumes but only mount sdcardfs volumes for user 0 because the sdcardfs mount paths do not change with for different users unlike the FUSE mount paths. Bug: 144473552 Test: atest AdoptableHostTest Test: Start a guest user in Settings and launch chrome browser in that user, verify that chrome does not crash Change-Id: I89f3591d0197d86267f0e3934f496273e2f9fd7e
diff --git a/VolumeManager.cpp b/VolumeManager.cpp index 3e7101c..546f802 100644 --- a/VolumeManager.cpp +++ b/VolumeManager.cpp
@@ -455,24 +455,19 @@ int VolumeManager::onUserRemoved(userid_t userId) { LOG(INFO) << "onUserRemoved: " << userId; - if (GetBoolProperty(android::vold::kPropFuseSnapshot, false) && - mAddedUsers.find(userId) != mAddedUsers.end()) { - destroyEmulatedVolumesForUser(userId); - } - + onUserStopped(userId); mAddedUsers.erase(userId); - mStartedUsers.erase(userId); return 0; } int VolumeManager::onUserStarted(userid_t userId) { LOG(INFO) << "onUserStarted: " << userId; - if (GetBoolProperty(android::vold::kPropFuseSnapshot, false)) { - if (mStartedUsers.find(userId) == mStartedUsers.end()) { - createEmulatedVolumesForUser(userId); - } - } else { + if (mStartedUsers.find(userId) == mStartedUsers.end()) { + createEmulatedVolumesForUser(userId); + } + + if (!GetBoolProperty(android::vold::kPropFuseSnapshot, false)) { // Note that sometimes the system will spin up processes from Zygote // before actually starting the user, so we're okay if Zygote // already created this directory. @@ -491,8 +486,7 @@ int VolumeManager::onUserStopped(userid_t userId) { LOG(VERBOSE) << "onUserStopped: " << userId; - if (GetBoolProperty(android::vold::kPropFuseSnapshot, false) && - mStartedUsers.find(userId) != mStartedUsers.end()) { + if (mStartedUsers.find(userId) != mStartedUsers.end()) { destroyEmulatedVolumesForUser(userId); }