summaryrefslogtreecommitdiffstats
path: root/voip
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2011-07-01 19:25:46 +0800
committerHung-ying Tyan <tyanh@google.com>2011-07-01 19:25:46 +0800
commitf89654dd2847cc574dfa6a44806289f7e69e17b7 (patch)
tree25ab43ac44c6f0e98c13460d52ab10eaac84c11c /voip
parenta6cec8feed5c135bb5f4d6193012d13258a067c4 (diff)
downloadframeworks_base-f89654dd2847cc574dfa6a44806289f7e69e17b7.zip
frameworks_base-f89654dd2847cc574dfa6a44806289f7e69e17b7.tar.gz
frameworks_base-f89654dd2847cc574dfa6a44806289f7e69e17b7.tar.bz2
Do not hold wifi lock when SIP is also available over mobile network.
Bug: 3111564 Change-Id: Ifc76e5c378d620e40ce4adf6ffa20807e9750fdb
Diffstat (limited to 'voip')
-rw-r--r--voip/java/com/android/server/sip/SipService.java51
1 files changed, 30 insertions, 21 deletions
diff --git a/voip/java/com/android/server/sip/SipService.java b/voip/java/com/android/server/sip/SipService.java
index 47863bd..ddc8031 100644
--- a/voip/java/com/android/server/sip/SipService.java
+++ b/voip/java/com/android/server/sip/SipService.java
@@ -83,6 +83,8 @@ public final class SipService extends ISipService.Stub {
private WifiScanProcess mWifiScanProcess;
private WifiManager.WifiLock mWifiLock;
private boolean mWifiOnly;
+ private BroadcastReceiver mWifiStateReceiver = null;
+
private IntervalMeasurementProcess mIntervalMeasurementProcess;
private MyExecutor mExecutor = new MyExecutor();
@@ -123,40 +125,47 @@ public final class SipService extends ISipService.Stub {
mWifiOnly = SipManager.isSipWifiOnly(context);
}
- private BroadcastReceiver mWifiStateReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
- int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
- WifiManager.WIFI_STATE_UNKNOWN);
- synchronized (SipService.this) {
- switch (state) {
- case WifiManager.WIFI_STATE_ENABLED:
- mWifiEnabled = true;
- if (anyOpenedToReceiveCalls()) grabWifiLock();
- break;
- case WifiManager.WIFI_STATE_DISABLED:
- mWifiEnabled = false;
- releaseWifiLock();
- break;
+ private BroadcastReceiver createWifiBroadcastReceiver() {
+ return new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
+ int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
+ WifiManager.WIFI_STATE_UNKNOWN);
+ synchronized (SipService.this) {
+ switch (state) {
+ case WifiManager.WIFI_STATE_ENABLED:
+ mWifiEnabled = true;
+ if (anyOpenedToReceiveCalls()) grabWifiLock();
+ break;
+ case WifiManager.WIFI_STATE_DISABLED:
+ mWifiEnabled = false;
+ releaseWifiLock();
+ break;
+ }
}
}
}
- }
+ };
};
private void registerReceivers() {
mContext.registerReceiver(mConnectivityReceiver,
new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
- mContext.registerReceiver(mWifiStateReceiver,
- new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION));
+ if (SipManager.isSipWifiOnly(mContext)) {
+ mWifiStateReceiver = createWifiBroadcastReceiver();
+ mContext.registerReceiver(mWifiStateReceiver,
+ new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION));
+ }
if (DEBUG) Log.d(TAG, " +++ register receivers");
}
private void unregisterReceivers() {
mContext.unregisterReceiver(mConnectivityReceiver);
- mContext.unregisterReceiver(mWifiStateReceiver);
+ if (SipManager.isSipWifiOnly(mContext)) {
+ mContext.unregisterReceiver(mWifiStateReceiver);
+ }
if (DEBUG) Log.d(TAG, " --- unregister receivers");
}