summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2014-11-20 06:11:10 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2014-11-20 06:11:10 -0800
commit70a7f6985c6b12097f3f96fe0274f2c9a04f9e76 (patch)
treeaff3b70ba180fee2c2f6f8a6fd5f19bfcad1b7c1
parent5a5a1e854b985cab758bf00b68cddc6b0ceb691b (diff)
parent522bbd51fa129e0b83c5228aa7ef0421540d2a4d (diff)
downloadandroid_frameworks_opt_net_wifi-70a7f6985c6b12097f3f96fe0274f2c9a04f9e76.tar.gz
android_frameworks_opt_net_wifi-70a7f6985c6b12097f3f96fe0274f2c9a04f9e76.tar.bz2
android_frameworks_opt_net_wifi-70a7f6985c6b12097f3f96fe0274f2c9a04f9e76.zip
Merge "Wifi: Reduce auto join scans when p2p is connected"
-rwxr-xr-xservice/java/com/android/server/wifi/WifiConfigStore.java28
-rwxr-xr-xservice/java/com/android/server/wifi/WifiStateMachine.java36
2 files changed, 62 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java
index 37620ab05..959c3f8be 100755
--- a/service/java/com/android/server/wifi/WifiConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiConfigStore.java
@@ -261,6 +261,8 @@ public class WifiConfigStore extends IpConfigStore {
= "ASSOCIATED_FULL_SCAN_BACKOFF_PERIOD: ";
private static final String ALWAYS_ENABLE_SCAN_WHILE_ASSOCIATED_KEY
= "ALWAYS_ENABLE_SCAN_WHILE_ASSOCIATED: ";
+ private static final String AUTO_JOIN_SCAN_INTERVAL_WHEN_P2P_CONNECTED_KEY
+ = "AUTO_JOIN_SCAN_INTERVAL_WHEN_P2P_CONNECTED: ";
private static final String ONLY_LINK_SAME_CREDENTIAL_CONFIGURATIONS_KEY
= "ONLY_LINK_SAME_CREDENTIAL_CONFIGURATIONS: ";
@@ -351,6 +353,7 @@ public class WifiConfigStore extends IpConfigStore {
boolean showNetworks = true; // TODO set this back to false, used for debugging 17516271
public int alwaysEnableScansWhileAssociated = 0;
+ public int autoJoinScanIntervalWhenP2pConnected = 300000;
public int maxNumActiveChannelsForPartialScans = 6;
public int maxNumPassiveChannelsForPartialScans = 2;
@@ -2456,6 +2459,31 @@ public class WifiConfigStore extends IpConfigStore {
Log.d(TAG,"readAutoJoinConfig: incorrect format :" + key);
}
}
+ if (key.startsWith(
+ AUTO_JOIN_SCAN_INTERVAL_WHEN_P2P_CONNECTED_KEY)) {
+ int scanInterval;
+ String st = key.replace(
+ AUTO_JOIN_SCAN_INTERVAL_WHEN_P2P_CONNECTED_KEY,
+ "");
+ st = st.replace(SEPARATOR_KEY, "");
+ try {
+ scanInterval = Integer.parseInt(st);
+ if (scanInterval >= 10000) {
+ autoJoinScanIntervalWhenP2pConnected = scanInterval;
+ } else {
+ Log.d(TAG,
+ "Cfg value is less then 10sec, Using default="
+ + autoJoinScanIntervalWhenP2pConnected);
+ }
+ Log.d(TAG, "readAutoJoinConfig: " +
+ "autoJoinScanIntervalWhenP2pConnected = "
+ + Integer.toString(
+ autoJoinScanIntervalWhenP2pConnected));
+ } catch (NumberFormatException e) {
+ Log.d(TAG, "readAutoJoinConfig: incorrect format :" +
+ key);
+ }
+ }
}
} catch (EOFException ignore) {
if (reader != null) {
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 120ee3889..fc12b8e68 100755
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -1619,14 +1619,40 @@ public class WifiStateMachine extends StateMachine {
private static int MESSAGE_HANDLING_STATUS_HANDLING_ERROR = -7;
private int messageHandlingStatus = 0;
+ private static long lastScanDuringP2p = 0;
//TODO: this is used only to track connection attempts, however the link state and packet per
//TODO: second logic should be folded into that
- private boolean isScanAllowed() {
+ private boolean isScanAllowed(int scanSource) {
long now = System.currentTimeMillis();
if (lastConnectAttempt != 0 && (now - lastConnectAttempt) < 10000) {
return false;
}
+ if (mP2pConnected.get()) {
+ if (scanSource == SCAN_ALARM_SOURCE) {
+ if (VDBG) {
+ logd("P2P connected: lastScanDuringP2p=" +
+ lastScanDuringP2p +
+ " CurrentTime=" + now +
+ " autoJoinScanIntervalWhenP2pConnected=" +
+ mWifiConfigStore.autoJoinScanIntervalWhenP2pConnected);
+ }
+
+ if (lastScanDuringP2p == 0 || (now - lastScanDuringP2p)
+ < mWifiConfigStore.autoJoinScanIntervalWhenP2pConnected) {
+ if (lastScanDuringP2p == 0) lastScanDuringP2p = now;
+ if (VDBG) {
+ logd("P2P connected, discard scan within " +
+ mWifiConfigStore.autoJoinScanIntervalWhenP2pConnected
+ + " milliseconds");
+ }
+ return false;
+ }
+ lastScanDuringP2p = now;
+ }
+ } else {
+ lastScanDuringP2p = 0;
+ }
return true;
}
@@ -6842,6 +6868,11 @@ public class WifiStateMachine extends StateMachine {
deferMessage(message);
break;
case CMD_START_SCAN:
+ if (!isScanAllowed(message.arg1)) {
+ // Ignore the scan request
+ if (VDBG) logd("L2ConnectedState: ignore scan");
+ return HANDLED;
+ }
//if (DBG) {
loge("WifiStateMachine CMD_START_SCAN source " + message.arg1
+ " txSuccessRate="+String.format( "%.2f", mWifiInfo.txSuccessRate)
@@ -7764,8 +7795,9 @@ public class WifiStateMachine extends StateMachine {
ret = NOT_HANDLED;
break;
case CMD_START_SCAN:
- if (!isScanAllowed()) {
+ if (!isScanAllowed(message.arg1)) {
// Ignore the scan request
+ if (VDBG) logd("DisconnectedState: ignore scan");
return HANDLED;
}
/* Disable background scan temporarily during a regular scan */