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

Commit a7430559 authored by David Su's avatar David Su
Browse files

Fix boot time regression

Spin up a new thread to perform Wifi initialization.

Also reordered initialization so that WifiScanningService
starts before WifiService, since WifiService needs to
call WifiScanner.

Bug: 141003116
Bug: 140938772

Test: atest google/perf/boottime/boottime-test -v
Change-Id: Idcc910f853a2270924bf138b636a3c56158cf1af
parent 4c4650cb
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL;
import android.annotation.NonNull;
import android.content.Context;
import android.net.ConnectivityModuleConnector;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -56,13 +57,20 @@ public class WifiStackClient {
        public void onModuleServiceConnected(IBinder service) {
            Log.i(TAG, "Wifi stack connected");

            // spin up a new thread to not block system_server main thread
            HandlerThread thread = new HandlerThread("InitWifiServicesThread");
            thread.start();
            thread.getThreadHandler().post(() -> {
                registerWifiStackService(service);
                IWifiStackConnector connector = IWifiStackConnector.Stub.asInterface(service);
            registerApiServiceAndStart(connector, Context.WIFI_SERVICE);
                registerApiServiceAndStart(connector, Context.WIFI_SCANNING_SERVICE);
                registerApiServiceAndStart(connector, Context.WIFI_SERVICE);
                registerApiServiceAndStart(connector, Context.WIFI_P2P_SERVICE);
                registerApiServiceAndStart(connector, Context.WIFI_AWARE_SERVICE);
                registerApiServiceAndStart(connector, Context.WIFI_RTT_RANGING_SERVICE);

                thread.quitSafely();
            });
        }
    }