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

Commit 2e750df0 authored by Emerson Pinter's avatar Emerson Pinter Committed by Gerrit Code Review
Browse files

Fix button backlights that depend on ALS.

On a few devices, lighting the buttons when the screen turns on
depends on the lightsensor, regardless of the user preference.
So go back to enabling the sensor whenever the screen turns on, and
enforce the user preference after running through the light settings
once.

Port from CM9.

Original: http://r.cyanogenmod.com/#/c/12818/

Change-Id: Ibb9155b4f299637d553986c44b9cb548dc855489
parent e072d5ca
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.WorkSource;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.EventLog;
import android.util.Log;
@@ -280,7 +281,7 @@ public class PowerManagerService extends IPowerManager.Stub
    private int mButtonBrightnessOverride = -1;
    private int mScreenBrightnessDim;
    private boolean mUseSoftwareAutoBrightness;
    private boolean mAutoBrightessEnabled;
    private boolean mAutoBrightessEnabled = true;
    private int[] mAutoBrightnessLevels;
    private int[] mLcdBacklightValues;
    private int[] mButtonBacklightValues;
@@ -1783,6 +1784,13 @@ public class PowerManagerService extends IPowerManager.Stub
                    // If AutoBrightness is enabled, set the brightness immediately after the
                    // next sensor value is received.
                    mWaitingForFirstLightSensor = mAutoBrightessEnabled;
                    if (!mAutoBrightessEnabled && SystemProperties.getBoolean(
                        "ro.hardware.respect_als", false)) {
                        /* Force a light sensor reset since we enabled it
                            when the screen came on */
                        mAutoBrightessEnabled = true;
                        setScreenBrightnessMode(Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
                    }
                } else {
                    // make sure button and key backlights are off too
                    mButtonLight.turnOff();