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

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

Multiple LEDs [3/3]: Illumination Bars support



Implement the support of a multiple LEDs settings.

The setting is deactivated by default
and will be ignored by the unimplemented phones.
Current LibLights will simply not use the new variable.

Changes includes :
  frameworks/base
  hardware/libhardware
  packages/Apps/Settings

Change-Id: Ie8712c13e43f823996f10ca83b4a9f95fb750e96
Signed-off-by: default avatarAdrianDC <radian.dc@gmail.com>
parent 1f6bec27
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
    <java-symbol type="bool" name="config_multiColorNotificationLed" />
    <java-symbol type="bool" name="config_intrusiveBatteryLed" />
    <java-symbol type="bool" name="config_multiColorBatteryLed" />
    <java-symbol type="bool" name="config_multipleNotificationLeds" />
    <java-symbol type="array" name="notification_light_package_mapping" />
    <java-symbol type="array" name="config_notificationNoAlertsVibePattern" />

+4 −0
Original line number Diff line number Diff line
@@ -946,6 +946,10 @@
         Used to decide if the user can change the colors -->
    <bool name="config_multiColorBatteryLed">false</bool>

    <!-- Does the device have multiple LEDs ?
         Used to decide if the user can change the multiple LEDs settings -->
    <bool name="config_multipleNotificationLeds">false</bool>

    <!-- Do the battery/notification LEDs support pulsing?
         Used to decide if we show pulse settings -->
    <bool name="config_ledCanPulse">true</bool>
+4 −0
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@
         on devices equiped with configurable LED controller -->
    <integer name="def_notification_brightness_level">255</integer>

    <!-- Default value for whether or not to use multiple notification LEDs
         on devices equiped with more than one LED -->
    <bool name="def_notification_multiple_leds">false</bool>

    <bool name="def_mount_play_notification_snd">true</bool>
    <bool name="def_mount_ums_autostart">false</bool>
    <bool name="def_mount_ums_prompt">true</bool>
+25 −2
Original line number Diff line number Diff line
@@ -137,6 +137,9 @@ public final class BatteryService extends SystemService {
    private boolean mAdjustableNotificationLedBrightness;
    private int mNotificationLedBrightnessLevel = LIGHT_BRIGHTNESS_MAXIMUM;

    private boolean mMultipleNotificationLeds;
    private boolean mMultipleLedsEnabled = false;

    private int mLowBatteryWarningLevel;
    private int mLowBatteryCloseWarningLevel;
    private int mShutdownBatteryTemperature;
@@ -833,6 +836,10 @@ public final class BatteryService extends SystemService {
            mAdjustableNotificationLedBrightness = context.getResources().getBoolean(
                    com.android.internal.R.bool.config_adjustableNotificationLedBrightness);

            // Does the Device have multiple LEDs ?
            mMultipleNotificationLeds = context.getResources().getBoolean(
                    com.android.internal.R.bool.config_multipleNotificationLeds);

            mBatteryLedOn = context.getResources().getInteger(
                    com.android.internal.R.integer.config_notificationsBatteryLedOn);
            mBatteryLedOff = context.getResources().getInteger(
@@ -855,7 +862,8 @@ public final class BatteryService extends SystemService {
                // No lights if explicitly disabled
                mBatteryLight.turnOff();
            } else if (level < mLowBatteryWarningLevel) {
                mBatteryLight.setModes(mNotificationLedBrightnessLevel);
                mBatteryLight.setModes(mNotificationLedBrightnessLevel,
                        mMultipleLedsEnabled);
                if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
                    // Battery is charging and low
                    mBatteryLight.setColor(mBatteryLowARGB);
@@ -869,7 +877,8 @@ public final class BatteryService extends SystemService {
                }
            } else if (status == BatteryManager.BATTERY_STATUS_CHARGING
                    || status == BatteryManager.BATTERY_STATUS_FULL) {
                mBatteryLight.setModes(mNotificationLedBrightnessLevel);
                mBatteryLight.setModes(mNotificationLedBrightnessLevel,
                        mMultipleLedsEnabled);
                if (status == BatteryManager.BATTERY_STATUS_FULL || level >= 90) {
                    // Battery is full or charging and nearly full
                    mBatteryLight.setColor(mBatteryFullARGB);
@@ -975,6 +984,13 @@ public final class BatteryService extends SystemService {
                        false, this, UserHandle.USER_ALL);
            }

            // Multiple LEDs enabled
            if (mMultipleNotificationLeds) {
                resolver.registerContentObserver(Settings.System.getUriFor(
                        Settings.System.NOTIFICATION_LIGHT_MULTIPLE_LEDS_ENABLE),
                        false, this, UserHandle.USER_ALL);
            }

            // Light colors
            if (mMultiColorLed) {
                // Register observer if we have a multi color led
@@ -1026,6 +1042,13 @@ public final class BatteryService extends SystemService {
                        LIGHT_BRIGHTNESS_MAXIMUM);
            }

            // Multiple LEDs enabled
            if (mMultipleNotificationLeds) {
                mMultipleLedsEnabled = Settings.System.getInt(resolver,
                        Settings.System.NOTIFICATION_LIGHT_MULTIPLE_LEDS_ENABLE,
                        mMultipleNotificationLeds ? 1 : 0) != 0;
            }

            updateLedPulse();
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ public abstract class Light {
    public abstract void setBrightness(int brightness, int brightnessMode);
    public abstract void setColor(int color);
    public abstract void setFlashing(int color, int mode, int onMS, int offMS);
    public abstract void setModes(int brightnessLevel);
    public abstract void setModes(int brightnessLevel, boolean multipleLeds);
    public abstract void pulse();
    public abstract void pulse(int color, int onMS);
    public abstract void turnOff();
Loading