diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-10-02 21:18:04 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-10-02 21:18:04 -0700 |
commit | ff532540f18e3b2181da0550fe55045418a3b84e (patch) | |
tree | 6b7c771a5838873365e3864ee1069de712b07c77 | |
parent | f3fb895269deadcda0cf497d421e4b89e8ee8f8f (diff) | |
download | frameworks_base-ff532540f18e3b2181da0550fe55045418a3b84e.zip frameworks_base-ff532540f18e3b2181da0550fe55045418a3b84e.tar.gz frameworks_base-ff532540f18e3b2181da0550fe55045418a3b84e.tar.bz2 |
Improve the screen dim duration calculation.
Take into account whether the screen off timeout is very short.
If so, we use a shorter dim timeout. Don't allow the dim
time to be more than 20% of the total screen on time so that
the screen remains bright at least 80% of the time even when
the timeout is short.
Bug: 7273646
Change-Id: Iccea764b90f0d8b1df7009d26160c6bcf6eabe5b
-rw-r--r-- | services/java/com/android/server/power/PowerManagerService.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java index 2ddda6c..d1c24eb 100644 --- a/services/java/com/android/server/power/PowerManagerService.java +++ b/services/java/com/android/server/power/PowerManagerService.java @@ -130,11 +130,17 @@ public final class PowerManagerService extends IPowerManager.Stub private static final int DEFAULT_SCREEN_OFF_TIMEOUT = 15 * 1000; private static final int MINIMUM_SCREEN_OFF_TIMEOUT = 10 * 1000; - // The screen dim duration, in seconds. + // The screen dim duration, in milliseconds. // This is subtracted from the end of the screen off timeout so the // minimum screen off timeout should be longer than this. private static final int SCREEN_DIM_DURATION = 7 * 1000; + // The maximum screen dim time expressed as a ratio relative to the screen + // off timeout. If the screen off timeout is very short then we want the + // dim timeout to also be quite short so that most of the time is spent on. + // Otherwise the user won't get much screen on time before dimming occurs. + private static final float MAXIMUM_SCREEN_DIM_RATIO = 0.2f; + // Upper bound on the battery charge percentage in order to consider turning // the screen on when the device starts charging wirelessly. // See point of use for more details. @@ -1168,7 +1174,7 @@ public final class PowerManagerService extends IPowerManager.Stub long nextTimeout = 0; if (mWakefulness != WAKEFULNESS_ASLEEP) { final int screenOffTimeout = getScreenOffTimeoutLocked(); - final int screenDimDuration = getScreenDimDurationLocked(); + final int screenDimDuration = getScreenDimDurationLocked(screenOffTimeout); mUserActivitySummary = 0; if (mLastUserActivityTime >= mLastWakeTime) { @@ -1242,8 +1248,9 @@ public final class PowerManagerService extends IPowerManager.Stub return Math.max(timeout, MINIMUM_SCREEN_OFF_TIMEOUT); } - private int getScreenDimDurationLocked() { - return SCREEN_DIM_DURATION; + private int getScreenDimDurationLocked(int screenOffTimeout) { + return Math.min(SCREEN_DIM_DURATION, + (int)(screenOffTimeout * MAXIMUM_SCREEN_DIM_RATIO)); } /** @@ -1987,6 +1994,12 @@ public final class PowerManagerService extends IPowerManager.Stub pw.println(" mScreenBrightnessSettingMaximum=" + mScreenBrightnessSettingMaximum); pw.println(" mScreenBrightnessSettingDefault=" + mScreenBrightnessSettingDefault); + final int screenOffTimeout = getScreenOffTimeoutLocked(); + final int screenDimDuration = getScreenDimDurationLocked(screenOffTimeout); + pw.println(); + pw.println("Screen off timeout: " + screenOffTimeout + " ms"); + pw.println("Screen dim duration: " + screenDimDuration + " ms"); + pw.println(); pw.println("Wake Locks: size=" + mWakeLocks.size()); for (WakeLock wl : mWakeLocks) { |