Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f7f7cad authored by San Mehat's avatar San Mehat
Browse files

ShutdownThread: Shutdown MountService before lowlevel shutdown



Signed-off-by: default avatarSan Mehat <san@google.com>
parent dde25397
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.RemoteException;
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;
@@ -190,6 +191,10 @@ public final class ShutdownThread extends Thread {
                IBluetooth.Stub.asInterface(ServiceManager.checkService(
                        BluetoothAdapter.BLUETOOTH_SERVICE));

        final IMountService mount =
                IMountService.Stub.asInterface(
                        ServiceManager.checkService("mount"));
        
        try {
            bluetoothOff = bluetooth == null ||
                           bluetooth.getBluetoothState() == BluetoothAdapter.STATE_OFF;
@@ -241,6 +246,17 @@ public final class ShutdownThread extends Thread {
            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();