summaryrefslogtreecommitdiffstats
path: root/wifi/java/android
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2011-02-28 22:22:37 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-02-28 22:22:37 -0800
commitd86dbb9e00c998979db488a720ce263291f22c6a (patch)
treedeb009eea78d8c26d837112a1430a786aea69152 /wifi/java/android
parent6ade7c2624af7438fa50238f170db4299707c313 (diff)
parent5af7cf7c558e6febfa5d48b62900929743d2f7bb (diff)
downloadframeworks_base-d86dbb9e00c998979db488a720ce263291f22c6a.zip
frameworks_base-d86dbb9e00c998979db488a720ce263291f22c6a.tar.gz
frameworks_base-d86dbb9e00c998979db488a720ce263291f22c6a.tar.bz2
am 5af7cf7c: am f9e2a491: Fix issue to clear scan alarms
* commit '5af7cf7c558e6febfa5d48b62900929743d2f7bb': Fix issue to clear scan alarms
Diffstat (limited to 'wifi/java/android')
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java39
1 files changed, 28 insertions, 11 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 676218e..f9d2772 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -2785,11 +2785,30 @@ public class WifiStateMachine extends HierarchicalStateMachine {
class DisconnectedState extends HierarchicalState {
private boolean mAlarmEnabled = false;
+ private long mScanIntervalMs;
+
+ private void setScanAlarm(boolean enabled) {
+ if (enabled == mAlarmEnabled) return;
+ if (enabled) {
+ mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
+ System.currentTimeMillis() + mScanIntervalMs,
+ mScanIntervalMs,
+ mScanIntent);
+
+ mAlarmEnabled = true;
+ } else {
+ mAlarmManager.cancel(mScanIntent);
+ mAlarmEnabled = false;
+ }
+ }
+
@Override
public void enter() {
if (DBG) Log.d(TAG, getName() + "\n");
EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());
+ mScanIntervalMs = Settings.Secure.getLong(mContext.getContentResolver(),
+ Settings.Secure.WIFI_SCAN_INTERVAL_MS, DEFAULT_SCAN_INTERVAL_MS);
/*
* We initiate background scanning if it is enabled, otherwise we
* initiate an infrequent scan that wakes up the device to ensure
@@ -2806,12 +2825,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
WifiNative.enableBackgroundScan(true);
}
} else {
- long scanMs = Settings.Secure.getLong(mContext.getContentResolver(),
- Settings.Secure.WIFI_SCAN_INTERVAL_MS, DEFAULT_SCAN_INTERVAL_MS);
-
- mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
- System.currentTimeMillis() + scanMs, scanMs, mScanIntent);
- mAlarmEnabled = true;
+ setScanAlarm(true);
}
}
@Override
@@ -2829,7 +2843,13 @@ public class WifiStateMachine extends HierarchicalStateMachine {
break;
case CMD_ENABLE_BACKGROUND_SCAN:
mEnableBackgroundScan = (message.arg1 == 1);
- WifiNative.enableBackgroundScan(mEnableBackgroundScan);
+ if (mEnableBackgroundScan) {
+ WifiNative.enableBackgroundScan(true);
+ setScanAlarm(false);
+ } else {
+ WifiNative.enableBackgroundScan(false);
+ setScanAlarm(true);
+ }
break;
/* Ignore network disconnect */
case NETWORK_DISCONNECTION_EVENT:
@@ -2866,10 +2886,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
if (mEnableBackgroundScan) {
WifiNative.enableBackgroundScan(false);
}
- if (mAlarmEnabled) {
- mAlarmManager.cancel(mScanIntent);
- mAlarmEnabled = false;
- }
+ setScanAlarm(false);
}
}