Move unsolicited vold events to Binder.

Create IVoldListener and move most unsolicited vold events over to
this new interface.  The remaining events will be routed through
method-specific listeners instead of a global one.

Move to upstream DISALLOW_COPY_AND_ASSIGN macro.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.DirectBootHostTest
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AdoptableHostTest
Test: cts-tradefed run commandAndExit cts-dev -m CtsOsTestCases -t android.os.storage.cts.StorageManagerTest
Bug: 13758960
Change-Id: Ib9293487db2d525a76b9b9c2e9ac18d98601c6cf
diff --git a/model/Disk.cpp b/model/Disk.cpp
index 9c22400..151937f 100644
--- a/model/Disk.cpp
+++ b/model/Disk.cpp
@@ -151,7 +151,12 @@
 status_t Disk::create() {
     CHECK(!mCreated);
     mCreated = true;
+#if ENABLE_BINDER
+    auto listener = VolumeManager::Instance()->getListener();
+    if (listener) listener->onDiskCreated(getId(), mFlags);
+#else
     notifyEvent(ResponseCode::DiskCreated, StringPrintf("%d", mFlags));
+#endif
     readMetadata();
     readPartitions();
     return OK;
@@ -161,7 +166,12 @@
     CHECK(mCreated);
     destroyAllVolumes();
     mCreated = false;
+#if ENABLE_BINDER
+    auto listener = VolumeManager::Instance()->getListener();
+    if (listener) listener->onDiskDestroyed(getId());
+#else
     notifyEvent(ResponseCode::DiskDestroyed);
+#endif
     return OK;
 }
 
@@ -281,9 +291,15 @@
     }
     }
 
+#if ENABLE_BINDER
+    auto listener = VolumeManager::Instance()->getListener();
+    if (listener) listener->onDiskMetadataChanged(getId(),
+            mSize, mLabel, mSysPath);
+#else
     notifyEvent(ResponseCode::DiskSizeChanged, StringPrintf("%" PRIu64, mSize));
     notifyEvent(ResponseCode::DiskLabelChanged, mLabel);
     notifyEvent(ResponseCode::DiskSysPathChanged, mSysPath);
+#endif
     return OK;
 }
 
@@ -306,7 +322,12 @@
     status_t res = ForkExecvp(cmd, output);
     if (res != OK) {
         LOG(WARNING) << "sgdisk failed to scan " << mDevPath;
+#if ENABLE_BINDER
+        auto listener = VolumeManager::Instance()->getListener();
+        if (listener) listener->onDiskScanned(getId());
+#else
         notifyEvent(ResponseCode::DiskScanned);
+#endif
         mJustPartitioned = false;
         return res;
     }
@@ -372,7 +393,12 @@
         }
     }
 
+#if ENABLE_BINDER
+    auto listener = VolumeManager::Instance()->getListener();
+    if (listener) listener->onDiskScanned(getId());
+#else
     notifyEvent(ResponseCode::DiskScanned);
+#endif
     mJustPartitioned = false;
     return OK;
 }