标签:
connectivity= ConnectivityService.getInstance(context);
ServiceManager.addService(Context.CONNECTIVITY_SERVICE,connectivity);
其中ConnectivityService.getInstance(context); 对应于frameworks/base/services/java/com/android/server/ConnectivityService.Java
下面看一下 ConnectivityService.Java中的
for(int netType : mPriorityList) {
switch (mNetAttributes[netType].mRadio) {
case ConnectivityManager.TYPE_WIFI:
Slog.v(TAG, "StartingWifi Service.");
WifiStateTracker wst = newWifiStateTracker(context, mHandler);
WifiService wifiService = newWifiService(context, wst);
ServiceManager.addService(Context.WIFI_SERVICE,wifiService);
wifiService.startWifi();//启动 wifiservice
mNetTrackers[ConnectivityManager.TYPE_WIFI] = wst;
wst.startMonitoring();//启动Monitoring
mWifiEnabler = new WifiEnabler(this,(CheckBoxPreference)findPreference("enable_wifi"));
mNotifyOpenNetworks =(CheckBoxPreference) findPreference("notify_open_networks");
mNotifyOpenNetworks.setChecked(Secure.getInt(getContentResolver(),Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,0) == 1);
标签:
原文地址:http://www.cnblogs.com/polo/p/5527504.html