Skip to content

Commit 797e688

Browse files
committed
Continue trying to make the turn off quickly after call feature work.
The previous implementation worked if the set timeout is short enough, which mine was. This one carries the remaining amount of timeout override forward through all of the countdown steps. Bug: 2844990 Change-Id: I040df22f9f9ddf98c355ac6845b7624e95f84f33
1 parent d5e601c commit 797e688

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

services/java/com/android/server/PowerManagerService.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,11 +1029,10 @@ private void setTimeoutLocked(long now, int nextState) {
10291029
// If they gave a timeoutOverride it is the number of seconds
10301030
// to screen-off. Figure out where in the countdown cycle we
10311031
// should jump to.
1032-
private void setTimeoutLocked(long now, long timeoutOverride, int nextState) {
1032+
private void setTimeoutLocked(long now, final long originalTimeoutOverride, int nextState) {
1033+
long timeoutOverride = originalTimeoutOverride;
10331034
if (mBootCompleted) {
10341035
synchronized (mLocks) {
1035-
mHandler.removeCallbacks(mTimeoutTask);
1036-
mTimeoutTask.nextState = nextState;
10371036
long when = 0;
10381037
if (timeoutOverride <= 0) {
10391038
switch (nextState)
@@ -1084,6 +1083,12 @@ private void setTimeoutLocked(long now, long timeoutOverride, int nextState) {
10841083
+ " timeoutOverride=" + timeoutOverride
10851084
+ " nextState=" + nextState + " when=" + when);
10861085
}
1086+
1087+
mHandler.removeCallbacks(mTimeoutTask);
1088+
mTimeoutTask.nextState = nextState;
1089+
mTimeoutTask.remainingTimeoutOverride = timeoutOverride > 0
1090+
? (originalTimeoutOverride - timeoutOverride)
1091+
: -1;
10871092
mHandler.postAtTime(mTimeoutTask, when);
10881093
mNextTimeout = when; // for debugging
10891094
}
@@ -1099,6 +1104,7 @@ private void cancelTimerLocked()
10991104
private class TimeoutTask implements Runnable
11001105
{
11011106
int nextState; // access should be synchronized on mLocks
1107+
long remainingTimeoutOverride;
11021108
public void run()
11031109
{
11041110
synchronized (mLocks) {
@@ -1119,11 +1125,11 @@ public void run()
11191125
{
11201126
case SCREEN_BRIGHT:
11211127
if (mDimDelay >= 0) {
1122-
setTimeoutLocked(now, SCREEN_DIM);
1128+
setTimeoutLocked(now, remainingTimeoutOverride, SCREEN_DIM);
11231129
break;
11241130
}
11251131
case SCREEN_DIM:
1126-
setTimeoutLocked(now, SCREEN_OFF);
1132+
setTimeoutLocked(now, remainingTimeoutOverride, SCREEN_OFF);
11271133
break;
11281134
}
11291135
}
@@ -2054,6 +2060,7 @@ private void userActivity(long time, long timeoutOverride, boolean noChangeLight
20542060
+ " mUserState=0x" + Integer.toHexString(mUserState)
20552061
+ " mWakeLockState=0x" + Integer.toHexString(mWakeLockState)
20562062
+ " mProximitySensorActive=" + mProximitySensorActive
2063+
+ " timeoutOverride=" + timeoutOverride
20572064
+ " force=" + force);
20582065
}
20592066
// ignore user activity if we are in the process of turning off the screen

0 commit comments

Comments
 (0)