recovery: Hide unmountable volumes from selection

* In volume manager, check if new volumes are mountable.

* Check volumes for mountable for inclusion into update list.

* Erase unmountable volumes from volumes vector for consistency with
  the item array.

Change-Id: I89ff6cc05a93afffe5e46b24d70fc368bccaf020
diff --git a/volume_manager/EmulatedVolume.cpp b/volume_manager/EmulatedVolume.cpp
index 23e6434..d0e0dcf 100644
--- a/volume_manager/EmulatedVolume.cpp
+++ b/volume_manager/EmulatedVolume.cpp
@@ -32,6 +32,7 @@
 #include <sys/sysmacros.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <unistd.h>
 
 using android::base::StringPrintf;
 
@@ -39,6 +40,7 @@
 namespace volmgr {
 
 static const std::string kStagingPath = "/mnt/staging/emulated";
+static const std::string kFbeKeyVersion = kStagingPath + "/unencrypted/key/version";
 
 EmulatedVolume::EmulatedVolume(FstabEntry* rec, const std::string& subdir)
     : VolumeBase(Type::kEmulated),
@@ -90,5 +92,15 @@
     return OK;
 }
 
+bool EmulatedVolume::detectMountable() {
+    bool mountable = false;
+    if (doMount() == OK) {
+        // Check if FBE encrypted
+        mountable = access(kFbeKeyVersion.c_str(), F_OK) != 0;
+        doUnmount();
+    }
+    return mountable;
+}
+
 }  // namespace volmgr
 }  // namespace android