1) 如果当前Android OS并不存在已建立WIFI连接,则使用在编译时生成的build.prop中的"wifi.supplicant_scan_interval"属性的值(以秒为单位)
3) 如果Android OS进入IDLE状态(early suspend),扫描周期会变为10min.
同时以上规则会被以下可变化的因素所部分改变:
a) 部分vendor会覆盖系统默认属性,比如:
254PRODUCT_PROPERTY_OVERRIDES += \ 255 wifi.interface=wlan0 \ 256 wifi.supplicant_scan_interval=15 257
b) 在Android4.2.2中,wpa_supplicant_6,wpa_supplicant_8中默认值为5s:
1725static struct wpa_supplicant * wpa_supplicant_alloc(void) 1726{ 1727 struct wpa_supplicant *wpa_s; 1728 1729 wpa_s = os_zalloc(sizeof(*wpa_s)); 1730 if (wpa_s == NULL) 1731 return NULL; 1732 wpa_s->scan_req = 1; 1733#ifdef ANDROID 1734 wpa_s->scan_interval = 5; 1735#endif 1736 return wpa_s; 1737}
而在wpa_supplicant_6, wpa_supplicant_8中同时都存在运行时设置(wpa_cli.c)该参数(一般release版Android,不root没法设置)的方式:
4827 reply_len = -1; 4828 } else if (os_strncmp(buf, "SCAN_INTERVAL ", 14) == 0) { 4829 if (wpa_supplicant_ctrl_iface_scan_interval(wpa_s, buf + 14)) 4830 reply_len = -1; 4831 } else if (os_strcmp(buf, "INTERFACE_LIST") == 0) { 4832 reply_len = wpa_supplicant_global_iface_list(
2960static int wpa_supplicant_ctrl_iface_scan_interval( 2961 struct wpa_supplicant *wpa_s, char *cmd) 2962{ 2963 int scan_int = atoi(cmd); 2964 return wpa_supplicant_set_scan_interval(wpa_s, scan_int); 2965}
1997int wpa_supplicant_set_scan_interval(struct wpa_supplicant *wpa_s, 1998 int scan_interval) 1999{ 2000 if (scan_interval < 0) { 2001 wpa_msg(wpa_s, MSG_ERROR, "Invalid scan interval %d", 2002 scan_interval); 2003 return -1; 2004 } 2005 wpa_msg(wpa_s, MSG_DEBUG, "Setting scan interval: %d sec", 2006 scan_interval); 2007 wpa_s->scan_interval = scan_interval; 2008 2009 return 0; 2010}