Prevent SD-card from Un-mounting if cancelled during erase

If User cancels during the formatting stage
of "Erase SD Card", make sure you do not
Un-Mount the Volume

CRs-Fixed: 616156

Conflicts:
        core/java/com/android/internal/os/storage/ExternalStorageFormatter.java

Change-Id: I8d7e1cf64917ee3628a1a682e2f3fb32443f3a2e
diff --git a/core/java/com/android/internal/os/storage/ExternalStorageFormatter.java b/core/java/com/android/internal/os/storage/ExternalStorageFormatter.java
index f7a2cb7..86e8d15 100644
--- a/core/java/com/android/internal/os/storage/ExternalStorageFormatter.java
+++ b/core/java/com/android/internal/os/storage/ExternalStorageFormatter.java
@@ -59,6 +59,7 @@
     private boolean mFactoryReset = false;
     private boolean mAlwaysReset = false;
     private String mReason = null;
+    private boolean mIsFormatSuccess = false;
 
     StorageEventListener mStorageListener = new StorageEventListener() {
         @Override
@@ -199,6 +200,7 @@
                 || Environment.MEDIA_MOUNTED_READ_ONLY.equals(status)) {
             updateProgressDialog(R.string.progress_unmounting);
             try {
+                if(mIsFormatSuccess) return;
                 final IMountService mountService = getMountService();
                 final StorageVolume[] volumes = mountService.getVolumeList();
                 final ArrayList<StorageVolume> physicalVols = StorageManager.getPhysicalExternalVolume(volumes);
@@ -255,6 +257,7 @@
                                 extStoragePath = mStorageVolume.getPath();
                             }
                             mountService.formatVolume(extStoragePath);
+                            mIsFormatSuccess = true;
                             success = true;
                         } catch (Exception e) {
                             Toast.makeText(ExternalStorageFormatter.this,