/** Link has poor connectivity. */ VERIFYING_POOR_LINK
但这个州的立场是什么?
搜索完整个项目后,我发现了这个:
WifiStateMachine.java中的子类VerifyingLinkState
class VerifyingLinkState extends State { @Override public void enter() { if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED,getName()); setNetworkDetailedState(DetailedState.VERIFYING_POOR_LINK); mWifiConfigStore.updateStatus(mLastNetworkId,DetailedState.VERIFYING_POOR_LINK); sendNetworkStateChangeBroadcast(mLastBssid); } @Override public boolean processMessage(Message message) { switch (message.what) { case WifiWatchdogStateMachine.POOR_LINK_DETECTED: //stay here break; case WifiWatchdogStateMachine.GOOD_LINK_DETECTED: try { mNwService.enableIpv6(mInterfaceName); } catch (RemoteException re) { loge("Failed to enable IPv6: " + re); } catch (IllegalStateException e) { loge("Failed to enable IPv6: " + e); } setNetworkDetailedState(DetailedState.CONNECTED); mWifiConfigStore.updateStatus(mLastNetworkId,DetailedState.CONNECTED); sendNetworkStateChangeBroadcast(mLastBssid); transitionTo(mConnectedState); break; default: return NOT_HANDLED; } return HANDLED; } }
在验证链接状态时,在enter()函数中,它将DetailedState设置为
DetailedState.VERIFYING_POOR_LINK
当连接真的很好时,这将导致用户对如下图所示的状态消息感到困惑.
虽然此消息只停留一段时间,然后迅速替换为“已连接”.但这个州的目标是什么?如果我没有在enter()函数中将DetailedState设置为VERIFYING_POOR_LINK,会有什么风险.
解决方法
WifiWatchdogStateMachine monitors the connection to a WiFi network. When WiFi
connects at L2 layer,the beacons from access point reach the device and it
can maintain a connection,but the application connectivity can be flaky (due
to bigger packet size exchange).We now monitor the quality of the last hop on WiFi using packet loss ratio as
an indicator to decide if the link is good enough to switch to Wi-Fi as the uplink.When WiFi is connected,the WiFi watchdog keeps sampling the RSSI and the
instant packet loss,and record it as per-AP loss-to-RSSi statistics. When
the instant packet loss is higher than a threshold,the WiFi watchdog sends a
poor link notification to avoid WiFi connection temporarily.While WiFi is being avoided,the WiFi watchdog keep watching the RSSI to
bring the WiFi connection back. Once the RSSI is high enough to achieve a
lower packet loss,a good link detection is sent such that the WiFi
connection become available again.BSSID roaming has been taken into account. When user is moving across
multiple APs,the WiFi watchdog will detect that and keep watching the
currently connected AP.Power impact should be minimal since much of the measurement relies on passive statistics already being tracked at the driver and the polling is done when screen is turned on and the RSSI is in a certain range.