am eacf7e03: Only cleanup ASECs in external storage DO NOT MERGE

* commit 'eacf7e03d60a2b33ac6cdaa0e01bd6a6fdd9455a':
  Only cleanup ASECs in external storage DO NOT MERGE
diff --git a/DirectVolume.cpp b/DirectVolume.cpp
index 4acee76..2a24376 100644
--- a/DirectVolume.cpp
+++ b/DirectVolume.cpp
@@ -113,6 +113,16 @@
                 } 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 @@
         mDiskNumParts = 1;
     }
 
-    char msg[255];
-
     int partmask = 0;
     int i;
     for (i = 1; i <= mDiskNumParts; i++) {
@@ -169,11 +177,6 @@
 #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) {
@@ -275,6 +278,11 @@
     int major = atoi(evt->findParam("MAJOR"));
     int minor = atoi(evt->findParam("MINOR"));
     char msg[255];
+    bool enabled;
+
+    if (mVm->shareEnabled(getLabel(), "ums", &enabled) == 0 && enabled) {
+        mVm->unshareVolume(getLabel(), "ums");
+    }
 
     SLOGD("Volume %s %s disk %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
     snprintf(msg, sizeof(msg), "Volume %s %s disk removed (%d:%d)",