系统settings wifi初探
系统代码位置:packages/apps/Settings/
编译结果:out/target/product/ckt92_we_kk/system/priv-app/Settings.apk
上图是settings wifi的按钮。
class WifiEnabler
上图红色的框
class AccessPoint
AccessPoint代表一个一个访问点。包含了AP所有的信息
class WifiSettings
上图中蓝色部分的刷新,在WifiSettings中完成。
updateAccessPoints
/** * Shows the latest access points available with supplimental information like * the strength of network and the security for it. */ private void updateAccessPoints() {
constructAccessPoints
定义和调用处的注释指出会返回排序后的AP.
/** Returns sorted list of access points */ private List<AccessPoint> constructAccessPoints() {
// AccessPoints are automatically sorted with TreeSet. final Collection<AccessPoint> accessPoints = constructAccessPoints();
每次调用前会先清空界面上面的AP list
/// M: empty ap list mExt.emptyCategory(getPreferenceScreen());
这段代码的不好之处在于,mExt.emptyCategory(getPreferenceScreen());的调用在函数constructAccessPoints()内,而添加新的AP list在函数外。
/// M: add ap to screen @{ for (AccessPoint accessPoint : accessPoints) { mExt.addPreference(getPreferenceScreen(), accessPoint, mExt.COMMON_AP, accessPoint.ssid, accessPoint.security); }