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/VolumeManager.cpp b/VolumeManager.cpp
index ffe4e22..a383651 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -15,12 +15,16 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <errno.h>
 
 #define LOG_TAG "Vold"
 
 #include <cutils/log.h>
 
+#include <sysutils/NetlinkEvent.h>
+
 #include "VolumeManager.h"
 #include "DeviceVolume.h"
 #include "ErrorCode.h"
@@ -56,37 +60,24 @@
     return 0;
 }
 
-void VolumeManager::handleDiskInserted(const char *devpath, int maj, int min,
-                                       int nr_parts) {
+void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
+    const char *devpath = evt->findParam("DEVPATH");
 
-    /* Lookup possible candidate DeviceVolumes */
+    /* Lookup a volume to handle this device */
     VolumeCollection::iterator it;
     bool hit = false;
     for (it = mVolumes->begin(); it != mVolumes->end(); ++it) {
-        if (!(*it)->handleDiskInsertion(devpath, maj, min, nr_parts)) {
+        if (!(*it)->handleBlockEvent(evt)) {
             hit = true;
-            LOGD("Volume '%s' has handled disk insertion for '%s'",
-                 (*it)->getLabel(), devpath);
             break;
         }
     }
 
     if (!hit) {
-        LOGW("No volumes handled insertion of disk '%s'", devpath);
+        LOGW("No volumes handled block event for '%s'", devpath);
     }
 }
 
-void VolumeManager::handleDiskRemoved(int maj, int min) {
-}
-
-void VolumeManager::handlePartCreated(const char *devpath, int maj, int min,
-                                      int part_no) {
-}
-
-void VolumeManager::handlePartRemoved(int maj, int min) {
-}
-
-
 int VolumeManager::listVolumes(SocketClient *cli) {
     VolumeCollection::iterator i;