summaryrefslogtreecommitdiffstats
path: root/voip/java
diff options
context:
space:
mode:
authorChung-yih Wang <cywang@google.com>2010-10-21 09:51:01 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-10-21 09:51:01 -0700
commit16f5d6ee797543b42ea457c8a8724a569eac6595 (patch)
tree765d3bde39dc4c8c8d69c4d442ba4c0bedd1b30b /voip/java
parent9d6d17fcd80ca43fb57c4bb5808e55e79f0fbe26 (diff)
parentaefcdde4bdf2be74bdf9620359830faeed5419e6 (diff)
downloadframeworks_base-16f5d6ee797543b42ea457c8a8724a569eac6595.zip
frameworks_base-16f5d6ee797543b42ea457c8a8724a569eac6595.tar.gz
frameworks_base-16f5d6ee797543b42ea457c8a8724a569eac6595.tar.bz2
am aefcdde4: am 4944fdd7: Periodically scan wifi when wifi is not connected and wifi lock is grabbed in SipService.
Merge commit 'aefcdde4bdf2be74bdf9620359830faeed5419e6' * commit 'aefcdde4bdf2be74bdf9620359830faeed5419e6': Periodically scan wifi when wifi is not connected and wifi lock is
Diffstat (limited to 'voip/java')
-rw-r--r--voip/java/com/android/server/sip/SipService.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/voip/java/com/android/server/sip/SipService.java b/voip/java/com/android/server/sip/SipService.java
index 2a35fb0..84e0803 100644
--- a/voip/java/com/android/server/sip/SipService.java
+++ b/voip/java/com/android/server/sip/SipService.java
@@ -79,6 +79,7 @@ public final class SipService extends ISipService.Stub {
private String mNetworkType;
private boolean mConnected;
private WakeupTimer mTimer;
+ private WifiScanProcess mWifiScanProcess;
private WifiManager.WifiLock mWifiLock;
private boolean mWifiOnly;
@@ -371,6 +372,7 @@ public final class SipService extends ISipService.Stub {
mContext.getSystemService(Context.WIFI_SERVICE))
.createWifiLock(WifiManager.WIFI_MODE_FULL, TAG);
mWifiLock.acquire();
+ if (!mConnected) startWifiScanner();
}
}
@@ -379,6 +381,20 @@ public final class SipService extends ISipService.Stub {
if (DEBUG) Log.d(TAG, "~~~~~~~~~~~~~~~~~~~~~ release wifi lock");
mWifiLock.release();
mWifiLock = null;
+ stopWifiScanner();
+ }
+ }
+
+ private synchronized void startWifiScanner() {
+ if (mWifiScanProcess == null) {
+ mWifiScanProcess = new WifiScanProcess();
+ }
+ mWifiScanProcess.start();
+ }
+
+ private synchronized void stopWifiScanner() {
+ if (mWifiScanProcess != null) {
+ mWifiScanProcess.stop();
}
}
@@ -413,8 +429,10 @@ public final class SipService extends ISipService.Stub {
for (SipSessionGroupExt group : mSipGroups.values()) {
group.onConnectivityChanged(true);
}
+ if (isWifi && (mWifiLock != null)) stopWifiScanner();
} else {
mMyWakeLock.reset(); // in case there's a leak
+ if (isWifi && (mWifiLock != null)) startWifiScanner();
}
} catch (SipException e) {
Log.e(TAG, "onConnectivityChanged()", e);
@@ -611,6 +629,36 @@ public final class SipService extends ISipService.Stub {
}
}
+ private class WifiScanProcess implements Runnable {
+ private static final String TAG = "\\WIFI_SCAN/";
+ private static final int INTERVAL = 60;
+ private boolean mRunning = false;
+
+ private WifiManager mWifiManager;
+
+ public void start() {
+ if (mRunning) return;
+ mRunning = true;
+ mTimer.set(INTERVAL * 1000, this);
+ }
+
+ WifiScanProcess() {
+ mWifiManager = (WifiManager)
+ mContext.getSystemService(Context.WIFI_SERVICE);
+ }
+
+ public void run() {
+ // scan and associate now
+ if (DEBUGV) Log.v(TAG, "just wake up here for wifi scanning...");
+ mWifiManager.startScanActive();
+ }
+
+ public void stop() {
+ mRunning = false;
+ mTimer.cancel(this);
+ }
+ }
+
// KeepAliveProcess is controlled by AutoRegistrationProcess.
// All methods will be invoked in sync with SipService.this.
private class KeepAliveProcess implements Runnable {