summaryrefslogtreecommitdiffstats
path: root/wifi/java
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2012-03-12 15:55:20 -0700
committerIrfan Sheriff <isheriff@google.com>2012-03-12 16:12:55 -0700
commit90d57dfac3113247e2d38a2235254fc35d12856a (patch)
tree94cdd5650e2431c635d0ed2721ee7d779d7a3db9 /wifi/java
parentd4933842b1f665f4d88b75a5d4d152cbc02e7010 (diff)
downloadframeworks_base-90d57dfac3113247e2d38a2235254fc35d12856a.zip
frameworks_base-90d57dfac3113247e2d38a2235254fc35d12856a.tar.gz
frameworks_base-90d57dfac3113247e2d38a2235254fc35d12856a.tar.bz2
Improve network avoidance
Adds a back-off based technique where the amount of time we wait before avoiding wi-fi is increased. This will reduce power consumption on devices that are experiencing high variance on wi-fi Change-Id: I40da03edfb5373ddb51056818ca0744dc26a5600
Diffstat (limited to 'wifi/java')
-rw-r--r--wifi/java/android/net/wifi/WifiWatchdogStateMachine.java34
1 files changed, 26 insertions, 8 deletions
diff --git a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
index 5c9bef9..f31ee68 100644
--- a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
@@ -113,11 +113,14 @@ public class WifiWatchdogStateMachine extends StateMachine {
private static final int RSSI_MONITOR_COUNT = 5;
private int mRssiMonitorCount = 0;
- /* Avoid flapping */
- private static final int MIN_INTERVAL_AVOID_BSSID_MS = 60 * 1000;
- private String mLastAvoidedBssid;
- /* a -ve interval to allow avoidance at boot */
- private long mLastBssidAvoidedTime = -MIN_INTERVAL_AVOID_BSSID_MS;
+ /* Avoid flapping. The interval is changed over time as long as we continue to avoid
+ * under the max interval after which we reset the interval again */
+ private static final int MIN_INTERVAL_AVOID_BSSID_MS[] = {0, 30 * 1000, 60 * 1000,
+ 5 * 60 * 1000, 30 * 60 * 1000};
+ /* Index into the interval array MIN_INTERVAL_AVOID_BSSID_MS */
+ private int mMinIntervalArrayIndex = 0;
+
+ private long mLastBssidAvoidedTime;
private int mCurrentSignalLevel;
@@ -744,11 +747,13 @@ public class WifiWatchdogStateMachine extends StateMachine {
mCurrentSignalLevel = calculateSignalLevel(msg.arg1);
//Ready to avoid bssid again ?
long time = android.os.SystemClock.elapsedRealtime();
- if (time - mLastBssidAvoidedTime > MIN_INTERVAL_AVOID_BSSID_MS) {
+ if (time - mLastBssidAvoidedTime > MIN_INTERVAL_AVOID_BSSID_MS[
+ mMinIntervalArrayIndex]) {
handleRssiChange();
} else {
if (DBG) log("Early to avoid " + mWifiInfo + " time: " + time +
- " last avoided: " + mLastBssidAvoidedTime);
+ " last avoided: " + mLastBssidAvoidedTime +
+ " mMinIntervalArrayIndex: " + mMinIntervalArrayIndex);
}
break;
default:
@@ -892,7 +897,20 @@ public class WifiWatchdogStateMachine extends StateMachine {
private void sendPoorLinkDetected() {
if (DBG) log("send POOR_LINK_DETECTED " + mWifiInfo);
mWsmChannel.sendMessage(POOR_LINK_DETECTED);
- mLastAvoidedBssid = mWifiInfo.getBSSID();
+
+ long time = android.os.SystemClock.elapsedRealtime();
+ if (time - mLastBssidAvoidedTime > MIN_INTERVAL_AVOID_BSSID_MS[
+ MIN_INTERVAL_AVOID_BSSID_MS.length - 1]) {
+ mMinIntervalArrayIndex = 1;
+ if (DBG) log("set mMinIntervalArrayIndex to 1");
+ } else {
+
+ if (mMinIntervalArrayIndex < MIN_INTERVAL_AVOID_BSSID_MS.length - 1) {
+ mMinIntervalArrayIndex++;
+ }
+ if (DBG) log("mMinIntervalArrayIndex: " + mMinIntervalArrayIndex);
+ }
+
mLastBssidAvoidedTime = android.os.SystemClock.elapsedRealtime();
}