点击Wifi热点配置选项,会弹出一个对话框,WifiApDialog.java。这个对话框会在onCreate的时候填入一些默认内容:
if (mWifiConfig != null) {
mSsid.setText(mWifiConfig.SSID);
if (mWifiConfig.apBand == 0) {
mBandIndex = 0;
} else {
mBandIndex = 1;
}
mSecurity.setSelection(mSecurityTypeIndex);
if (mSecurityTypeIndex == WPA2_INDEX) {
mPassword.setText(mWifiConfig.preSharedKey);
}
}
内容都是从mWifiConfig获取的,这个mWifiConfig是在构造的时候赋值:
// TetherSettings.java
private void initWifiTethering() {
final Activity activity = getActivity();
mWifiConfig = mWifiManager.getWifiApConfiguration(); // 这里获取的
mSecurityType = getResources().getStringArray(R.array.wifi_ap_security);
mCreateNetwork = findPreference(WIFI_AP_SSID_AND_SECURITY);