安卓设置默认热点密码
代码地址 frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiApConfigStore.java
/* Generate a default WPA2 based configuration with a random password.
We are changing the Wifi Ap configuration storage from secure settings to a
flat file accessible only by the system. A WPA2 based default configuration
will keep the device secure after the update */
private void setDefaultApConfiguration() {
WifiConfiguration config = new WifiConfiguration();
//设置初始昵称
//R.string.wifi_tether_configure_ssid_default 地址
// frameworks/core/res/res/values/strings.xml
config.SSID = mContext.getString(R.string.wifi_tether_configure_ssid_default);
//设置初始加密类型
config.allowedKeyManagement.set(KeyMgmt.WPA2_PSK);
String randomUUID = UUID.randomUUID().toString();
//first 12 chars from xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
//设置初始密码
config.preSharedKey = randomUUID.substring(0, 8) + randomUUID.substring(9,13);
sendMessage(WifiStateMachine.CMD_SET_AP_CONFIG, config);
}