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
gugelfrei
Zim 5 years ago
parent a438b24368
commit 2d45d9b420

@ -455,24 +455,19 @@ int VolumeManager::onUserAdded(userid_t userId, int userSerialNumber) {
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::onUserStarted(userid_t userId) {
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);
}

@ -99,6 +99,11 @@ status_t EmulatedVolume::doMount() {
}
setFuseFd(std::move(fd));
return 0;
} else if (getMountUserId() != 0) {
// For sdcardfs, only mount for user 0, since user 0 will always be running
// and the paths don't change for different users. Trying to double mount
// will cause sepolicy to scream since sdcardfs prevents 'mounton'
return OK;
}
if (!(mFusePid = fork())) {
@ -174,6 +179,10 @@ status_t EmulatedVolume::doUnmount() {
rmdir(pass_through_path.c_str());
setFuseFd(android::base::unique_fd());
return OK;
} else if (getMountUserId() != 0) {
// For sdcardfs, only unmount for user 0, since user 0 will always be running
// and the paths don't change for different users.
return OK;
}
ForceUnmount(mFuseDefault);

Loading…
Cancel
Save