summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorWei Liu <luciferleo@google.com>2016-06-03 10:37:52 -0700
committerWei Liu <luciferleo@google.com>2016-06-03 15:22:33 -0700
commit07a83d343adb6a5a2d4fce734b1dbec717126b6d (patch)
tree7b4c2c9d3d35ef913ee5ba2fc083f2eb80ff7213 /service
parenteb6b69f6c2b1e1327065c23a9ba0895ccb5f782a (diff)
Hold the wakelock for suspend optimaztion only when it matters.
b/23106128 Change-Id: I367ffd43f84bb46276d30c12ffcd54d641a9bc4a
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 2181311bc..6a28c0c83 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -2879,12 +2879,16 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
enableRssiPolling(screenOn);
if (mUserWantsSuspendOpt.get()) {
+ int shouldReleaseWakeLock = 0;
if (screenOn) {
- sendMessage(CMD_SET_SUSPEND_OPT_ENABLED, 0, 0);
+ sendMessage(CMD_SET_SUSPEND_OPT_ENABLED, 0, shouldReleaseWakeLock);
} else {
- // Allow 2s for suspend optimizations to be set
- mSuspendWakeLock.acquire(2000);
- sendMessage(CMD_SET_SUSPEND_OPT_ENABLED, 1, 0);
+ if (isConnected()) {
+ // Allow 2s for suspend optimizations to be set
+ mSuspendWakeLock.acquire(2000);
+ shouldReleaseWakeLock = 1;
+ }
+ sendMessage(CMD_SET_SUSPEND_OPT_ENABLED, 1, shouldReleaseWakeLock);
}
}
mScreenBroadcastReceived.set(true);
@@ -4070,7 +4074,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
break;
case CMD_SET_SUSPEND_OPT_ENABLED:
if (message.arg1 == 1) {
- mSuspendWakeLock.release();
+ if (message.arg2 == 1) {
+ mSuspendWakeLock.release();
+ }
setSuspendOptimizations(SUSPEND_DUE_TO_SCREEN, true);
} else {
setSuspendOptimizations(SUSPEND_DUE_TO_SCREEN, false);
@@ -4789,7 +4795,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
case CMD_SET_SUSPEND_OPT_ENABLED:
if (message.arg1 == 1) {
setSuspendOptimizationsNative(SUSPEND_DUE_TO_SCREEN, true);
- mSuspendWakeLock.release();
+ if (message.arg2 == 1) {
+ mSuspendWakeLock.release();
+ }
} else {
setSuspendOptimizationsNative(SUSPEND_DUE_TO_SCREEN, false);
}