Modify the WiFi softap SSID

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.