ShutdownThread: Shutdown MountService before lowlevel shutdown

Signed-off-by: San Mehat <san@google.com>
diff --git a/core/java/com/android/internal/app/ShutdownThread.java b/core/java/com/android/internal/app/ShutdownThread.java
index 2060cf8..c110f95 100644
--- a/core/java/com/android/internal/app/ShutdownThread.java
+++ b/core/java/com/android/internal/app/ShutdownThread.java
@@ -32,6 +32,7 @@
 import android.os.Power;
 import android.os.ServiceManager;
 import android.os.SystemClock;
+import android.os.IMountService;
 
 import com.android.internal.telephony.ITelephony;
 import android.util.Log;
@@ -189,6 +190,10 @@
         final IBluetooth bluetooth =
                 IBluetooth.Stub.asInterface(ServiceManager.checkService(
                         BluetoothAdapter.BLUETOOTH_SERVICE));
+
+        final IMountService mount =
+                IMountService.Stub.asInterface(
+                        ServiceManager.checkService("mount"));
         
         try {
             bluetoothOff = bluetooth == null ||
@@ -241,6 +246,17 @@
             SystemClock.sleep(PHONE_STATE_POLL_SLEEP_MSEC);
         }
 
+        // Shutdown MountService to ensure media is in a safe state
+        try {
+            if (mount != null) {
+                mount.shutdown();
+            } else {
+                Log.w(TAG, "MountService unavailable for shutdown");
+            }
+        } catch (Exception e) {
+            Log.e(TAG, "Exception during MountService shutdown", e);
+        }
+
         //shutdown power
         Log.i(TAG, "Performing low-level shutdown...");
         Power.shutdown();