connectivity = ConnectivityService.getInstance(context);
ServiceManager.addService(Context.CONNECTIVE_SETVICE,connectvity);
ConnectivityService 啟動時,會從 resource load 進這個 device 所有的 NetworkAttributes[]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This string array should be overridden by the device to present a list of network | |
attributes. This is used by the connectivity manager to decide which networks can coexist | |
based on the hardware --> | |
<!-- An Array of "[Connection name],[ConnectivityManager connection type], | |
[associated radio-type],[priority] --> | |
<string-array translatable="false" name="networkAttributes"> | |
<item>"wifi,1,1,1"</item> | |
<item>"mobile,0,0,0"</item> | |
<item>"mobile_mms,2,0,2"</item> | |
<item>"mobile_supl,3,0,2"</item> | |
<item>"mobile_hipri,5,0,3"</item> | |
<item>"ethernet,9,9,9"</item> | |
<item>"pppoe,10,10,10"</item> | |
</string-array> | |
<!-- This string array should be overridden by the device to present a list of radio | |
attributes. This is used by the connectivity manager to decide which networks can coexist | |
based on the hardware --> | |
<!-- An Array of "[ConnectivityManager connectionType], | |
[# simultaneous connection types]" --> | |
<string-array translatable="false" name="radioAttributes"> | |
<item>"1,1"</item> | |
<item>"0,1"</item> | |
<item>"9,1"</item> | |
<item>"10,1"</item> | |
</string-array> |
然後一一將他門生出來..例如 Wifi
case ConnectivityManager.TYPE_WIFI:
Slog.d(TAG, "Starting Wifi Service.");
WifiStateTracker wst = new WifiStateTracker(context, mHandler);
WifiService wifiService = new WifiService(context, wst);
ServiceManager.addService(Context.WIFI_SERVICE, wifiService);
wifiService.startWifi();
mNetTrackers[ConnectivityManager.TYPE_WIFI] = wst;
wst.startMonitoring();
break;
WifiStateTracker 被傳入 WifiServer 中,同時也被 ConnectivityService 紀錄在要照顧的 mNetTrackers[] 陣列中。
不直接在 WifiServer 中實做 WifiStateTracker (介面?) 的原因大概是因為 WifiStateTracker 不是 interface,而是 Abstract Class。
又 java 不允許多重繼承的原因。
而 NetworkStateTracker 又是一個 abstract class, 不是 interface。
.. 問題反而變成 NetworkStateTracker 為什麼是 abstract class, not interface
沒有留言:
張貼留言