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

Commit 5f27ef49 authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Move MountService's Handler to a different thread.

This should help avoid blocking the system UI during storage
operations.

Change-Id: Ic53cb370baf47e8b00476706ac8df45645a2d814
parent e118d6fb
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import android.os.storage.IMountServiceListener;
import android.os.storage.IMountShutdownObserver;
import android.os.storage.StorageResultCode;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.IBinder;
@@ -193,10 +195,14 @@ class MountService extends IMountService.Stub
        }
    }

    final private Handler mHandler = new Handler() {
    class MountServiceHandler extends Handler {
        ArrayList<UnmountCallBack> mForceUnmounts = new ArrayList<UnmountCallBack>();
        boolean mRegistered = false;

        MountServiceHandler(Looper l) {
            super(l);
        }

        void registerReceiver() {
            mRegistered = true;
            mContext.registerReceiver(mPmReceiver, mPmFilter);
@@ -287,6 +293,8 @@ class MountService extends IMountService.Stub
            }
        }
    };
    final private HandlerThread mHandlerThread;
    final private Handler mHandler;

    private void waitForReady() {
        while (mReady == false) {
@@ -850,6 +858,10 @@ class MountService extends IMountService.Stub
        mContext.registerReceiver(mBroadcastReceiver,
                new IntentFilter(Intent.ACTION_BOOT_COMPLETED), null, null);

        mHandlerThread = new HandlerThread("MountService");
        mHandlerThread.start();
        mHandler = new MountServiceHandler(mHandlerThread.getLooper());

        /*
         * Vold does not run in the simulator, so pretend the connector thread
         * ran and did its thing.