wifi连接问题:密码正确但连接时supplicant state返回的是ERROR_AUTHENTICATING
frameworks\opt\net\wifi\service\java\com\android\server\wifi\wifistatemachine.java
frameworks\base\core\java\com\android\internal\util\statemachine.java
frameworks\base\core\java\com\android\internal\util\state.java
frameworks\opt\net\wifi\service\java\com\android\server\wifi\wifiservice.java
反正把frameworks导入source insight中就可以全部都搜得到了。
wifi hal(wifi抽象层)的在:
hardware\broadcom\wlan\bcmdhd\wifi_hal\wifi_hal.cpp
hardware\broadcom\wlan\bcmdhd\wifi_hal\wifi_logger.cpp
导入hardware\broadcom\wlan\bcmdhd\wifi_hal到source insight就可以很方便看wifi hal相关的代码了。
各个state的关系(wifistatemachine的构造方法,父类是statemachine):
addstate(mdefaultstate); addstate(minitialstate, mdefaultstate); addstate(msupplicantstartingstate, mdefaultstate); addstate(msupplicantstartedstate, mdefaultstate); addstate(mdriverstartingstate, msupplicantstartedstate); addstate(mdriverstartedstate, msupplicantstartedstate); addstate(mscanmodestate, mdriverstartedstate); addstate(mconnectmodestate, mdriverstartedstate); addstate(ml2connectedstate, mconnectmodestate); addstate(mobtainingipstate, ml2connectedstate); addstate(mverifyinglinkstate, ml2connectedstate); addstate(mconnectedstate, ml2connectedstate); addstate(mroamingstate, ml2connectedstate); addstate(mdisconnectingstate, mconnectmodestate); addstate(mdisconnectedstate, mconnectmodestate); addstate(mwpsrunningstate, mconnectmodestate); addstate(mwaitforp2pdisablestate, msupplicantstartedstate); addstate(mdriverstoppingstate, msupplicantstartedstate); addstate(mdriverstoppedstate, msupplicantstartedstate); addstate(msupplicantstoppingstate, mdefaultstate); addstate(msoftapstartingstate, mdefaultstate); addstate(msoftapstartedstate, mdefaultstate); addstate(mtetheringstate, msoftapstartedstate); addstate(mtetheredstate, msoftapstartedstate); addstate(muntetheringstate, msoftapstartedstate); setinitialstate(minitialstate);初始状态是initialstate,而initialstate的父状态是defaultstate。statemachine#addstate()
/** * add a new state to the state machine * @param state the state to add * @param parent the parent of state */ protected final void addstate(state state, state parent) { msmhandler.addstate(state, parent); }
wifistatemachine对消息的处理原则是,如果子状态处理不了,就给父状态处理,层层上报,直到defaultstate,如果defaultstate都处理不了就报error。消息由state的子类的processmessage(message msg)去处理,返回true表示处理了,false则表示给父状态处理。给出connectmodestate#processmessage的部分代码:
@override public boolean processmessage(message message) { wificonfiguration config; int netid; boolean ok; boolean diddisconnect; string bssid; string ssid; networkupdateresult result; logstateandmessage(message, getclass().getsimplename()); switch (message.what) { case wifimonitor.association_rejection_event: mwifilogger.capturebugreportdata(wifilogger.report_reason_assoc_failure); didblacklistbssid = false; bssid = (string) message.obj; if (bssid == null || textutils.isempty(bssid)) { // if bssid is null, use the target roam bssid bssid = mtargetroambssid; } if (bssid != null) { // if we have a bssid, tell configstore to black list it synchronized(mscanresultcache) { didblacklistbssid = mwificonfigstore.handlebssidblacklist (mlastnetworkid, bssid, false); } } msupplicantstatetracker.sendmessage(wifimonitor.association_rejection_event); break; case wifimonitor.authentication_failure_event: mwifilogger.capturebugreportdata(wifilogger.report_reason_auth_failure); msupplicantstatetracker.sendmessage(wifimonitor.authentication_failure_event); ///m:@{ if (mwififwkext != null) { mwififwkext.setnotificationvisible(true); } ///@} break; case wifimonitor.ssid_temp_disabled: case wifimonitor.ssid_reenabled: string substr = (string) message.obj; string en = message.what == wifimonitor.ssid_temp_disabled "temp-disabled" : "re-enabled"; logd("connectmodestate ssid state=" + en + " nid=" + integer.tostring(message.arg1) + " [" + substr + "]"); synchronized(mscanresultcache) { mwificonfigstore.handlessidstatechange(message.arg1, message.what == wifimonitor.ssid_reenabled, substr, mwifiinfo.getbssid()); } break; //... ... }
state的子类都在wifistatemachine.cpp中实现,是wifistatemachine的内部类,每个state子类都会在processmessage中调用logstateandmessage(message, getclass().getsimplename());,下面看logstateandmessage的源码:
private void logstateandmessage(message message, string state) { messagehandlingstatus = 0; if (mlogmessages) { //long now = systemclock.elapsedrealtimenanos(); //string ts = string.format("[%,d us]", now/1000); logd(" " + state + " " + getlogrecstring(message)); } }
看getlogrecstring的源码:
/** * return the additional string to be logged by logrec, default * * @param msg that was processed * @return information to be logged as a string */ protected string getlogrecstring(message msg) { wificonfiguration config; long now; string report; string key; stringbuilder sb = new stringbuilder(); ///m: add log @{ sb.append("(when="); timeutils.formatduration(msg.getwhen() - systemclock.uptimemillis() , sb); sb.append(" what="); sb.append(msg.what); if (msg.arg1 != 0) { sb.append(" arg1="); sb.append(msg.arg1); } if (msg.arg2 != 0) { sb.append(" arg2="); sb.append(msg.arg2); sb.append(") "); } ///@} if (mscreenon) { sb.append("!"); } if (messagehandlingstatus != message_handling_status_unknown) { sb.append("(").append(messagehandlingstatus).append(")"); } sb.append(smtostring(msg)); if (msg.sendinguid > 0 && msg.sendinguid != process.wifi_uid) { sb.append(" uid=" + msg.sendinguid); } sb.append(" ").append(printtime()); switch (msg.what) { case cmd_started_gscan_dbg: case cmd_started_pno_dbg: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (msg.obj != null) { sb.append(" " + (string)msg.obj); } break; case cmd_restart_autojoin_offload: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); sb.append("/").append(integer.tostring(mrestartautojoinoffloadcounter)); if (msg.obj != null) { sb.append(" " + (string)msg.obj); } break; case cmd_update_associated_scan_permission: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); sb.append(" halallowed=").append(usehalbasedautojoinoffload()); sb.append(" scanallowed=").append(allowfullbandscanandassociated()); sb.append(" autojoinallowed="); sb.append(mwificonfigstore.enableautojoinwhenassociated.get()); sb.append(" withtraffic=").append(getallowscanswithtraffic()); sb.append(" tx=").append(mwifiinfo.txsuccessrate); sb.append("/").append(mwificonfigstore.maxtxpacketforfullscans); sb.append(" rx=").append(mwifiinfo.rxsuccessrate); sb.append("/").append(mwificonfigstore.maxrxpacketforfullscans); sb.append(" -> ").append(mconnectedmodegscanoffloadstarted); break; case cmd_pno_network_found: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (msg.obj != null) { scanresult[] results = (scanresult[])msg.obj; for (int i = 0; i < results.length; i++) { sb.append(" ").append(results[i].ssid).append(" "); sb.append(results[i].frequency); sb.append(" ").append(results[i].level); } } break; case cmd_start_scan: now = system.currenttimemillis(); sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); sb.append(" ic="); sb.append(integer.tostring(sscanalarmintentcount)); if (msg.obj != null) { bundle bundle = (bundle) msg.obj; long request = bundle.getlong(scan_request_time, 0); if (request != 0) { sb.append(" proc(ms):").append(now - request); } } if (misscanongoing) sb.append(" ongoing"); if (misfullscanongoing) sb.append(" full"); if (laststartscantimestamp != 0) { sb.append(" started:").append(laststartscantimestamp); sb.append(",").append(now - laststartscantimestamp); } if (lastscanduration != 0) { sb.append(" dur:").append(lastscanduration); } sb.append(" cnt=").append(mdelayedscancounter); sb.append(" rssi=").append(mwifiinfo.getrssi()); sb.append(" f=").append(mwifiinfo.getfrequency()); sb.append(" sc=").append(mwifiinfo.score); sb.append(" link=").append(mwifiinfo.getlinkspeed()); sb.append(string.format(" tx=%.1f,", mwifiinfo.txsuccessrate)); sb.append(string.format(" %.1f,", mwifiinfo.txretriesrate)); sb.append(string.format(" %.1f ", mwifiinfo.txbadrate)); sb.append(string.format(" rx=%.1f", mwifiinfo.rxsuccessrate)); if (lastscanfreqs != null) { sb.append(" list=").append(lastscanfreqs); } else { sb.append(" fiv=").append(fullbandconnectedtimeintervalmilli); } report = reportontime(); if (report != null) { sb.append(" ").append(report); } break; case wifimonitor.supplicant_state_change_event: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); statechangeresult statechangeresult = (statechangeresult) msg.obj; if (statechangeresult != null) { sb.append(statechangeresult.tostring()); } break; case wifimanager.save_network: case wifistatemachine.cmd_auto_save_network: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (lastsavedconfigurationattempt != null) { sb.append(" ").append(lastsavedconfigurationattempt.configkey()); sb.append(" nid=").append(lastsavedconfigurationattempt.networkid); if (lastsavedconfigurationattempt.hiddenssid) { sb.append(" hidden"); } if (lastsavedconfigurationattempt.presharedkey != null && !lastsavedconfigurationattempt.presharedkey.equals("*")) { sb.append(" haspsk"); } if (lastsavedconfigurationattempt.ephemeral) { sb.append(" ephemeral"); } if (lastsavedconfigurationattempt.selfadded) { sb.append(" selfadded"); } sb.append(" cuid=").append(lastsavedconfigurationattempt.creatoruid); sb.append(" suid=").append(lastsavedconfigurationattempt.lastupdateuid); } break; case wifimanager.forget_network: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (lastforgetconfigurationattempt != null) { sb.append(" ").append(lastforgetconfigurationattempt.configkey()); sb.append(" nid=").append(lastforgetconfigurationattempt.networkid); if (lastforgetconfigurationattempt.hiddenssid) { sb.append(" hidden"); } if (lastforgetconfigurationattempt.presharedkey != null) { sb.append(" haspsk"); } if (lastforgetconfigurationattempt.ephemeral) { sb.append(" ephemeral"); } if (lastforgetconfigurationattempt.selfadded) { sb.append(" selfadded"); } sb.append(" cuid=").append(lastforgetconfigurationattempt.creatoruid); sb.append(" suid=").append(lastforgetconfigurationattempt.lastupdateuid); sb.append(" ajst=").append(lastforgetconfigurationattempt.autojoinstatus); } break; case wifimonitor.association_rejection_event: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); string bssid = (string) msg.obj; if (bssid != null && bssid.length() > 0) { sb.append(" "); sb.append(bssid); } sb.append(" blacklist=" + boolean.tostring(didblacklistbssid)); break; case wifimonitor.scan_results_event: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (mscanresults != null) { sb.append(" found="); sb.append(mscanresults.size()); } sb.append(" known=").append(mnumscanresultsknown); sb.append(" got=").append(mnumscanresultsreturned); if (lastscanduration != 0) { sb.append(" dur:").append(lastscanduration); } if (montime != 0) { sb.append(" on:").append(montimethisscan).append(",").append(montimescan); sb.append(",").append(montime); } if (mtxtime != 0) { sb.append(" tx:").append(mtxtimethisscan).append(",").append(mtxtimescan); sb.append(",").append(mtxtime); } if (mrxtime != 0) { sb.append(" rx:").append(mrxtimethisscan).append(",").append(mrxtimescan); sb.append(",").append(mrxtime); } sb.append(string.format(" bcn=%d", mrunningbeaconcount)); sb.append(string.format(" con=%d", mconnectionrequests)); key = mwificonfigstore.getlastselectedconfiguration(); if (key != null) { sb.append(" last=").append(key); } break; case wifimonitor.scan_failed_event: break; case wifimonitor.network_connection_event: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); sb.append(" ").append(mlastbssid); sb.append(" nid=").append(mlastnetworkid); config = getcurrentwificonfiguration(); if (config != null) { sb.append(" ").append(config.configkey()); } key = mwificonfigstore.getlastselectedconfiguration(); if (key != null) { sb.append(" last=").append(key); } break; case cmd_target_bssid: case cmd_associated_bssid: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (msg.obj != null) { sb.append(" bssid=").append((string) msg.obj); } if (mtargetroambssid != null) { sb.append(" target=").append(mtargetroambssid); } sb.append(" roam=").append(integer.tostring(mautoroaming)); break; case wifimonitor.network_disconnection_event: if (msg.obj != null) { sb.append(" ").append((string) msg.obj); } sb.append(" nid=").append(msg.arg1); sb.append(" reason=").append(msg.arg2); if (mlastbssid != null) { sb.append(" lastbssid=").append(mlastbssid); } if (mwifiinfo.getfrequency() != -1) { sb.append(" freq=").append(mwifiinfo.getfrequency()); sb.append(" rssi=").append(mwifiinfo.getrssi()); } if (linkdebouncing) { sb.append(" debounce"); } break; case wifimonitor.ssid_temp_disabled: case wifimonitor.ssid_reenabled: sb.append(" nid=").append(msg.arg1); if (msg.obj != null) { sb.append(" ").append((string) msg.obj); } config = getcurrentwificonfiguration(); if (config != null) { sb.append(" cur=").append(config.configkey()); sb.append(" ajst=").append(config.autojoinstatus); if (config.selfadded) { sb.append(" selfadded"); } if (config.status != 0) { sb.append(" st=").append(config.status); sb.append(" rs=").append(config.disablereason); } if (config.lastconnected != 0) { now = system.currenttimemillis(); sb.append(" lastconn=").append(now - config.lastconnected).append("(ms)"); } if (mlastbssid != null) { sb.append(" lastbssid=").append(mlastbssid); } if (mwifiinfo.getfrequency() != -1) { sb.append(" freq=").append(mwifiinfo.getfrequency()); sb.append(" rssi=").append(mwifiinfo.getrssi()); sb.append(" bssid=").append(mwifiinfo.getbssid()); } } break; case cmd_rssi_poll: case cmd_unwanted_network: case wifimanager.rssi_pktcnt_fetch: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (mwifiinfo.getssid() != null) if (mwifiinfo.getssid() != null) sb.append(" ").append(mwifiinfo.getssid()); if (mwifiinfo.getbssid() != null) sb.append(" ").append(mwifiinfo.getbssid()); sb.append(" rssi=").append(mwifiinfo.getrssi()); sb.append(" f=").append(mwifiinfo.getfrequency()); sb.append(" sc=").append(mwifiinfo.score); sb.append(" link=").append(mwifiinfo.getlinkspeed()); sb.append(string.format(" tx=%.1f,", mwifiinfo.txsuccessrate)); sb.append(string.format(" %.1f,", mwifiinfo.txretriesrate)); sb.append(string.format(" %.1f ", mwifiinfo.txbadrate)); sb.append(string.format(" rx=%.1f", mwifiinfo.rxsuccessrate)); sb.append(string.format(" bcn=%d", mrunningbeaconcount)); report = reportontime(); if (report != null) { sb.append(" ").append(report); } if (wifiscoringreport != null) { sb.append(wifiscoringreport); } if (mconnectedmodegscanoffloadstarted) { sb.append(" offload-started periodmilli " + mgscanperiodmilli); } else { sb.append(" offload-stopped"); } break; case cmd_auto_connect: case wifimanager.connect_network: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); config = (wificonfiguration) msg.obj; if (config != null) { sb.append(" ").append(config.configkey()); if (config.visibility != null) { sb.append(" ").append(config.visibility.tostring()); } } if (mtargetroambssid != null) { sb.append(" ").append(mtargetroambssid); } sb.append(" roam=").append(integer.tostring(mautoroaming)); config = getcurrentwificonfiguration(); if (config != null) { sb.append(config.configkey()); if (config.visibility != null) { sb.append(" ").append(config.visibility.tostring()); } } break; case cmd_auto_roam: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); scanresult result = (scanresult) msg.obj; if (result != null) { now = system.currenttimemillis(); sb.append(" bssid=").append(result.bssid); sb.append(" rssi=").append(result.level); sb.append(" freq=").append(result.frequency); if (result.seen > 0 && result.seen < now) { sb.append(" seen=").append(now - result.seen); } else { // somehow the timestamp for this scan result is inconsistent sb.append(" !seen=").append(result.seen); } } if (mtargetroambssid != null) { sb.append(" ").append(mtargetroambssid); } sb.append(" roam=").append(integer.tostring(mautoroaming)); sb.append(" fail count=").append(integer.tostring(mroamfailcount)); break; case cmd_add_or_update_network: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (msg.obj != null) { config = (wificonfiguration) msg.obj; sb.append(" ").append(config.configkey()); sb.append(" prio=").append(config.priority); sb.append(" status=").append(config.status); if (config.bssid != null) { sb.append(" ").append(config.bssid); } wificonfiguration curconfig = getcurrentwificonfiguration(); if (curconfig != null) { if (curconfig.configkey().equals(config.configkey())) { sb.append(" is current"); } else { sb.append(" current=").append(curconfig.configkey()); sb.append(" prio=").append(curconfig.priority); sb.append(" status=").append(curconfig.status); } } } break; case wifimanager.disable_network: case cmd_enable_network: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); key = mwificonfigstore.getlastselectedconfiguration(); if (key != null) { sb.append(" last=").append(key); } config = mwificonfigstore.getwificonfiguration(msg.arg1); if (config != null && (key == null || !config.configkey().equals(key))) { sb.append(" target=").append(key); } break; case cmd_get_configured_networks: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); sb.append(" num=").append(mwificonfigstore.getconfigurednetworkssize()); break; case dhcpstatemachine.cmd_pre_dhcp_action: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); sb.append(" txpkts=").append(mwifiinfo.txsuccess); sb.append(",").append(mwifiinfo.txbad); sb.append(",").append(mwifiinfo.txretries); break; case dhcpstatemachine.cmd_post_dhcp_action: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (msg.arg1 == dhcpstatemachine.dhcp_success) { sb.append(" ok "); } else if (msg.arg1 == dhcpstatemachine.dhcp_failure) { sb.append(" fail "); } if (mlinkproperties != null) { if (mlinkproperties.hasipv4address()) { sb.append(" v4"); } if (mlinkproperties.hasglobalipv6address()) { sb.append(" v6"); } if (mlinkproperties.hasipv4defaultroute()) { sb.append(" v4r"); } if (mlinkproperties.hasipv6defaultroute()) { sb.append(" v6r"); } if (mlinkproperties.hasipv4dnsserver()) { sb.append(" v4dns"); } if (mlinkproperties.hasipv6dnsserver()) { sb.append(" v6dns"); } } break; case wifip2pserviceimpl.p2p_connection_changed: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (msg.obj != null) { networkinfo info = (networkinfo) msg.obj; networkinfo.state state = info.getstate(); networkinfo.detailedstate detailedstate = info.getdetailedstate(); if (state != null) { sb.append(" st=").append(state); } if (detailedstate != null) { sb.append("/").append(detailedstate); } } break; case cmd_ip_configuration_lost: int count = -1; wificonfiguration c = getcurrentwificonfiguration(); if (c != null) count = c.numipconfigfailures; sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); sb.append(" failures: "); sb.append(integer.tostring(count)); sb.append("/"); sb.append(integer.tostring(mwificonfigstore.getmaxdhcpretries())); if (mwifiinfo.getbssid() != null) { sb.append(" ").append(mwifiinfo.getbssid()); } if (c != null) { scandetailcache scandetailcache = mwificonfigstore.getscandetailcache(c); if (scandetailcache != null) { for (scandetail sd : scandetailcache.values()) { scanresult r = sd.getscanresult(); if (r.bssid.equals(mwifiinfo.getbssid())) { sb.append(" ipfail=").append(r.numipconfigfailures); sb.append(",st=").append(r.autojoinstatus); } } } sb.append(" -> ajst=").append(c.autojoinstatus); sb.append(" ").append(c.disablereason); sb.append(" txpkts=").append(mwifiinfo.txsuccess); sb.append(",").append(mwifiinfo.txbad); sb.append(",").append(mwifiinfo.txretries); } sb.append(string.format(" bcn=%d", mrunningbeaconcount)); break; case cmd_update_linkproperties: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (mlinkproperties != null) { if (mlinkproperties.hasipv4address()) { sb.append(" v4"); } if (mlinkproperties.hasglobalipv6address()) { sb.append(" v6"); } if (mlinkproperties.hasipv4defaultroute()) { sb.append(" v4r"); } if (mlinkproperties.hasipv6defaultroute()) { sb.append(" v6r"); } if (mlinkproperties.hasipv4dnsserver()) { sb.append(" v4dns"); } if (mlinkproperties.hasipv6dnsserver()) { sb.append(" v6dns"); } } break; case cmd_ip_reachability_lost: if (msg.obj != null) { sb.append(" ").append((string) msg.obj); } break; case cmd_set_country_code: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); if (msg.obj != null) { sb.append(" ").append((string) msg.obj); } break; case cmd_roam_watchdog_timer: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); sb.append(" cur=").append(roamwatchdogcount); break; case cmd_disconnecting_watchdog_timer: sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); sb.append(" cur=").append(disconnectingwatchdogcount); break; case cmd_start_rssi_monitoring_offload: case cmd_stop_rssi_monitoring_offload: case cmd_rssi_threshold_breach: sb.append(" rssi="); sb.append(integer.tostring(msg.arg1)); sb.append(" thresholds="); sb.append(arrays.tostring(mrssiranges)); break; default: ///m: add log @{ sb.append(msg.tostring()); ///@} sb.append(" "); sb.append(integer.tostring(msg.arg1)); sb.append(" "); sb.append(integer.tostring(msg.arg2)); break; } return sb.tostring(); }
首先看时间点附近的log,看mainlog。
搜索wifistatemachine,结果如下:
line 97197: 06-05 10:02:22.841257650767 i wifistatemachine: fetchrssilinkspeedandfrequencynative, newrssi:-30, newlinkspeed:135, ssid:"tp-50" line 97198: 06-05 10:02:22.841299650767 d wifistatemachine: mlastsignallevel:4, newsignallevel:4 line 97201: 06-05 10:02:22.845437650767 d wifistatemachine: obtainingipstate (when=0 what=131249!m_cmd_update_rssi uid=10047 rt=2746647/2746647{ when=0 what=131249 target=com.android.internal.util.statemachine$smhandler } 0 0 line 97202: 06-05 10:02:22.845763650767 d wifistatemachine: l2connectedstate (when=-1ms what=131249!m_cmd_update_rssi uid=10047 rt=2746648/2746648{ when=-1ms what=131249 target=com.android.internal.util.statemachine$smhandler } 0 0 line 97203: 06-05 10:02:22.848220650767 d wifistatemachine: connectmodestate (when=-3ms what=131249!m_cmd_update_rssi uid=10047 rt=2746650/2746650{ when=-3ms what=131249 target=com.android.internal.util.statemachine$smhandler } 0 0 line 97204: 06-05 10:02:22.856197650767 d wifistatemachine: driverstartedstate (when=-11ms what=131249!m_cmd_update_rssi uid=10047 rt=2746658/2746658{ when=-11ms what=131249 target=com.android.internal.util.statemachine$smhandler } 0 0 line 97205: 06-05 10:02:22.856494650767 d wifistatemachine: supplicantstartedstate (when=-11ms what=131249!m_cmd_update_rssi uid=10047 rt=2746658/2746658{ when=-11ms what=131249 target=com.android.internal.util.statemachine$smhandler } 0 0 line 97215: 06-05 10:02:22.864223650767 i wifistatemachine: fetchrssinative, newrssi:-30 line 97563: 06-05 10:02:23.902084650767 d wifistatemachine: obtainingipstate (when=-2ms what=196613 arg1=2 arg2=2) !cmd_post_dhcp_action rt=2747704/2747704 2 2 fail line 97564: 06-05 10:02:23.902509650767 d wifistatemachine: l2connectedstate (when=-2ms what=196613 arg1=2 arg2=2) !cmd_post_dhcp_action rt=2747704/2747704 2 2 fail line 97565: 06-05 10:02:23.902550650767 d wifistatemachine: cmd_post_dhcp_action for:2, mdhcpv4status:0, mdhcpv6status:2 line 97566: 06-05 10:02:23.903208650767 d wifistatemachine: setsuspendoptimizationsnative: 1 true -want true stack:setsuspendoptimizationsnative - handlepostdhcpsetup - processmessage - processmsg line 97649: 06-05 10:02:23.922255650767 d wifistatemachine: obtainingipstate (when=-11ms what=147463 arg1=2489!authentication_failure_event rt=2747724/2747724{ when=-11ms what=147463 arg1=2489 target=com.android.internal.util.statemachine$smhandler } 2489 0 line 97670: 06-05 10:02:23.922952650767 d wifistatemachine: l2connectedstate (when=-12ms what=147463 arg1=2489!authentication_failure_event rt=2747725/2747725{ when=-12ms what=147463 arg1=2489 target=com.android.internal.util.statemachine$smhandler } 2489 0 line 97671: 06-05 10:02:23.923348650767 d wifistatemachine: connectmodestate (when=-12ms what=147463 arg1=2489!authentication_failure_event rt=2747725/2747725{ when=-12ms what=147463 arg1=2489 target=com.android.internal.util.statemachine$smhandler } 2489 0 line 97676: 06-05 10:02:23.924092650767 d wifistatemachine: obtainingipstate (when=-12ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747726/2747726{ when=-12ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 line 97677: 06-05 10:02:23.924443650767 d wifistatemachine: l2connectedstate (when=-12ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747726/2747726{ when=-12ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 line 97678: 06-05 10:02:23.926002650767 d wifistatemachine: connectmodestate (when=-14ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747728/2747728{ when=-14ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 line 97679: 06-05 10:02:23.926376650767 d wifistatemachine: driverstartedstate (when=-14ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747728/2747728{ when=-14ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 line 97680: 06-05 10:02:23.926725650767 d wifistatemachine: supplicantstartedstate (when=-15ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747729/2747729{ when=-15ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 line 97683: 06-05 10:02:23.929685650767 d wifistatemachine: defaultstate (when=-17ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747731/2747731{ when=-17ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 line 97684: 06-05 10:02:23.929733650767 e wifistatemachine: error! unhandled message{ when=-18ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 }
最明显的是wifistatemachine: error! unhandled message{ when=-18ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 }。但是并不是这个导致的。这个报的是wpas发过来的消息没有state处理,就是一直上报到defaultstate还是不能处理,就会报这个error!
直接显示错误的log是:
obtainingipstate (when=-11ms what=147463 arg1=2489!authentication_failure_event rt=2747724/2747724{ when=-11ms what=147463 arg1=2489 target=com.android.internal.util.statemachine$smhandler } 2489 0 line 97670: 06-05 10:02:23.922952650767 d wifistatemachine: l2connectedstate (when=-12ms what=147463 arg1=2489!authentication_failure_event rt=2747725/2747725{ when=-12ms what=147463 arg1=2489 target=com.android.internal.util.statemachine$smhandler } 2489 0 line 97671: 06-05 10:02:23.923348650767 d wifistatemachine: connectmodestate (when=-12ms what=147463 arg1=2489!authentication_failure_event rt=2747725/2747725{ when=-12ms what=147463 arg1=2489 target=com.android.internal.util.statemachine$smhandler } 2489 0
可以看出来,这个错误的消息没有一直上报,而是最终connectmodestate处理了。
结合整个log一起看,就是结合wifihw,wifi_hal,wpa_supplicant一起看:
#在此开始连接 06-05 10:02:23.913477650 10218 d wifihw : [1] get event: ifname=wlan0 <3>ctrl-event-state-change id=8 state=0 bssid=8c:a6:df:e8:f2:08 ssid=tp-50 06-05 10:02:23.913492650 10218 d wifihw : [2] get event: ifname=wlan0 ctrl-event-state-change id=8 state=0 bssid=8c:a6:df:e8:f2:08 ssid=tp-50 06-05 10:02:23.913562650 10218 d wifimonitor: event [ifname=wlan0 ctrl-event-state-change id=8 state=0 bssid=8c:a6:df:e8:f2:08 ssid=tp-50] 06-05 10:02:23.913897650 10218 d wifihw : enter -->wifi_wait_on_socket buflen=2048 06-05 10:02:23.914498650767 d wifihal : start memory dump command 06-05 10:02:23.914536650767 d wifihal : wifirequest::create vendor command to iface 13, vendor_id=0x1a11, subcmd=0x1401, res=0 06-05 10:02:23.920562 10210 10210 d wpa_supplicant: rtm_newlink: ifi_index=13 ifname=wlan0 wext ifi_family=0 ifi_flags=0x11003 ([up][lower_up]) 06-05 10:02:23.921482650767 d wifihal : wificommand::requestresponse err=-95 06-05 10:02:23.921571650767 e wifihal : failed to register trigger memory dump response; result = -95 #在此开始就认证报错了,估计是获取ip失败,直接原因貌似是上面的failed to register trigger memory dump response造成的。 06-05 10:02:23.922255650767 d wifistatemachine: obtainingipstate (when=-11ms what=147463 arg1=2489!authentication_failure_event rt=2747724/2747724{ when=-11ms what=147463 arg1=2489 target=com.android.internal.util.statemachine$smhandler } 2489 0 06-05 10:02:23.922422 10210 10210 d wpa_supplicant: rtm_newlink: ifi_index=13 ifname=wlan0 operstate=2 linkmode=1 ifi_family=0 ifi_flags=0x1003 ([up]) 06-05 10:02:23.922485 10210 10210 d wpa_supplicant: nl80211: event message available 06-05 10:02:23.922534 10210 10210 d wpa_supplicant: nl80211: ignored event (cmd=48) for foreign interface (ifindex 13 wdev 0x0) 06-05 10:02:23.922553 10210 10210 d wpa_supplicant: nl80211: drv event 48 (nl80211_cmd_disconnect) received for wlan0 06-05 10:02:23.922574 10210 10210 w wpa_supplicant: nl80211: was expecting local disconnect but got another disconnect event first 06-05 10:02:23.922585 10210 10210 d wpa_supplicant: nl80211: disconnect event 06-05 10:02:23.922610 10210 10210 d wpa_supplicant: wlan0: event deauth (12) received 06-05 10:02:23.922647 10210 10210 d wpa_supplicant: wlan0: deauthentication notification 06-05 10:02:23.922668 10210 10210 d wpa_supplicant: wlan0: * reason 0 06-05 10:02:23.922686 10210 10210 d wpa_supplicant: deauthentication frame ie(s) - hexdump(len=0): [null] 06-05 10:02:23.922715 10210 10210 d wpa_supplicant: wlan0: auto connect disabled: do not try to re-connect 06-05 10:02:23.922735 10210 10210 d wpa_supplicant: tdls: remove peers on disassociation 06-05 10:02:23.922755 10210 10210 d wpa_supplicant: wlan0: wpa: clear old pmk and ptk 06-05 10:02:23.922781 10210 10210 d wpa_supplicant: wlan0: disconnect event - remove keys 06-05 10:02:23.922804 10210 10210 d wpa_supplicant: wlan0: state: disconnected -> disconnected 06-05 10:02:23.922821 10210 10210 d wpa_supplicant: p2p: restorage p2p channels 06-05 10:02:23.922838 10210 10210 d wpa_supplicant: nl80211: set wlan0 operstate 0->0 (dormant) 06-05 10:02:23.922860 10210 10210 d wpa_supplicant: netlink: operstate: ifindex=13 linkmode=-1 (no change), operstate=5 (if_oper_dormant) 06-05 10:02:23.922906 10210 10210 d wpa_supplicant: eapol: external notification - portenabled=0 06-05 10:02:23.922927 10210 10210 d wpa_supplicant: eapol: external notification - portvalid=0 06-05 10:02:23.922952650767 d wifistatemachine: l2connectedstate (when=-12ms what=147463 arg1=2489!authentication_failure_event rt=2747725/2747725{ when=-12ms what=147463 arg1=2489 target=com.android.internal.util.statemachine$smhandler } 2489 0 06-05 10:02:23.923348650767 d wifistatemachine: connectmodestate (when=-12ms what=147463 arg1=2489!authentication_failure_event rt=2747725/2747725{ when=-12ms what=147463 arg1=2489 target=com.android.internal.util.statemachine$smhandler } 2489 0 06-05 10:02:23.923474650767 d wifihal : start memory dump command 06-05 10:02:23.923513650767 d wifihal : wifirequest::create vendor command to iface 13, vendor_id=0x1a11, subcmd=0x1401, res=0 06-05 10:02:23.923587650767 d wifihal : wificommand::requestresponse err=-95 06-05 10:02:23.923608650767 e wifihal : failed to register trigger memory dump response; result = -95 06-05 10:02:23.924092650767 d wifistatemachine: obtainingipstate (when=-12ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747726/2747726{ when=-12ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 06-05 10:02:23.924443650767 d wifistatemachine: l2connectedstate (when=-12ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747726/2747726{ when=-12ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 06-05 10:02:23.926002650767 d wifistatemachine: connectmodestate (when=-14ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747728/2747728{ when=-14ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 06-05 10:02:23.926376650767 d wifistatemachine: driverstartedstate (when=-14ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747728/2747728{ when=-14ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 06-05 10:02:23.926725650767 d wifistatemachine: supplicantstartedstate (when=-15ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747729/2747729{ when=-15ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 06-05 10:02:23.926863650 10414 d dhcpclient: dhcpinitstate 0 cmd_kick 0 0 null 06-05 10:02:23.927038650 10414 d dhcpclient: broadcasting dhcpdiscover 06-05 10:02:23.929685650767 d wifistatemachine: defaultstate (when=-17ms what=147496 arg1=-1!p2p_peer_disconnect_event rt=2747731/2747731{ when=-17ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 } -1 0 06-05 10:02:23.929733650767 e wifistatemachine: error! unhandled message{ when=-18ms what=147496 arg1=-1 obj=3 target=com.android.internal.util.statemachine$smhandler obj=3 }
貌似是在wifi_logger.cpp#start() -> cpp_bindings.cpp wifirequest#create(uint32_t id, int subcmd)中出错了。就是写命令google_oui和logger_trigger_mem_dump到nl80211_attr_vendor_id和nl80211_attr_vendor_subcmd时出错了。
int wifirequest::create(uint32_t id, int subcmd) { int res = create(nl80211_cmd_vendor); if (res < 0) { return res; } res = put_u32(nl80211_attr_vendor_id, id); if (res < 0) { return res; } res = put_u32(nl80211_attr_vendor_subcmd, subcmd); if (res < 0) { return res; } if (miface != -1) { res = set_iface_id(miface); } return res; }
上一篇: Android 实现手绘功能教程
下一篇: meta标签