Add support for supplicant SCAN_INTERVAL
Also, allow scan interval for framework and supplicant
to be configured at build time or run time
Bug: 4144882
Change-Id: I877f4bcc872597b44d3f4da85cf2bc0f16e09444
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 6deb5a0..c75b0fe 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3303,12 +3303,20 @@
public static final String WIFI_IDLE_MS = "wifi_idle_ms";
/**
- * The interval in milliseconds to issue scans when the driver is
- * started. This is necessary to allow wifi to connect to an
- * access point when the driver is suspended.
+ * The interval in milliseconds to issue wake up scans when wifi needs
+ * to connect. This is necessary to connect to an access point when
+ * device is on the move and the screen is off.
* @hide
*/
- public static final String WIFI_SCAN_INTERVAL_MS = "wifi_scan_interval_ms";
+ public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
+ "wifi_framework_scan_interval_ms";
+
+ /**
+ * The interval in milliseconds to scan as used by the wifi supplicant
+ * @hide
+ */
+ public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
+ "wifi_supplicant_scan_interval_ms";
/**
* The interval in milliseconds at which to check packet counts on the
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp
index 667ba75..494dc27 100644
--- a/core/jni/android_net_wifi_Wifi.cpp
+++ b/core/jni/android_net_wifi_Wifi.cpp
@@ -556,7 +556,7 @@
return doBooleanCommand(cmdstr, "OK");
}
-static void android_net_wifi_enableBackgroundScan(JNIEnv* env, jobject clazz, jboolean enable)
+static void android_net_wifi_enableBackgroundScanCommand(JNIEnv* env, jobject clazz, jboolean enable)
{
//Note: BGSCAN-START and BGSCAN-STOP are documented in core/res/res/values/config.xml
//and will need an update if the names are changed
@@ -568,6 +568,16 @@
}
}
+static void android_net_wifi_setScanIntervalCommand(JNIEnv* env, jobject clazz, jint scanInterval)
+{
+ char cmdstr[BUF_SIZE];
+
+ int numWritten = snprintf(cmdstr, sizeof(cmdstr), "SCAN_INTERVAL %d", scanInterval);
+
+ if(numWritten < (int)sizeof(cmdstr)) doBooleanCommand(cmdstr, "OK");
+}
+
+
// ----------------------------------------------------------------------------
/*
@@ -635,7 +645,8 @@
(void*) android_net_wifi_setSuspendOptimizationsCommand},
{ "setCountryCodeCommand", "(Ljava/lang/String;)Z",
(void*) android_net_wifi_setCountryCodeCommand},
- { "enableBackgroundScan", "(Z)V", (void*) android_net_wifi_enableBackgroundScan},
+ { "enableBackgroundScanCommand", "(Z)V", (void*) android_net_wifi_enableBackgroundScanCommand},
+ { "setScanIntervalCommand", "(I)V", (void*) android_net_wifi_setScanIntervalCommand},
};
int register_android_net_wifi_WifiManager(JNIEnv* env)
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 56bc1d3..107a06a 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -209,6 +209,15 @@
The driver commands needed to support the feature are BGSCAN-START and BGSCAN-STOP -->
<bool translatable="false" name="config_wifi_background_scan_support">false</bool>
+ <!-- Integer indicating wpa_supplicant scan interval in milliseconds -->
+ <integer translatable="false" name="config_wifi_supplicant_scan_interval">15000</integer>
+
+ <!-- Integer indicating the framework scan interval in milliseconds. This is used in the scenario
+ where the chipset does not support background scanning (config_wifi_background_scan_suport
+ is false) to set up a periodic wake up scan so that the device can connect to a new access
+ point on the move. A value of 0 means no periodic scans will be used in the framework. -->
+ <integer translatable="false" name="config_wifi_framework_scan_interval">300000</integer>
+
<!-- Flag indicating whether the keyguard should be bypassed when
the slider is open. This can be set or unset depending how easily
the slider can be opened (for example, in a pocket or purse). -->