Volumes know parent disks; unsupported disks.

This is cleaner and more direct than the reverse of having the disk
publish child volume membership.  Rename state constants to match
public API.  Add state representing bad removal.  Make it clear that
volume flags are related to mounting.

Send new unsupported disk event when we finish scanning an entire
disk and have no meaningful volumes.

Bug: 19993667
Change-Id: I08a91452ff561171a484d1da5745293ec893aec0
diff --git a/Disk.cpp b/Disk.cpp
index 51eeba8..5e222b3 100644
--- a/Disk.cpp
+++ b/Disk.cpp
@@ -36,6 +36,8 @@
 #include <sys/stat.h>
 #include <sys/mount.h>
 
+#define ENTIRE_DEVICE_FALLBACK 0
+
 using android::base::ReadFileToString;
 using android::base::WriteStringToFile;
 using android::base::StringPrintf;
@@ -125,8 +127,8 @@
     }
 
     mVolumes.push_back(vol);
+    vol->setDiskId(getId());
     vol->create();
-    notifyEvent(ResponseCode::DiskVolumeCreated, vol->getId());
 }
 
 void Disk::createPrivateVolume(dev_t device, const std::string& partGuid) {
@@ -157,14 +159,13 @@
     }
 
     mVolumes.push_back(vol);
+    vol->setDiskId(getId());
     vol->create();
-    notifyEvent(ResponseCode::DiskVolumeCreated, vol->getId());
 }
 
 void Disk::destroyAllVolumes() {
     for (auto vol : mVolumes) {
         vol->destroy();
-        notifyEvent(ResponseCode::DiskVolumeDestroyed, vol->getId());
     }
     mVolumes.clear();
 }
@@ -295,11 +296,19 @@
         }
     }
 
+#if ENTIRE_DEVICE_FALLBACK
     // Ugly last ditch effort, treat entire disk as partition
     if (table == Table::kUnknown || !foundParts) {
+        // TODO: use blkid to confirm filesystem before doing this
         LOG(WARNING) << mId << " has unknown partition table; trying entire device";
         createPublicVolume(mDevice);
     }
+#endif
+
+    // Well this is embarrassing, we can't handle the disk
+    if (mVolumes.size() == 0) {
+        notifyEvent(ResponseCode::DiskUnsupported);
+    }
 
     mJustPartitioned = false;
     return OK;