vold2: Refactor the netlink event handling and better define how partitions/disks are handled
Signed-off-by: San Mehat <san@android.com>
diff --git a/NetlinkHandler.cpp b/NetlinkHandler.cpp
index 156079f..19ec932 100644
--- a/NetlinkHandler.cpp
+++ b/NetlinkHandler.cpp
@@ -44,7 +44,6 @@
void NetlinkHandler::onEvent(NetlinkEvent *evt) {
VolumeManager *vm = VolumeManager::Instance();
const char *subsys = evt->getSubsystem();
- int action = evt->getAction();
if (!subsys) {
LOGW("No subsystem found in netlink event");
@@ -52,37 +51,7 @@
}
if (!strcmp(subsys, "block")) {
- const char *devpath = evt->findParam("DEVPATH");
- const char *devtype = evt->findParam("DEVTYPE");
- int major = atoi(evt->findParam("MAJOR"));
- int minor = atoi(evt->findParam("MINOR"));
-
- LOGI("Block event %d, type %s, %d:%d, path '%s'", action, devtype, major, minor, devpath);
-
- if (!strcmp(devtype, "disk")) {
- const char *tmp = evt->findParam("NPARTS");
-
- if (!tmp) {
- LOGE("Disk uevent missing 'NPARTS' parameter");
- return;
- }
- if (action == NetlinkEvent::NlActionAdd)
- vm->handleDiskInserted(devpath, major, minor, atoi(tmp));
- else if (action == NetlinkEvent::NlActionRemove)
- vm->handleDiskRemoved(major, minor);
- } else {
- const char *tmp = evt->findParam("PARTN");
-
- if (!tmp) {
- LOGE("Partition uevent missing 'PARTN' parameter");
- return;
- }
- if (action == NetlinkEvent::NlActionAdd)
- vm->handlePartCreated(devpath, major, minor, atoi(tmp));
- else if (action == NetlinkEvent::NlActionRemove)
- vm->handlePartRemoved(major, minor);
- }
- LOGD("Block event handled");
+ vm->handleBlockEvent(evt);
} else if (!strcmp(subsys, "battery")) {
} else if (!strcmp(subsys, "power_supply")) {
} else {