WIFI启动流程

系统加载system后会在第一时间加载SystemServer,WiFi的服务就在这时被加载启动的

    private static final String WIFI_SERVICE_CLASS =
            "com.android.server.wifi.WifiService";
    private static final String WIFI_P2P_SERVICE_CLASS =
            "com.android.server.wifi.p2p.WifiP2pService";

   mSystemServiceManager.startService(WIFI_P2P_SERVICE_CLASS);
   mSystemServiceManager.startService(WIFI_SERVICE_CLASS);
   mSystemServiceManager.startService("com.android.server.wifi.WifiScanningService");
   mSystemServiceManager.startService("com.android.server.wifi.RttService");

    下面我们来分析下WiFiService

public final class WifiService extends SystemService {

    private static final String TAG = "WifiService";
    final WifiServiceImpl mImpl;

    public WifiService(Context context) {
        super(context);
        mImpl = new WifiServiceImpl(context);
    }

    @Override
    public void onStart() {
        Log.i(TAG, "Registering " + Context.WIFI_SERVICE);
        publishBinderService(Context.WIFI_SERVICE, mImpl);
    }

    @Override
    public void onBootPhase(int phase) {
        if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
            mImpl.checkAndStartWifi();
        }
    }
}
    从上面可以看出,WifiService只做了两件事:一、初始化并绑定WifiServiceImpl 二、改变WiFi状态 ,所有对WiFi的操作都是在WiFiServiceImpl中实现的。
 

你可能感兴趣的:(WIFI启动流程)