Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9888b73d authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Steve Kondik
Browse files

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
parent b5fe4463
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.display;
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;
@@ -124,6 +125,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;

@@ -262,6 +266,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;
@@ -595,6 +600,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.
+10 −0
Original line number Diff line number Diff line
@@ -159,6 +159,8 @@ public final class PowerManagerService extends SystemService
    // Default setting for double tap to wake.
    private static final int DEFAULT_DOUBLE_TAP_TO_WAKE = 0;

    private static final int BUTTON_ON_DURATION = 5 * 1000;

    private final Context mContext;
    private final ServiceThread mHandlerThread;
    private final PowerManagerHandler mHandler;
@@ -174,6 +176,7 @@ public final class PowerManagerService extends SystemService
    private SettingsObserver mSettingsObserver;
    private DreamManagerInternal mDreamManager;
    private Light mAttentionLight;
    private Light mButtonsLight;

    private final Object mLock = new Object();

@@ -543,6 +546,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(
@@ -1543,6 +1547,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;