[RK3288][Android6.0] 一律运行WLAN漫游扫描选项

Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92

开发者选项中有一栏是“”Always allow Wi‑Fi Roam Scans“
[RK3288][Android6.0] 一律运行WLAN漫游扫描选项_第1张图片
解释是运行WLAN漫游扫描,看它是如何影响扫描执行流程

对应是string name在
packages/apps/Settings/res/values/strings.xml:3645:
Always allow Wi\u2011Fi Roam Scans

代码里查找wifi_allow_scan_with_traffic
DevelopmentSettings.java
private static final String WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY = "wifi_allow_scan_with_traffic";
mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
点切换选项时,触发click操作:

public boolean onPreferenceTreeClick()
{
    } else if (preference == mWifiAllowScansWithTraffic) {
        writeWifiAllowScansWithTrafficOptions();
}

private void writeWifiAllowScansWithTrafficOptions() {
    mWifiManager.setAllowScansWithTraffic(mWifiAllowScansWithTraffic.isChecked() ? 1 : 0);
}

WifiStateMachine.java

public void setAllowScansWithTraffic(int enabled) {
    mWifiConfigStore.alwaysEnableScansWhileAssociated.set(enabled);
}

存到了mWifiConfigStore,找对应的get接口

public int getAllowScansWithTraffic() {
  return mWifiConfigStore.alwaysEnableScansWhileAssociated.get();
}

getAllowScansWithTraffic调用的地方

boolean allowFullBandScanAndAssociated() {
    // Too much traffic at the interface, hence no full band scan
    if (getAllowScansWithTraffic() == 0) {
        return false;
    }
}

当屏幕状态变化的时候,会调用

private void handleScreenStateChanged(boolean screenOn) {
 if (screenOn) {
  //如果allowFullBandScanAndAssociated()返回false,那么无论是startGScanConnectedModeOffload()
  //还是startDelayedScan()都无法执行scan了
  if (getCurrentState() == mConnectedState
            && allowFullBandScanAndAssociated()) {
        if (useHalBasedAutoJoinOffload()) {
            startGScanConnectedModeOffload("screenOnConnected");
        } else {
            // Scan after 500ms
            startDelayedScan(500, null, null);
        }
    }
  }
}

你可能感兴趣的:(子类__WiFi)