Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92

概念:
PNO 即Preferred Network Offload,用于系统在休眠的时候连接WiFi
此功能是在Android3.1加入的

缺陷:
在使用PNO时,有潜在泄露个人隐私的风险。这里没明白,意思是说PNO会发送之前的连接过的网络给AP,然后hacker截取?

代码:
当屏幕状态有变化的时候,会调用handleScreenStateChanged(),如果pno功能有enable,就会配置pno,然后再scan.

private void handleScreenStateChanged(boolean screenOn)
{//亮屏的情况if (screenOn) {enableBackgroundScan(false);setScanAlarm(false);clearBlacklist();fullBandConnectedTimeIntervalMilli= mWifiConfigStore.wifiAssociatedShortScanIntervalMilli.get();// In either Disconnectedstate or ConnectedState,// start the scan alarm so as to enable autojoin//如果当前是连接着的if (getCurrentState() == mConnectedState&& allowFullBandScanAndAssociated()) {//PNO功能是否开启了if (useHalBasedAutoJoinOffload()) {//使用PNO来扫描startGScanConnectedModeOffload("screenOnConnected");} else {// Scan after 500msstartDelayedScan(500, null, null);}} else if (getCurrentState() == mDisconnectedState) {if (useHalBasedAutoJoinOffload()) {//调用未连接的PNO扫描startGScanDisconnectedModeOffload("screenOnDisconnected");} else {// Scan after 500msstartDelayedScan(500, null, null);}}//关屏休眠时} else {//当处于未连接状态时if (getCurrentState() == mDisconnectedState) {// Screen Off and Disconnected and chipset doesn't support scan offload//              => start scan alarm// Screen Off and Disconnected and chipset does support scan offload//              => will use scan offload (i.e. background scan)//如果不支持PNO,那么就用alarm做定期扫描if (useHalBasedAutoJoinOffload()) {startGScanDisconnectedModeOffload("screenOffDisconnected");} else {if (!mBackgroundScanSupported) {setScanAlarm(true);} else {if (!mIsScanOngoing) {enableBackgroundScan(true);}}}} else {enableBackgroundScan(false);if (useHalBasedAutoJoinOffload()) {// don't try stop Gscan if it is not enabledstopGScan("ScreenOffStop(enableBackground=" + mLegacyPnoEnabled + ") ");}}}
}
private boolean startGScanConnectedModeOffload(String reason)
{if (!useHalBasedAutoJoinOffload()) return false;//获取pno列表List<WifiNative.WifiPnoNetwork> llist= mWifiAutoJoinController.getPnoList(getCurrentWifiConfiguration());// first program the network we want to look for thru the pno APIWifiNative.WifiPnoNetwork list[]= (WifiNative.WifiPnoNetwork[]) llist.toArray(new WifiNative.WifiPnoNetwork[0]);//设置pnoif (!WifiNative.setPnoList(list, WifiStateMachine.this)) {Log.e(TAG, "Failed to set pno, length = " + list.length);return false;}
}

pno list的创建在buildPnoList():

private void buildPnoList() {mCachedPnoList = new ArrayList<WifiNative.WifiPnoNetwork>();ArrayList<WifiConfiguration> sortedWifiConfigurations= new ArrayList<WifiConfiguration>(getConfiguredNetworks());Log.e(TAG, "buildPnoList sortedWifiConfigurations size " + sortedWifiConfigurations.size());if (sortedWifiConfigurations.size() != 0) {// Sort by descending priorityCollections.sort(sortedWifiConfigurations, new Comparator<WifiConfiguration>() {public int compare(WifiConfiguration a, WifiConfiguration b) {return a.priority - b.priority;}});}for (WifiConfiguration config : sortedWifiConfigurations) {// Initialize the RSSI threshold with sane value:// Use the 2.4GHz threshold since most WifiConfigurations are dual bands// There is very little penalty with triggering too soon, i.e. if PNO finds a network// that has an RSSI too low for us to attempt joining it.int threshold = thresholdInitialAutoJoinAttemptMin24RSSI.get();Log.e(TAG, "found sortedWifiConfigurations : " + config.configKey());WifiNative.WifiPnoNetwork network = mWifiNative.new WifiPnoNetwork(config, threshold);mCachedPnoList.add(network);}
}

是否使用pno依赖于如下三个变量判断
1. Settings里有没有打开
2. 驱动是否支持
3. HAL层是否打开

boolean useHalBasedAutoJoinOffload() {// all three settings need to be true:// - developper settings switch// - driver support// - config optionreturn mHalBasedPnoEnableInDevSettings&& mHalBasedPnoDriverSupported&& mWifiConfigStore.enableHalBasedPno.get();
}

rk3288默认是关闭的,可以从log中直接看到:
WifiStateMachine: Enter ConnectedState mScreenOn=true scanperiod=20000 useGscan=false/false mHalBasedPnoEnableInDevSettings false

参考:
How to Lock Down Your Android Wi-Fi Settings to Improve Privacy
Honeycomb MR1
Android bug leaks your location via WiFi

[RK3288][Android6.0] WiFi之PNO功能了解相关推荐

  1. android开启热点softap模式,[RK3288][Android6.0] Wifi开启热点(SoftAP)流程小结

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 在Settings中选择要打开wifi热点功能: 调用流程如下: onPreferenceChan ...

  2. [RK3288][Android6.0] WiFi的dts配置说明(AP6335)

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 原理图 配置文件 参考 使用的是AP6335, 硬件上用的是SDIO0. 原理图: 配置文件: 电 ...

  3. android6.0 wifi流程,[RK3288][Android6.0] WiFi之从Linkspeed看获取流程

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 WiFi的(Link speed)连接速度可以从Settings里查看 从连接速度来看下获取WiF ...

  4. android删除wifi配置,[RK3288][Android6.0] WiFi之无线网络配置的忘记(移除)过程

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 ,这里看一下它的移除过程是怎样的,当选择界面的FORGET时,会触发以下流程调用. onForge ...

  5. [RK3288][Android6.0] WiFi之cfg80211知识点小结

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 概念: cfg80211是Linux 802.11用于管理配置的一套API,它是用户和驱动之间的桥 ...

  6. [RK3288][Android6.0] WiFi之NetworkFactory形成的评分机制

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 NetworkFactory作为网络评分机制中一个重要角色而存在,每个模块实现需要继承Networ ...

  7. [RK3288][Android6.0] WiFi之NetworkAgent对评分的更新

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 上一篇看了NetworkFactory的使用过程,它是在系统初始化时就被创建,接下来在接入网络时N ...

  8. [RK3288][Android6.0] WiFi之wpa_supplicant扫描过程

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 wpa_supplicant_req_scan -> wpa_supplicant_scan ...

  9. [RK3288][Android6.0] WiFi之开机自动连接过程

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 当上一次有连接过wifi,下次开机默认wifi有打开的情况下,系统会自动连接上最佳的无线网络. 手 ...

最新文章

  1. 两个asp.net发送邮件类
  2. VS2010数据库项目不能正常工作解决方案
  3. Entity Framework 6 Recipes 2nd Edition(10-6)译 - TPT继承模型中使用存储过程
  4. base64编码 vba_VB VBA ASP 可通用的基于Base64进行加密和解密的函数
  5. mysql 目录武沛齐_MySQL数据表中的数据操作
  6. linux设置逻辑卷进不了图形界面,LVM逻辑卷管理器图形界面操作
  7. Delphi的StringReplace[转]
  8. docker安装php怎么修改配置,怎么给docker配置内存大小?
  9. vscode怎么写qt项目_使用VSCode 编译调试QT程序
  10. Memcached、MongoDB、Redis和tokyotyrant
  11. python查看大文件的最后一行
  12. ps4手柄驱动linux,GeForce 344.11正式版驱动:支持GTX 980/970,集成DSR选项
  13. [爬虫系列(三)]用多线程爬取百度贴吧默认表情
  14. 智联招聘 'python数据分析'职位分析第一篇
  15. 应用场景:征信和权属管理
  16. Matlab exercise04
  17. Java7技术系列:DI依赖注入
  18. 麦肯锡三部曲_人际连接三部曲
  19. 虚拟机挂载ubuntu,启动卡在开机界面,只有左上角显示横杠
  20. 史上最强七种防蚊药水大比拼!看完你都震惊了!

热门文章

  1. 【漫步计算机系统】:发展概览Ⅲ
  2. Java计算时间差、日期差总结
  3. 2015 Syrian Private Universities Collegiate Programming Contest
  4. Silverlight教程第五部分:用 ListBox 和 DataBinding 显示列表数据 (木野狐译)
  5. 搜狗输入法自动打开问题
  6. 使用html和js制作饼图,使用js画图之饼图
  7. 梦雨百度网盘批量改名与文件批量复制
  8. Unreal 4.24毛发
  9. python测试驱动开发pdf_python 测试驱动开发的简单例子
  10. 大数据开发面试准备——计算机网络