| From 1672d35b1d213d54adf7ef20bcc6344683e0969f Mon Sep 17 00:00:00 2001 |
| From: Ricardo Cerqueira <cyanogenmod@cerqueira.org> |
| Date: Fri, 23 Nov 2012 14:23:16 +0000 |
| Subject: [PATCH 02/16] Reintroduce button-backlight (and respective inactivity |
| timeout) |
| |
| The power manager rewrite from Change I1d7a52e98f0449f76d70bf421f6a7f245957d1d7 |
| completely removed support for control of the button backlights, which makes |
| all capacitive buttons out there stay dark. The commit message in that change |
| mentions it hasn't been implemented _yet_, so this fix should be temporary |
| until upstream does their own implementation |
| |
| [RC: Updated to 5.0] |
| |
| Change-Id: I6094c446e0b8c23f57d30652a3cbd35dee5e821a |
| --- |
| .../com/android/server/display/DisplayPowerController.java | 11 +++++++++++ |
| .../java/com/android/server/power/PowerManagerService.java | 10 ++++++++++ |
| 2 files changed, 21 insertions(+) |
| |
| diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java |
| index f8e5836..80bdf1f 100644 |
| --- a/services/core/java/com/android/server/display/DisplayPowerController.java |
| +++ b/services/core/java/com/android/server/display/DisplayPowerController.java |
| @@ -20,6 +20,7 @@ import android.app.ActivityManager; |
| import com.android.internal.app.IBatteryStats; |
| import com.android.server.LocalServices; |
| import com.android.server.am.BatteryStatsService; |
| +import com.android.server.lights.LightsManager; |
| |
| import android.animation.Animator; |
| import android.animation.ObjectAnimator; |
| @@ -129,6 +130,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call |
| // Battery stats. |
| private final IBatteryStats mBatteryStats; |
| |
| + // The lights service. |
| + private final LightsManager mLights; |
| + |
| // The sensor manager. |
| private final SensorManager mSensorManager; |
| |
| @@ -300,6 +304,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call |
| mCallbacks = callbacks; |
| |
| mBatteryStats = BatteryStatsService.getService(); |
| + mLights = LocalServices.getService(LightsManager.class); |
| mSensorManager = sensorManager; |
| mWindowManagerPolicy = LocalServices.getService(WindowManagerPolicy.class); |
| mBlanker = blanker; |
| @@ -678,6 +683,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call |
| // Use zero brightness when screen is off. |
| if (state == Display.STATE_OFF) { |
| brightness = PowerManager.BRIGHTNESS_OFF; |
| + mLights.getLight(LightsManager.LIGHT_ID_BUTTONS).setBrightness(brightness); |
| + } |
| + |
| + // Disable button lights when dozing |
| + if (state == Display.STATE_DOZE || state == Display.STATE_DOZE_SUSPEND) { |
| + mLights.getLight(LightsManager.LIGHT_ID_BUTTONS).setBrightness(PowerManager.BRIGHTNESS_OFF); |
| } |
| |
| // Configure auto-brightness. |
| diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java |
| index f84b20c..1ced53f 100644 |
| --- a/services/core/java/com/android/server/power/PowerManagerService.java |
| +++ b/services/core/java/com/android/server/power/PowerManagerService.java |
| @@ -220,6 +220,8 @@ public final class PowerManagerService extends SystemService |
| private static final int HALT_MODE_REBOOT = 1; |
| private static final int HALT_MODE_REBOOT_SAFE_MODE = 2; |
| |
| + private static final int BUTTON_ON_DURATION = 5 * 1000; |
| + |
| // File location for last reboot reason |
| private static final String LAST_REBOOT_LOCATION = "/data/misc/reboot/last_reboot_reason"; |
| |
| @@ -240,6 +242,7 @@ public final class PowerManagerService extends SystemService |
| private SettingsObserver mSettingsObserver; |
| private DreamManagerInternal mDreamManager; |
| private Light mAttentionLight; |
| + private Light mButtonsLight; |
| |
| private final Object mLock = LockGuard.installNewLock(LockGuard.INDEX_POWER); |
| |
| @@ -747,6 +750,7 @@ public final class PowerManagerService extends SystemService |
| |
| mLightsManager = getLocalService(LightsManager.class); |
| mAttentionLight = mLightsManager.getLight(LightsManager.LIGHT_ID_ATTENTION); |
| + mButtonsLight = mLightsManager.getLight(LightsManager.LIGHT_ID_BUTTONS); |
| |
| // Initialize display power management. |
| mDisplayManagerInternal.initPowerManagement( |
| @@ -1947,6 +1951,12 @@ public final class PowerManagerService extends SystemService |
| nextTimeout = mLastUserActivityTime |
| + screenOffTimeout - screenDimDuration; |
| if (now < nextTimeout) { |
| + if (now > mLastUserActivityTime + BUTTON_ON_DURATION) { |
| + mButtonsLight.setBrightness(0); |
| + } else { |
| + mButtonsLight.setBrightness(mDisplayPowerRequest.screenBrightness); |
| + nextTimeout = now + BUTTON_ON_DURATION; |
| + } |
| mUserActivitySummary = USER_ACTIVITY_SCREEN_BRIGHT; |
| } else { |
| nextTimeout = mLastUserActivityTime + screenOffTimeout; |
| -- |
| 2.7.4 |
| |