ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2012年12月10日 星期一

android, Wifi Service -- code reading,

SystemServer.java 啟動 connectivity = ConnectivityService.getInstance(context); ServiceManager.addService(Context.CONNECTIVE_SETVICE,connectvity); ConnectivityService 啟動時,會從 resource load 進這個 device 所有的 NetworkAttributes[]
<!-- 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>
view raw gistfile1.xml hosted with ❤ by GitHub


然後一一將他門生出來..例如 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


沒有留言:

標籤

網誌存檔