am bac5eb96: Merge "Delay disk inserted broadcast until disk is ready"

* commit 'bac5eb966c5c3aa9abe83cdb5187326f422741ab':
  Delay disk inserted broadcast until disk is ready
This commit is contained in:
Jean-Baptiste Queru 2012-05-22 07:44:54 -07:00 committed by Android Git Automerger
commit e925ff6670

View file

@ -113,6 +113,16 @@ int DirectVolume::handleBlockEvent(NetlinkEvent *evt) {
} else {
handlePartitionAdded(dp, evt);
}
/* Send notification iff disk is ready (ie all partitions found) */
if (getState() == Volume::State_Idle) {
char msg[255];
snprintf(msg, sizeof(msg),
"Volume %s %s disk inserted (%d:%d)", getLabel(),
getMountpoint(), mDiskMajor, mDiskMinor);
mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeDiskInserted,
msg, false);
}
} else if (action == NetlinkEvent::NlActionRemove) {
if (!strcmp(devtype, "disk")) {
handleDiskRemoved(dp, evt);
@ -148,8 +158,6 @@ void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) {
mDiskNumParts = 1;
}
char msg[255];
int partmask = 0;
int i;
for (i = 1; i <= mDiskNumParts; i++) {
@ -169,11 +177,6 @@ void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) {
#endif
setState(Volume::State_Pending);
}
snprintf(msg, sizeof(msg), "Volume %s %s disk inserted (%d:%d)",
getLabel(), getMountpoint(), mDiskMajor, mDiskMinor);
mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeDiskInserted,
msg, false);
}
void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt) {