Modify the default SSID of a Wi-Fi softap instance
In versions earlier than andorid4.0, modifying the softap SSID is in wifiservice. java.
Private Boolean setwifiapenabledblocking
In Versions later than 4.0, the original SSID value is moved to wifiapconfigstore. java. A little change to softap after the 4.0 state machine mechanism is used.
/* Generate a default wpa2 based configuration with a random password.
We are changing the WiFi AP configuration storage from secure settings to
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 ();
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. pai_set_ap_config, config );
}
In fact, the default SSID value has been written when the WiFi state machine is started.
Public wifistatemachine (context, string wlaninterface ){
...
Wifiapconfigstore = wifiapconfigstore. makewifiapconfigstore (
Context, gethandler ());
Wifiapconfigstore. loadapconfiguration ();
...
}
I changed the default value of the SSID today, so I will share the method with you. Open Source: knowledge belongs to everyone.
Private void setdefaultapconfiguration (){
Wificonfiguration Config = new wificonfiguration ();
-Config. SSID = mcontext. getstring (R. String. wifi_tether_configure_ssid_default );
+ // The default softap SSID shocould be the product name
+ // Config. SSID = mcontext. getstring (R. String. wifi_tether_configure_ssid_default );
+ Config. SSID = systemproperties. Get ("Ro. Build. Product"); // change the default SSID value to the product name.
Config. allowedkeymanagement. Set (keymgmt. wpa2_psk );
String randomuuid = UUID. randomuuid (). tostring ();
// First 12 chars from xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx