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

Commit ae49dcd8 authored by ChainsDD's avatar ChainsDD
Browse files

Add ability to change the color of the breathing light based on a system setting.

The breathing light had to be changed to use the notification light instead of the attention light due to the fact that the attention light is set to only flash either white or blue in the new Google lib.
parent 05086acd
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1432,6 +1432,12 @@ public final class Settings {
         */
        public static final String NOTIFICATION_SCREEN_ON = "notification_screen_on";

        /**
         * Color to pulse the breathing light
         * @hide
         */
        public static final String BREATHING_LIGHT_COLOR = "breathing_light_color";

        /**
         * Whether to wake the screen with the trackball. The value is boolean (1 or 0).
         * @hide
+9 −2
Original line number Diff line number Diff line
@@ -303,7 +303,12 @@ public class HardwareService extends IHardwareService.Stub {
        }
    }

    // Overload this function to prevent possibly breaking anything.
    public void pulseBreathingLight() {
        pulseBreathingLight(0x00ffffff);
    }

    public void pulseBreathingLight(int color) {
        synchronized (this) {
            // HACK: Added at the last minute of cupcake -- design this better;
            // Don't reuse the attention light -- make another one.
@@ -313,7 +318,8 @@ public class HardwareService extends IHardwareService.Stub {
            }
            if (!mAttentionLightOn && !mPulsing) {
                mPulsing = true;
                setLight_native(mNativePointer, LIGHT_ID_ATTENTION, 0x00ffffff,
                // Use LIGHT_ID_NOTIFICATIONS to allow full color. LIGHT_ID_ATTENTION only allows white and blue
                setLight_native(mNativePointer, LIGHT_ID_NOTIFICATIONS, color,
                        LIGHT_FLASH_HARDWARE, 7, 0, 0);
                mH.sendMessageDelayed(Message.obtain(mH, 1), 2000);
            }
@@ -329,7 +335,8 @@ public class HardwareService extends IHardwareService.Stub {
                }
                if (mPulsing) {
                    mPulsing = false;
                    setLight_native(mNativePointer, LIGHT_ID_ATTENTION,
                    // Use LIGHT_ID_NOTIFICATIONS to allow full color. LIGHT_ID_ATTENTION only allows white and blue
                    setLight_native(mNativePointer, LIGHT_ID_NOTIFICATIONS,
                            mAttentionLightOn ? 0xffffffff : 0,
                            LIGHT_FLASH_NONE, 0, 0, 0);
                }
+6 −1
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ class NotificationManagerService extends INotificationManager.Stub
    private boolean mNotificationScreenOn;
    private boolean mNotificationPulseEnabled;
    private boolean mPulseBreathingLight;
    private int mBreathingLightColor;

    // for adb connected notifications
    private boolean mUsbConnected;
@@ -362,6 +363,8 @@ class NotificationManagerService extends INotificationManager.Stub
                    Settings.System.NOTIFICATION_LIGHT_PULSE), false, this);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.NOTIFICATION_SCREEN_ON), false, this);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.BREATHING_LIGHT_COLOR), false, this);
            update();
        }

@@ -389,6 +392,8 @@ class NotificationManagerService extends INotificationManager.Stub
                mNotificationScreenOn = screenOn;
                updateNotificationPulse();
            }
            mBreathingLightColor = Settings.System.getInt(resolver,
                    Settings.System.BREATHING_LIGHT_COLOR, 0x00ffffff);
        }
    }

@@ -1039,7 +1044,7 @@ class NotificationManagerService extends INotificationManager.Stub
        // we only flash if screen is off and persistent pulsing is enabled
        if (mLedNotification == null || (mScreenOn && !mNotificationScreenOn) || !mNotificationPulseEnabled) {
            if (mPulseBreathingLight) {
                mHardware.pulseBreathingLight();
                mHardware.pulseBreathingLight(mBreathingLightColor);
            } else {
                mHardware.setLightOff_UNCHECKED(HardwareService.LIGHT_ID_NOTIFICATIONS);
            }