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

Commit bf8cbb05 authored by Paul Stewart's avatar Paul Stewart
Browse files

WifiManager: Use ConnectivityThread

Instead of minting it's own hander thread, have WifiManager use
the looper from ConnectivityThread.

Bug: 27432949

Change-Id: Iddeebeb8ab506c912f526c7569f304e10b9d7ab8
parent 74fc3bfc
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import android.media.soundtrigger.SoundTriggerManager;
import android.media.tv.ITvInputManager;
import android.media.tv.TvInputManager;
import android.net.ConnectivityManager;
import android.net.ConnectivityThread;
import android.net.EthernetManager;
import android.net.IConnectivityManager;
import android.net.IEthernetManager;
@@ -500,7 +501,8 @@ final class SystemServiceRegistry {
            public WifiManager createService(ContextImpl ctx) {
                IBinder b = ServiceManager.getService(Context.WIFI_SERVICE);
                IWifiManager service = IWifiManager.Stub.asInterface(b);
                return new WifiManager(ctx.getOuterContext(), service);
                return new WifiManager(ctx.getOuterContext(), service,
                        ConnectivityThread.getInstanceLooper());
            }});

        registerService(Context.WIFI_P2P_SERVICE, WifiP2pManager.class,
+4 −7
Original line number Diff line number Diff line
@@ -671,9 +671,7 @@ public class WifiManager {

    private AsyncChannel mAsyncChannel;
    private CountDownLatch mConnected;

    /* TODO(b/27432949): Use a common connectivity thread for this. */
    private HandlerThread mHandlerThread;
    private Looper mLooper;

    /**
     * Create a new WifiManager instance.
@@ -685,9 +683,10 @@ public class WifiManager {
     * @hide - hide this because it takes in a parameter of type IWifiManager, which
     * is a system private class.
     */
    public WifiManager(Context context, IWifiManager service) {
    public WifiManager(Context context, IWifiManager service, Looper looper) {
        mContext = context;
        mService = service;
        mLooper = looper;
        mTargetSdkVersion = context.getApplicationInfo().targetSdkVersion;
    }

@@ -1978,12 +1977,10 @@ public class WifiManager {
                        "getWifiServiceMessenger() returned null!  This is invalid.");
            }

            mHandlerThread = new HandlerThread("WifiManager");
            mAsyncChannel = new AsyncChannel();
            mConnected = new CountDownLatch(1);

            mHandlerThread.start();
            Handler handler = new ServiceHandler(mHandlerThread.getLooper());
            Handler handler = new ServiceHandler(mLooper);
            mAsyncChannel.connect(mContext, handler, messenger);
            try {
                mConnected.await();