Unmount public sdcard filesystems before killing the fuse process.

Avoids ENOTCONN during eject for sdcard users.

Change-Id: I7b89ccaad4bb7af3639dc0b702168030a2f88366
Bug: 28268676
diff --git a/PublicVolume.cpp b/PublicVolume.cpp
index e748de6..893f928 100644
--- a/PublicVolume.cpp
+++ b/PublicVolume.cpp
@@ -194,12 +194,10 @@
 }
 
 status_t PublicVolume::doUnmount() {
-    if (mFusePid > 0) {
-        kill(mFusePid, SIGTERM);
-        TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, 0));
-        mFusePid = 0;
-    }
-
+    // Unmount the storage before we kill the FUSE process. If we kill
+    // the FUSE process first, most file system operations will return
+    // ENOTCONN until the unmount completes. This is an exotic and unusual
+    // error code and might cause broken behaviour in applications.
     KillProcessesUsingPath(getPath());
 
     ForceUnmount(kAsecPath);
@@ -209,6 +207,12 @@
     ForceUnmount(mFuseWrite);
     ForceUnmount(mRawPath);
 
+    if (mFusePid > 0) {
+        kill(mFusePid, SIGTERM);
+        TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, 0));
+        mFusePid = 0;
+    }
+
     rmdir(mFuseDefault.c_str());
     rmdir(mFuseRead.c_str());
     rmdir(mFuseWrite.c_str());