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

Commit 337acef1 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Sam Mortimer
Browse files

fw/b: Button backlight brightness

Squash of:

Author: Ricardo Cerqueira <cyanogenmod@cerqueira.org>
Date:   Fri Nov 23 14:23:16 2012 +0000

    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

    Change-Id: I6094c446e0b8c23f57d30652a3cbd35dee5e821a

Author: Danny Baumann <dannybaumann@web.de>
Date:   Thu Aug 22 08:53:24 2013 +0200

    Add PowerManager integration for button and keyboard backlight.

    Allows setting button and keyboard backlight brightness as well as
    button timeout.

    Change-Id: I550cccafc0a8f90d6347de9261adb26b75955cc4

Author: Steve Kondik <steve@cyngn.com>
Date:   Sat Jan 3 05:13:26 2015 -0800

    power: Disable keyboard/button lights while dozing/dreaming

     * With hardkeys and doze mode enabled, entering suspend results in
       an epic battle over the lights. It's a bad situation. Disable
       them when we're sleepy.

    Change-Id: I7f1fc35a1573717d1ea101a07c4171d6f66d1553

Author: nadlabak <pavel@doshaska.net>
Date:   Sun Jun 7 02:01:05 2015 +0200

    PowerManagerService: Fix updating of mUserActivitySummary

    I7f1fc35a1573717d1ea101a07c4171d6f66d1553 missed the fact that the primary
    purpose of the affected condition block was to update mUserActivitySummary
    and the button/keyboard light handling was just appended to it later.

    This fixes the waking from dream/screensaver by user activity.

    I30c5c8c9c09e3d57ace18cac72b783510b9b3bf3 is removed here as well as it was
    just a band aid.

    jira: NIGHTLIES-1285

    Change-Id: I6b2f6c58e73110787d62e86d4d2ef538638cf491

Author: Bruno Martins <bgcngm@gmail.com>
Date:   Tue Dec 26 17:15:05 2017 +0000

    Forward-port button brightness implementation to O

     * Reworked for the new handler interface, restoring also removed
       methods (partial revert of commit 86c39f9e).

     * Keyboard backlight brightness support left out for now.

    Change-Id: I53f031fa2da394e95a2b29a01eb3c6a8f8132507

Change-Id: I5176a2028c18408c17bac7f25e62b5612fd6c227
parent 37fd15d8
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -918,6 +918,15 @@ public final class PowerManager {
                com.android.internal.R.integer.config_screenBrightnessForVrSettingDefault);
                com.android.internal.R.integer.config_screenBrightnessForVrSettingDefault);
    }
    }


    /**
     * Gets the default button brightness value.
     * @hide
     */
    public int getDefaultButtonBrightness() {
        return mContext.getResources().getInteger(
                com.android.internal.R.integer.config_buttonBrightnessSettingDefault);
    }

    /**
    /**
     * Creates a new wake lock with the specified level and flags.
     * Creates a new wake lock with the specified level and flags.
     * <p>
     * <p>
+10 −0
Original line number Original line Diff line number Diff line
@@ -106,6 +106,16 @@ public abstract class PowerManagerInternal {
     */
     */
    public abstract void setScreenBrightnessOverrideFromWindowManager(int brightness);
    public abstract void setScreenBrightnessOverrideFromWindowManager(int brightness);


    /**
     * Used by the window manager to override the button brightness based on the
     * current foreground activity.
     *
     * This method must only be called by the window manager.
     *
     * @param brightness The overridden brightness, or -1 to disable the override.
     */
    public abstract void setButtonBrightnessOverrideFromWindowManager(int brightness);

    /**
    /**
     * Used by the window manager to override the user activity timeout based on the
     * Used by the window manager to override the user activity timeout based on the
     * current foreground activity.  It can only be used to make the timeout shorter
     * current foreground activity.  It can only be used to make the timeout shorter
+21 −0
Original line number Original line Diff line number Diff line
<!--
     Copyright (C) 2012-2015 The CyanogenMod Project
     Copyright (C) 2017 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources>
    <!-- Button backlight -->
    <integer name="config_buttonBrightnessSettingDefault">255</integer>
    <bool name="config_deviceHasVariableButtonBrightness">false</bool>
</resources>
+4 −0
Original line number Original line Diff line number Diff line
@@ -19,4 +19,8 @@
    <java-symbol type="string" name="adb_net_active_notification_title" />
    <java-symbol type="string" name="adb_net_active_notification_title" />
    <java-symbol type="string" name="adb_both_active_notification_title" />
    <java-symbol type="string" name="adb_both_active_notification_title" />
    <java-symbol type="string" name="adb_active_generic_notification_message" />
    <java-symbol type="string" name="adb_active_generic_notification_message" />

    <!-- Button backlight -->
    <java-symbol type="integer" name="config_buttonBrightnessSettingDefault" />
    <java-symbol type="bool" name="config_deviceHasVariableButtonBrightness" />
</resources>
</resources>
+12 −0
Original line number Original line Diff line number Diff line
@@ -59,6 +59,7 @@ import com.android.server.am.BatteryStatsService;
import com.android.server.display.whitebalance.DisplayWhiteBalanceController;
import com.android.server.display.whitebalance.DisplayWhiteBalanceController;
import com.android.server.display.whitebalance.DisplayWhiteBalanceFactory;
import com.android.server.display.whitebalance.DisplayWhiteBalanceFactory;
import com.android.server.display.whitebalance.DisplayWhiteBalanceSettings;
import com.android.server.display.whitebalance.DisplayWhiteBalanceSettings;
import com.android.server.lights.LightsManager;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.policy.WindowManagerPolicy;


import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -150,6 +151,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    // Battery stats.
    // Battery stats.
    private final IBatteryStats mBatteryStats;
    private final IBatteryStats mBatteryStats;


    // The lights service.
    private final LightsManager mLights;

    // The sensor manager.
    // The sensor manager.
    private final SensorManager mSensorManager;
    private final SensorManager mSensorManager;


@@ -396,6 +400,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        mCallbacks = callbacks;
        mCallbacks = callbacks;


        mBatteryStats = BatteryStatsService.getService();
        mBatteryStats = BatteryStatsService.getService();
        mLights = LocalServices.getService(LightsManager.class);
        mSensorManager = sensorManager;
        mSensorManager = sensorManager;
        mWindowManagerPolicy = LocalServices.getService(WindowManagerPolicy.class);
        mWindowManagerPolicy = LocalServices.getService(WindowManagerPolicy.class);
        mBlanker = blanker;
        mBlanker = blanker;
@@ -850,6 +855,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        if (state == Display.STATE_OFF) {
        if (state == Display.STATE_OFF) {
            brightness = PowerManager.BRIGHTNESS_OFF;
            brightness = PowerManager.BRIGHTNESS_OFF;
            mBrightnessReasonTemp.setReason(BrightnessReason.REASON_SCREEN_OFF);
            mBrightnessReasonTemp.setReason(BrightnessReason.REASON_SCREEN_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);
        }
        }


        // Always use the VR brightness when in the VR state.
        // Always use the VR brightness when in the VR state.
Loading