diff options
author | Chung-yih Wang <cywang@google.com> | 2010-10-08 23:30:05 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-10-08 23:30:05 -0700 |
commit | 833db40866ebf27be33aa387d08a2cb0b9a4246d (patch) | |
tree | 0efe5eeae48d88ebcdfae99c8e85c1f7f3fcbee1 /voip | |
parent | 4c2c62fe08c736273dd9fb5910dedc7ecdc5f4b3 (diff) | |
parent | dc2e5208e2b448a2c481d726818de79ea6a49783 (diff) | |
download | frameworks_base-833db40866ebf27be33aa387d08a2cb0b9a4246d.zip frameworks_base-833db40866ebf27be33aa387d08a2cb0b9a4246d.tar.gz frameworks_base-833db40866ebf27be33aa387d08a2cb0b9a4246d.tar.bz2 |
am dc2e5208: Merge "Do not release the wifi lock if the screen is off." into gingerbread
Merge commit 'dc2e5208e2b448a2c481d726818de79ea6a49783' into gingerbread-plus-aosp
* commit 'dc2e5208e2b448a2c481d726818de79ea6a49783':
Do not release the wifi lock if the screen is off.
Diffstat (limited to 'voip')
-rw-r--r-- | voip/java/com/android/server/sip/SipService.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/voip/java/com/android/server/sip/SipService.java b/voip/java/com/android/server/sip/SipService.java index db1931b..ee554b5 100644 --- a/voip/java/com/android/server/sip/SipService.java +++ b/voip/java/com/android/server/sip/SipService.java @@ -92,6 +92,7 @@ public final class SipService extends ISipService.Stub { new HashMap<String, ISipSession>(); private ConnectivityReceiver mConnectivityReceiver; + private boolean mScreenOn; /** * Starts the SIP service. Do nothing if the SIP API is not supported on the @@ -111,11 +112,27 @@ public final class SipService extends ISipService.Stub { mConnectivityReceiver = new ConnectivityReceiver(); context.registerReceiver(mConnectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); + context.registerReceiver(mScreenOnOffReceiver, + new IntentFilter(Intent.ACTION_SCREEN_ON)); + context.registerReceiver(mScreenOnOffReceiver, + new IntentFilter(Intent.ACTION_SCREEN_OFF)); mTimer = new WakeupTimer(context); mWifiOnly = SipManager.isSipWifiOnly(context); } + BroadcastReceiver mScreenOnOffReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (Intent.ACTION_SCREEN_OFF.equals(action)) { + mScreenOn = true; + } else if (Intent.ACTION_SCREEN_ON.equals(action)) { + mScreenOn = false; + } + } + }; + private MyExecutor getExecutor() { // create mExecutor lazily if (mExecutor == null) mExecutor = new MyExecutor(); @@ -366,7 +383,10 @@ public final class SipService extends ISipService.Stub { boolean wifiOff = (isWifi && !connected) || (wasWifi && !sameType); boolean wifiOn = isWifi && connected; if (wifiOff) { - releaseWifiLock(); + if (mScreenOn) releaseWifiLock(); + // If the screen is off, we still keep the wifi lock in order + // to be able to reassociate with any available AP. Otherwise, + // the wifi driver could be stopped after 15 mins of idle time. } else if (wifiOn) { if (anyOpened()) grabWifiLock(); } |