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

Commit 328e41af authored by AdrianDC's avatar AdrianDC Committed by Steve Kondik
Browse files

batteryservice: Use Alpha channel for segmented LED power level

 * Allows proper usage of the RGB color down the liblights layers,
    and custom liblights will implement the usage of alpha value

Change-Id: I40e2867051d5296f3045bcb85958c59793bc86cc
parent ca89e1b2
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -846,8 +846,8 @@ public final class BatteryService extends SystemService {
            mBatteryLedOff = context.getResources().getInteger(
                    com.android.internal.R.integer.config_notificationsBatteryLedOff);

            // Does a device have a segmented battery LED? In this case, we send the level
            // in the lower 8 bits of the color and let the HAL sort it out.
            // Does the Device have segmented battery LED support? In this case, we send the level
            // in the alpha channel of the color and let the HAL sort it out.
            mUseSegmentedBatteryLed = context.getResources().getBoolean(
                    org.cyanogenmod.platform.internal.R.bool.config_useSegmentedBatteryLed);
        }
@@ -864,14 +864,12 @@ public final class BatteryService extends SystemService {

            final int level = mBatteryProps.batteryLevel;
            final int status = mBatteryProps.batteryStatus;
            mNotificationLedBrightnessLevel = mUseSegmentedBatteryLed ? level :
                    LIGHT_BRIGHTNESS_MAXIMUM;

            if (!mLightEnabled) {
                // No lights if explicitly disabled
                mBatteryLight.turnOff();
            } else if (mUseSegmentedBatteryLed &&
                    (status == BatteryManager.BATTERY_STATUS_CHARGING
                    || status == BatteryManager.BATTERY_STATUS_FULL)) {
                mBatteryLight.setColor(level);
            } else if (level < mLowBatteryWarningLevel) {
                mBatteryLight.setModes(mNotificationLedBrightnessLevel,
                        mMultipleLedsEnabled);