WLAN无法自动打开问题分析

问题现象和背景

1.Wifi关闭

2. 设置->网络和互联网->WLAN->WLAN偏好设置->自动开启WLAN打开(前提要求打开位置信息中wlan随时扫描)

3. 预期结果:扫描到之前连接过的热点后,wifi会自动打开

   实际结果:wifi未能自动打开

原因分析:

WakeupController中注册ScanListener,监听并处理随时扫描上报的scan result,上报的扫描结果符合判定要求后,会enablewifi。

378     private void handleScanResults(Collection<ScanResult> scanResults) {
379          if (!isEnabledAndReady()) {
380              Log.d(TAG, "Attempted to handleScanResults while not enabled");
381              return;
382          }
383  
384          // only count scan as handled if isEnabledAndReady
385          mNumScansHandled++;
386          if (mVerboseLoggingEnabled) {
387              Log.d(TAG, "Incoming scan #" + mNumScansHandled);
388          }
389  
390          // need to show notification here in case user turns phone on while wifi is off
391          mWakeupOnboarding.maybeShowNotification();
392  
393          // filter out unknown networks
394          Set<ScanResultMatchInfo> goodNetworks = getGoodSavedNetworksAndSuggestions();
395          Set<ScanResultMatchInfo> matchInfos = toMatchInfos(scanResults);
396          matchInfos.retainAll(goodNetworks);
397  
398          mWakeupLock.update(matchInfos);
399          if (!mWakeupLock.isUnlocked()) {
400              return;
401          }
402  
403          ScanResult network = mWakeupEvaluator.findViableNetwork(scanResults, goodNetworks);
404  
405          if (network != null) {
406              Log.d(TAG, "Enabling wifi for network: " + network.SSID);
407              enableWifi();
408          }
409      }

之所以一直没有触发,是因为WakeupController中只是注册了scanlistener,并没有发起scan的动作,所以不会有scan result上报

调试发现,当上层有应用或者系统网络定位发起wifi scan请求后,芯片才会执行scan动作并上报,WakeupController接收扫描结果并判断,符合要求后在handleScanResults中enablewifi
 
复测方法
安装wifiservice apk,保证上层能成功发起scan动作后,可成功自动打开wifi
 
相关log:
07:32:46.591639  1085  7181 I WifiService: setWifiEnabled package=com.android.settings uid=1000 enable=false----关闭wlfi
07:37:21.682052  1085  1128 I WifiService: startScan uid=10136-----com.jhj.dev.wifi apk发起扫描
 07:37:21.685222  1085  1314 V WifiScanRequestProxy: Foreground scan app request [10136, com.jhj.dev.wifi]
 07:37:21.685321  1085  1314 I WifiScanRequestProxy: Scan request from com.jhj.dev.wifi throttled
 07:37:25.962909  1085  1314 D WakeupLock: Found network in lock: "iPhone"----此时扫描到之前连接过的热点,但是被lock住,未释放(有10mins的lock time,也就是距离上次连接10分钟内,不可自动打开)
 07:41:05.492517  1085  1314 D WakeupLock: Removed network from lock: "iPhone"-----此时到达unlock time
 07:43:05.719132  1085  1314 D WakeupController: Enabling wifi for network: iPhone----开始打开wifi
 07:43:07.930226  1085  1314 D SupplicantStaIfaceHal: connectToNetwork "iPhone"WPA_PSK----主动连接
 07:43:08.183816  1792 12387 D DhcpClient: Received packet: 66:b6:ef:9b:29:fa ACK: your new IP /172.20.10.2, netmask /255.255.255.240, gateways [/172.20.10.1] DNS servers: /172.20.10.1 , lease time 85536---获取dhcp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值