打印的过滤:
logcat -s WifiMonitor wpa_supplicant WifiSettings WifiHW WifiConfigStore WifiStateMachine addOrUpdateNetworkNative WifiManager
1.frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiMonitor.java
public class WifiMonitor { private static class MonitorThread extends Thread { public void run() { //noinspection InfiniteLoopStatement for (;;) { String eventStr = mWifiNative.waitForEvent(); // Skip logging the common but mostly uninteresting scan-results event if (DBG && eventStr.indexOf(SCAN_RESULTS_STR) == -1) { Log.d(TAG, "Event [" + eventStr + "]"); } if (mWifiMonitorSingleton.dispatchEvent(eventStr)) { if (DBG) Log.d(TAG, "Disconnecting from the supplicant, no more events"); break; } } } } private boolean dispatchEvent(String eventStr, String iface) { handleSupplicantStateChange(eventData); } private void handleSupplicantStateChange(String dataString) { notifySupplicantStateChange(networkId, wifiSsid, BSSID, newSupplicantState); } void notifySupplicantStateChange(int networkId, WifiSsid wifiSsid, String BSSID, SupplicantState newState) { mStateMachine.sendMessage(mStateMachine.obtainMessage(SUPPLICANT_STATE_CHANGE_EVENT, eventLogCounter, 0, new StateChangeResult(networkId, wifiSsid, BSSID, newState))); } }2.frameworks/opt/net/wifi/service/java/com/android/server/wifi/SupplicantStateTracker.java
private void sendSupplicantStateChangedBroadcast(SupplicantState state, boolean failedAuth) { if (failedAuth) { intent.putExtra( WifiManager.EXTRA_SUPPLICANT_ERROR, WifiManager.ERROR_AUTHENTICATING); } mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); }通过广播通知应用程序。