diff options
author | Hung-ying Tyan <tyanh@google.com> | 2011-07-03 20:01:55 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-03 20:01:55 -0700 |
commit | 9324e04dcf4d5dd4dd08b1a4d7d981e259df3fe0 (patch) | |
tree | d802b2e1139cb38e7cb58edef418064cc3dc0340 /voip | |
parent | f8c34ad3efd82974f166419b174431564658a7d0 (diff) | |
parent | f89654dd2847cc574dfa6a44806289f7e69e17b7 (diff) | |
download | frameworks_base-9324e04dcf4d5dd4dd08b1a4d7d981e259df3fe0.zip frameworks_base-9324e04dcf4d5dd4dd08b1a4d7d981e259df3fe0.tar.gz frameworks_base-9324e04dcf4d5dd4dd08b1a4d7d981e259df3fe0.tar.bz2 |
Merge "Do not hold wifi lock when SIP is also available over mobile network."
Diffstat (limited to 'voip')
-rw-r--r-- | voip/java/com/android/server/sip/SipService.java | 51 |
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"); } |