vold: support "volume list [broadcast]" command
Sometimes when an sdcard is already mounted, some info like uuid and label are not re-broadcast to new listeners. The extra argument to list allows late listeners to catch up by asking volume list to broadcast that info again. Bug: 16253597 Bug: 16306775 Change-Id: Ie7d0c1132c22d307a5b2a0e50075a3716138d00b Signed-off-by: Benson Huang <benson.huang@mediatek.com> (cherry picked from commit 85f4700f44170b772697e627b3075dcb9137e1b7)
This commit is contained in:
parent
e068a491c2
commit
40b64a6841
3 changed files with 19 additions and 3 deletions
|
@ -131,7 +131,8 @@ int CommandListener::VolumeCmd::runCommand(SocketClient *cli,
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (!strcmp(argv[1], "list")) {
|
if (!strcmp(argv[1], "list")) {
|
||||||
return vm->listVolumes(cli);
|
bool broadcast = argc >= 3 && !strcmp(argv[2], "broadcast");
|
||||||
|
return vm->listVolumes(cli, broadcast);
|
||||||
} else if (!strcmp(argv[1], "debug")) {
|
} else if (!strcmp(argv[1], "debug")) {
|
||||||
if (argc != 3 || (argc == 3 && (strcmp(argv[2], "off") && strcmp(argv[2], "on")))) {
|
if (argc != 3 || (argc == 3 && (strcmp(argv[2], "off") && strcmp(argv[2], "on")))) {
|
||||||
cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: volume debug <off/on>", false);
|
cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: volume debug <off/on>", false);
|
||||||
|
|
|
@ -260,8 +260,9 @@ void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int VolumeManager::listVolumes(SocketClient *cli) {
|
int VolumeManager::listVolumes(SocketClient *cli, bool broadcast) {
|
||||||
VolumeCollection::iterator i;
|
VolumeCollection::iterator i;
|
||||||
|
char msg[256];
|
||||||
|
|
||||||
for (i = mVolumes->begin(); i != mVolumes->end(); ++i) {
|
for (i = mVolumes->begin(); i != mVolumes->end(); ++i) {
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
@ -270,6 +271,20 @@ int VolumeManager::listVolumes(SocketClient *cli) {
|
||||||
(*i)->getState());
|
(*i)->getState());
|
||||||
cli->sendMsg(ResponseCode::VolumeListResult, buffer, false);
|
cli->sendMsg(ResponseCode::VolumeListResult, buffer, false);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
if (broadcast) {
|
||||||
|
if((*i)->getUuid()) {
|
||||||
|
snprintf(msg, sizeof(msg), "%s %s \"%s\"", (*i)->getLabel(),
|
||||||
|
(*i)->getFuseMountpoint(), (*i)->getUuid());
|
||||||
|
mBroadcaster->sendBroadcast(ResponseCode::VolumeUuidChange,
|
||||||
|
msg, false);
|
||||||
|
}
|
||||||
|
if((*i)->getUserLabel()) {
|
||||||
|
snprintf(msg, sizeof(msg), "%s %s \"%s\"", (*i)->getLabel(),
|
||||||
|
(*i)->getFuseMountpoint(), (*i)->getUserLabel());
|
||||||
|
mBroadcaster->sendBroadcast(ResponseCode::VolumeUserLabelChange,
|
||||||
|
msg, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cli->sendMsg(ResponseCode::CommandOkay, "Volumes listed.", false);
|
cli->sendMsg(ResponseCode::CommandOkay, "Volumes listed.", false);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
|
|
||||||
int addVolume(Volume *v);
|
int addVolume(Volume *v);
|
||||||
|
|
||||||
int listVolumes(SocketClient *cli);
|
int listVolumes(SocketClient *cli, bool broadcast);
|
||||||
int mountVolume(const char *label);
|
int mountVolume(const char *label);
|
||||||
int unmountVolume(const char *label, bool force, bool revert);
|
int unmountVolume(const char *label, bool force, bool revert);
|
||||||
int shareVolume(const char *label, const char *method);
|
int shareVolume(const char *label, const char *method);
|
||||||
|
|
Loading…
Reference in a new issue