am 210228a0
: Merge "Start tracking added users with serial numbers." into mnc-dev
* commit '210228a089cd215bc671b9fb664d869d2c5ad986': Start tracking added users with serial numbers.
This commit is contained in:
commit
b75343ae99
3 changed files with 39 additions and 15 deletions
|
@ -185,13 +185,21 @@ int CommandListener::VolumeCmd::runCommand(SocketClient *cli,
|
|||
// mkdirs [path]
|
||||
return sendGenericOkFail(cli, vm->mkdirs(argv[2]));
|
||||
|
||||
} else if (cmd == "start_user" && argc > 2) {
|
||||
// start_user [user]
|
||||
return sendGenericOkFail(cli, vm->startUser(atoi(argv[2])));
|
||||
} else if (cmd == "user_added" && argc > 3) {
|
||||
// user_added [user] [serial]
|
||||
return sendGenericOkFail(cli, vm->onUserAdded(atoi(argv[2]), atoi(argv[3])));
|
||||
|
||||
} else if (cmd == "cleanup_user" && argc > 2) {
|
||||
// cleanup_user [user]
|
||||
return sendGenericOkFail(cli, vm->cleanupUser(atoi(argv[2])));
|
||||
} else if (cmd == "user_removed" && argc > 2) {
|
||||
// user_removed [user]
|
||||
return sendGenericOkFail(cli, vm->onUserRemoved(atoi(argv[2])));
|
||||
|
||||
} else if (cmd == "user_started" && argc > 2) {
|
||||
// user_started [user]
|
||||
return sendGenericOkFail(cli, vm->onUserStarted(atoi(argv[2])));
|
||||
|
||||
} else if (cmd == "user_stopped" && argc > 2) {
|
||||
// user_stopped [user]
|
||||
return sendGenericOkFail(cli, vm->onUserStopped(atoi(argv[2])));
|
||||
|
||||
} else if (cmd == "mount" && argc > 2) {
|
||||
// mount [volId] [flags] [user]
|
||||
|
|
|
@ -426,28 +426,38 @@ int VolumeManager::linkPrimary(userid_t userId) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int VolumeManager::startUser(userid_t userId) {
|
||||
int VolumeManager::onUserAdded(userid_t userId, int userSerialNumber) {
|
||||
mAddedUsers[userId] = userSerialNumber;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VolumeManager::onUserRemoved(userid_t userId) {
|
||||
mAddedUsers.erase(userId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VolumeManager::onUserStarted(userid_t userId) {
|
||||
// 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.
|
||||
std::string path(StringPrintf("%s/%d", kUserMountPath, userId));
|
||||
fs_prepare_dir(path.c_str(), 0755, AID_ROOT, AID_ROOT);
|
||||
|
||||
mUsers.push_back(userId);
|
||||
mStartedUsers.insert(userId);
|
||||
if (mPrimary) {
|
||||
linkPrimary(userId);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VolumeManager::cleanupUser(userid_t userId) {
|
||||
mUsers.remove(userId);
|
||||
int VolumeManager::onUserStopped(userid_t userId) {
|
||||
mStartedUsers.erase(userId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VolumeManager::setPrimary(const std::shared_ptr<android::vold::VolumeBase>& vol) {
|
||||
mPrimary = vol;
|
||||
for (userid_t userId : mUsers) {
|
||||
for (userid_t userId : mStartedUsers) {
|
||||
linkPrimary(userId);
|
||||
}
|
||||
return 0;
|
||||
|
@ -462,7 +472,8 @@ int VolumeManager::reset() {
|
|||
disk->destroy();
|
||||
disk->create();
|
||||
}
|
||||
mUsers.clear();
|
||||
mAddedUsers.clear();
|
||||
mStartedUsers.clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include <list>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <cutils/multiuser.h>
|
||||
#include <utils/List.h>
|
||||
|
@ -118,8 +120,10 @@ public:
|
|||
|
||||
nsecs_t benchmarkVolume(const std::string& id);
|
||||
|
||||
int startUser(userid_t userId);
|
||||
int cleanupUser(userid_t userId);
|
||||
int onUserAdded(userid_t userId, int userSerialNumber);
|
||||
int onUserRemoved(userid_t userId);
|
||||
int onUserStarted(userid_t userId);
|
||||
int onUserStopped(userid_t userId);
|
||||
|
||||
int setPrimary(const std::shared_ptr<android::vold::VolumeBase>& vol);
|
||||
|
||||
|
@ -198,7 +202,8 @@ private:
|
|||
std::list<std::shared_ptr<DiskSource>> mDiskSources;
|
||||
std::list<std::shared_ptr<android::vold::Disk>> mDisks;
|
||||
|
||||
std::list<userid_t> mUsers;
|
||||
std::unordered_map<userid_t, int> mAddedUsers;
|
||||
std::unordered_set<userid_t> mStartedUsers;
|
||||
|
||||
std::shared_ptr<android::vold::VolumeBase> mInternalEmulated;
|
||||
std::shared_ptr<android::vold::VolumeBase> mPrimary;
|
||||
|
|
Loading…
Reference in a new issue