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

Commit 1387635c 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 684bca11
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -3228,6 +3228,13 @@ public final class Settings {
        public static final String NOTIFICATION_LIGHT_BRIGHTNESS_LEVEL =
                "notification_light_brightness_level";

        /**
         * Whether to use the all the LEDs for the notifications or just one.
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_MULTIPLE_LEDS_ENABLE =
                "notification_light_multiple_leds_enable";

        /**
         * Whether to allow notifications with the screen on or DayDreams.
         * The value is boolean (1 or 0). Default will always be false.
@@ -4006,6 +4013,7 @@ public final class Settings {
            PHONE_BLACKLIST_UNKNOWN_NUMBER_MODE,
            PHONE_BLACKLIST_REGEX_ENABLED,
            NOTIFICATION_LIGHT_BRIGHTNESS_LEVEL,
            NOTIFICATION_LIGHT_MULTIPLE_LEDS_ENABLE,
            NOTIFICATION_LIGHT_SCREEN_ON
        };

+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,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
@@ -901,6 +901,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
@@ -70,6 +70,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;
@@ -757,6 +760,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(
@@ -807,7 +814,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);
@@ -821,7 +829,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);
@@ -930,6 +939,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
@@ -981,6 +997,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();
        }
    }
Loading