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

Commit 5ee3f9b9 authored by Mike Kasick's avatar Mike Kasick
Browse files

Fixes to ensure keyboard backlight is lit when the keyboard is visible.

- Ignore mKeyboardVisible in PowerManagerService::applyKeyboardState if
  KEYBOARD_BRIGHT_BIT is already set in mPowerState.  Previously, if the
  keyboard were to hide after setting mPowerState, but before running
  applyKeyboardState, then the keyboard backlight would remain off at the
  next slide event since mPowerState is unchanged.

- Always set mLightSensorKeyboardBrightness in
  PowerManagerService::lightSensorChangedLocked to a sensor-based value,
  instead of 0 when the keyboard is hidden.  This ensures
  mLightSensorKeyboardBrightness is sensible on slide events since it may
  not be recomputed timely.
parent 3347c890
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -1825,7 +1825,7 @@ public class PowerManagerService extends IPowerManager.Stub
            }

            if (!mBootCompleted && !mAutoBrightnessButtonKeyboard) {
                newState |= ALL_BRIGHT;
                newState |= (mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT);
            }

            boolean oldScreenOn = (mPowerState & SCREEN_ON_BIT) != 0;
@@ -2422,7 +2422,11 @@ public class PowerManagerService extends IPowerManager.Stub
            // do not override brightness if the battery is low
            return state;
        }
        if (!mKeyboardVisible) {
        // Ignore mKeyboardVisible if KEYBOARD_BRIGHT_BIT is explicitly set, which
        // it will only if the keyboard is visible at the time mPowerState is set.
        // Otherwise, if mKeyboardVisible changes afterwards, it's possible for
        // the backlight to mismatch mPowerState and remain off.
        if (!mKeyboardVisible && (state & KEYBOARD_BRIGHT_BIT) == 0) {
            brightness = 0;
        } else if (mButtonBrightnessOverride >= 0) {
            brightness = mButtonBrightnessOverride;
@@ -2817,14 +2821,10 @@ public class PowerManagerService extends IPowerManager.Stub
                int buttonValue = getAutoBrightnessValue(value, mLastButtonValue,
                        (mCustomLightEnabled ? mCustomLightLevels : mAutoBrightnessLevels),
                        (mCustomLightEnabled ? mCustomButtonValues : mButtonBacklightValues));
                int keyboardValue;
                if (mKeyboardVisible) {
                    keyboardValue = getAutoBrightnessValue(value, mLastKeyboardValue,
                int keyboardValue = getAutoBrightnessValue(value, mLastKeyboardValue,
                            (mCustomLightEnabled ? mCustomLightLevels : mAutoBrightnessLevels),
                            (mCustomLightEnabled ? mCustomKeyboardValues : mKeyboardBacklightValues));
                } else {
                    keyboardValue = 0;
                }

                mLightSensorScreenBrightness = lcdValue;
                mLightSensorButtonBrightness = buttonValue;
                mLightSensorKeyboardBrightness = keyboardValue;
@@ -3327,7 +3327,7 @@ public class PowerManagerService extends IPowerManager.Stub
            setPowerState(SCREEN_BRIGHT);
        } else {
            // turn everything on
            setPowerState(ALL_BRIGHT);
            setPowerState(mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT);
        }

        synchronized (mLocks) {