Wifistatemachine Study Notes

Source: Internet
Author: User

Wifistatemachine
1. Initialization
Incoming Interface name Wlaninterface
Create a new WiFi type of Networkinfo
Send a broadcast with an SSID of NULL
Battery
Networkmanagementservice
Does peer support mp2psupported
Wifinative based on the interface name Wlaninterface
Wificonfigstore based on the wifinative
Wifimonitor based on the wifinative
Wifiinfo
Supplicantstatetracker
Two x Linkproperties:mlinkproperties + mnetlinklinkproperties
Mwifip2pmanager
A interfaceobserver. Let Networkmanagementservice help specifically monitor changes to IP address
Alarmmanager
Normal scan intent:scanintent + mscanintent Action_start_scan + scan_request
Bulk scan of Intent:batchedintent + mbatchedscanintervalintent Action_refresh_batched_scan
Framework default scan interval: Mdefaultframeworkscanintervalms
Driver Delay Stop Time: Mdriverstopdelayms
Background Scan support: mbackgroundscansupported
Peer Device Type: Mprimarydevicetype
User's power-saving choice: muserwantssuspendopt
Broadcastreceiver:action_tether_state_changed of monitoring tethering network status change
Broadcastreceiver:action_start_scan to listen for scan requests
Monitor screen status changes broadcastreceiver:action_screen_on + Action_screen_off +action_refresh_batched_scan
Broadcastreceiver:action_delayed_driver_stop for monitoring delay STOP DRIVER Request
Listen for user changes to the SUSPEND option: wifi_suspend_optimizations_enabled
Monitoring boot Completion option: action_boot_completed
List of LRUCache types: Mscanresultcache
Power PowerManager
Sleep Lock: Mwakelock + msuspendwakelock
Softap Power Saving Intent:softapidleintent + msoftapidleintent
Monitoring SOFTAP and STA connection disconnect condition: action_softap_sta_connected + action_softap_sta_disconnected
Connecting the broadcastreceiver:asus_choose_bestap_action of better hotspots
ENABLE All networks: Enableallnetworkintent + menableallnetworkintent + action_enable_all_network
Broadcastreceiver:action_sim_state_changed to monitor SIM card status


The following is the state machine structure:
0. Mdefaultstate:


1. Initial state of the Minitialstate state machine

2. Msupplicantstartingstate

3. Msupplicantstartedstate
3.1 Mdriverstartingstate
3.2 mdriverstartedstate
3.2.1 Mscanmodestate
3.2.2 Mconnectmodestate
3.2.2.1 Ml2connectedstate
3.2.2.2 Mdisconnectingstate
3.2.2.3 Mdisconnectedstate
3.2.2.4 mwpsrunningstate
3.3 Mwaitforp2pdisablestate
3.4 mdriverstoppingstate
3.5 mdriverstoppedstate
4. Msupplicantstoppingstate
5. Msoftapstartingstate
6. Msoftapstartedstate
6.1 Mtetheringstate
6.2 Mtetheredstate
6.3 Muntetheringstate


Each state machine contains, for example, the following processes:
1. Enter stage
2. ProcessMessage Stage
3. Exit Stage

After the state machine starts to inform: Wifi_scan_available


Take a look at what each state machine handles:


1. Initial state of the Minitialstate state machine
Enter stage:
Uninstalling driver
Connect to a peer-to state machine
SOFTAP Configuration state machine Wifiapconfigstore new and loaded configuration
Establishing a connection with the Softap state machine Wifiapconfigstore
ProcessMessage Stage:
The Messages processed are:
Cmd_start_supplicant:
Mwifinative Loading driver First
Networkmanagementservice loading STA-type firmware
Better Setinterfacedown before supplicant up.
Networkmanagementservice setting setinterfaceipv6privacyextensions?
Networkmanagementservice ban DisableIpv6?
Mwifimonitor kill the Killsupplicant in execution
Mwifinative Open Startsupplicant
Set WiFi status wifi_state_enabling: Send broadcast Wifi_state_changed_action
Mwifimonitor started to monitor the execution of supplicant: startmonitoring
Transfer to another State: 2. Msupplicantstartingstate
CMD_START_AP:
Mwifinative Loading driver First
Set SOFTAP Status: Wifi_ap_state_enabling
Transfer to another State: 5. Msoftapstartingstate


2. Msupplicantstartingstate
ProcessMessage Stage:
The Messages processed are:
Wifimonitor.sup_connection_event:
Set State wifi_state_enabled
Send Message cmd_reset_supplicant_state to Msupplicantstatetracker, indicating that supplicant status is unknown today
Wifiinfo setting MAC Address: setmacaddress
Mwificonfigstore load and enable all networks Loadandenableallnetworks
Initializing the WPS connection: initializewpsdetails
Send broadcast indicates supplicant connection succeeded: Sendsupplicantconnectionchangedbroadcast
Transfer to another state: 3.2 mdriverstartedstate
Wifimonitor.sup_disconnection_event:
Tries to Supplicant_restart_tries (=5) times to start and connect supplicant
If the reboot is more than 5 times, set the state Wifi_state_unknown and move to State 1. Minitialstate
Otherwise killsupplicant, transfer to State 1. Minitialstate, send cmd_start_supplicant interval supplicant_restart_interval_msecs restart supplicant
Other messages left for mdefaultstate processing


3.2 mdriverstartedstate
Enter stage:
Notification Battery: Updatebatteryworksource + mwakelock.setworksource (newsource);
Set up bluetooth co-scanning mode, some scan parameters to change to reduce the interference to BT: Setbluetoothcoexistencescanmode
Set Country Code:setcountrycode
Set Band: Setfrequencyband
Set current network status information, i.e. change mnetworkinfo:setnetworkdetailedstate
Set IPv6 packet filter, just filter IPv6 packet, reason Baidu: Stopfilteringmulticastv6packets
Set IPv4 packet Filter:startfilteringmulticastv4packets + stopfilteringmulticastv4packets
The three operation states of the STA are performed according to the user settings:
Connect_mode, able to scan and connect to the AP and move to other states mdisconnectedstate
Scan_only_mode, can only scan the AP, transfer to other States 3.2.1 Mscanmodestate
Scan_only_wifi_off_mode, the AP can only be scanned at Wifibutton shutdown and transferred to other States mscanmodestate
Receive a broadcast from the screen,
If a broadcast is received. Setsuspendoptimizations
Otherwise. Handling Screen Changes Handlescreenstatechanged
Set Power saving: Setpowersave
The ability to get peer ready to connect: wifistatemachine.cmd_enable_p2p
Send a broadcast to tell all people to start scanning: wifi_scan_available

ProcessMessage Stage:
The Messages processed are:
Cmd_start_scan:
Who initiated the scan: Notescanstart
Start Native Scan: Startscannative + wifinative.scan_with_connection_setup
Cmd_set_batched_scan:
Record Batch scan settings recordbatchedscansettings
Start Batch Scan Startbatchedscan
Cmd_set_country_code:
Set Country Code:setcountrycode
Cmd_set_frequency_band:
Set Band:setband
Flush Old data-like Scan Results:bssflush
Get the latest scan results when the band is set up: startscannative
Cmd_bluetooth_adapter_state_change:
Bluetooth Adapter Status change:
Set Bluetooth compatible scan mode: Setbluetoothcoexistencescanmode
Cmd_stop_driver:
Mwificonfigstore Disable all networks: Disableallnetworks
Send STOP DRIVER command: Cmd_delayed_stop_driver
Cmd_start_driver:
Agree to all networks: Enableallnetworks
Cmd_delayed_stop_driver:
Close Driver:stopdriver
Transfer to Mwaitforp2pdisablestate
Cmd_start_packet_filtering:
Startfilteringmulticastv6packets+ startfilteringmulticastv4packets
Cmd_stop_packet_filtering:
Stopfilteringmulticastv6packets+ stopfilteringmulticastv4packets
Cmd_set_suspend_opt_enabled:
Adjust Suspend:setsuspendoptimizationsnative (Suspend_due_to_screen, true) according to the screen switch;
Cmd_set_high_perf_mode:
Performance Tuning Suspend:setsuspendoptimizationsnative (Suspend_due_to_high_perf, false) based on user settings;
Cmd_enable_tdls:
Open Tdls:starttdls
Asus_event_del_pmkid:
Remove the SIM card at the same time clear PMK information:d Elpmkid

Exit phase:
Notify the battery: Updatebatteryworksource
Send a broadcast to tell all people to start scanning: wifi_scan_available


3.2.1 Mscanmodestate
ProcessMessage Stage:
The Messages processed are:
Cmd_set_operational_mode:
Cmd_start_scan:


3.2.2.3 Mdisconnectedstate
Enter stage:
Infer if a peer-to-peer connection is temporarily disconnected
Gets the framework scan interval time Mframeworkscanintervalms
Background scanning cancels the current regular scan, causing no scan results to be returned, so do not turn on background scanning when there is a regular scan waiting to run
There is currently no network saved, supplicant stop to get AP information periodic scan, but you need to open periodic scan periodically to notify user of the open network around

ProcessMessage Stage:
The Messages processed are:
Cmd_no_networks_periodic_scan:
This is a scan that needs to be switched on and off no matter what network is saved
Forget_network:
Cmd_remove_network:
No processing, this is a scan that does not have to be kept on a regular basis, no matter what network
Cmd_set_operational_mode:
The three operation states of the STA are performed according to the user settings:
Connect_mode. Ability to scan and connect to the AP and transfer to other States mdisconnectedstate
Scan_only_mode, can only scan the AP, transfer to other States 3.2.1 Mscanmodestate
Scan_only_wifi_off_mode, the AP can only be scanned at Wifibutton shutdown and transferred to other States mscanmodestate
Cmd_enable_background_scan:
Background Scan
Network_disconnection_event:
Supplicant_state_change_event:
Set Network details Status: setnetworkdetailedstate
Cmd_start_scan:
Background Scan
Scan_results_event:
Not_handled. Handed to parent for processing
P2p_connection_changed:
Dealing with changes in peer
Cmd_reconnect:
Cmd_reassociate:

Exit phase:
Enable background scanning


3.2.2.4 mwpsrunningstate
ProcessMessage Stage:
The Messages processed are:
Wps_success_event:
Network_connection_event:
Wps_overlap_event:
Wps_fail_event:
Wps_timeout_event:
Start_wps:
Cancel_wps:

Exit phase:


5. Msoftapstartingstate
Enter stage:
Message is CMD_START_AP, check if config is valid
Config is valid, send message cmd_set_ap_config to set config, then open softap:startsoftapwithconfig

ProcessMessage Stage:
The Messages processed are:
Exit phase:


6.2 Mtetheredstate
Enter stage:
Set a rtc_wakeup. For scheduled send msoftapidleintent
ProcessMessage Stage:
The Messages processed are:
Exit phase:

6.3 Muntetheringstate
Enter stage:
Send a timeout message after 5 seconds, close tethering
ProcessMessage Stage:
The Messages processed are:
Cmd_tether_state_change:
Cmd_tether_notification_timed_out:

Exit phase:


Wifistatemachine Study Notes

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.