Fix issue #6664140: Time to lock should work even Stay awake...

...in Developer options is on

Don't respect stay awake while on as long as a time to lock limit
is being enforced.  When we start enforcing one, make sure the
setting is off (since we won't be respecting it anyway).

Bug: 6664140
Change-Id: Id07cb528afa0c64c7766341841c51771f507121d
This commit is contained in:
Dianne Hackborn
2012-06-15 17:05:25 -07:00
parent 87959cdd85
commit 2fe8fb276c
2 changed files with 51 additions and 37 deletions

View File

@@ -477,6 +477,11 @@ public class PowerManagerService extends IPowerManager.Stub
}
}
int getStayOnConditionsLocked() {
return mMaximumScreenOffTimeout <= 0 || mMaximumScreenOffTimeout == Integer.MAX_VALUE
? mStayOnConditions : 0;
}
private class SettingsObserver implements Observer {
private int getInt(String name, int defValue) {
ContentValues values = mSettings.getValues(name);
@@ -760,7 +765,8 @@ public class PowerManagerService extends IPowerManager.Stub
}
private void updateWakeLockLocked() {
if (mStayOnConditions != 0 && mBatteryService.isPowered(mStayOnConditions)) {
final int stayOnConditions = getStayOnConditionsLocked();
if (stayOnConditions != 0 && mBatteryService.isPowered(stayOnConditions)) {
// keep the device on if we're plugged in and mStayOnWhilePluggedIn is set.
mStayOnWhilePluggedInScreenDimLock.acquire();
mStayOnWhilePluggedInPartialLock.acquire();
@@ -2097,7 +2103,8 @@ public class PowerManagerService extends IPowerManager.Stub
// was dim
steps = (int)(ANIM_STEPS*ratio);
}
if (mStayOnConditions != 0 && mBatteryService.isPowered(mStayOnConditions)) {
final int stayOnConditions = getStayOnConditionsLocked();
if (stayOnConditions != 0 && mBatteryService.isPowered(stayOnConditions)) {
// If the "stay on while plugged in" option is
// turned on, then the screen will often not
// automatically turn off while plugged in. To