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

Commit 670f9328 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Implement Notification.DEFAULT_LIGHTS flag.



This flag was already in the public API but did not do anything until now.
We now use it so we can override the default notification LED color on a per device basis.

Change-Id: I0d6e239b7da2fdbeda9608d6d4de3e778aa88e2c
BUG: 2329568

Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 867e8eb7
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -164,6 +164,15 @@
    <!-- Close low battery warning when battery level reaches this value -->
    <integer name="config_lowBatteryCloseWarningLevel">20</integer>

    <!-- Default color for notification LED. -->
    <color name="config_defaultNotificationColor">#ff00ff00</color>

    <!-- Default LED on time for notification LED in milliseconds. -->
    <integer name="config_defaultNotificationLedOn">500</integer>

    <!-- Default LED off time for notification LED in milliseconds. -->
    <integer name="config_defaultNotificationLedOff">2000</integer>

    <!-- Allow the menu hard key to be disabled in LockScreen on some devices -->
    <bool name="config_disableMenuKeyInLockScreen">false</bool>

+7 −2
Original line number Diff line number Diff line
@@ -80,11 +80,16 @@ public class LightsService {
            }
        }


        public void pulse() {
            pulse(0x00ffffff, 7);
        }

        public void pulse(int color, int onMS) {
            synchronized (this) {
                if (mColor == 0 && !mFlashing) {
                    setLightLocked(0x00ffffff, LIGHT_FLASH_HARDWARE, 7, 0, BRIGHTNESS_MODE_USER);
                    mH.sendMessageDelayed(Message.obtain(mH, 1, this), 3000);
                    setLightLocked(color, LIGHT_FLASH_HARDWARE, onMS, 1000, BRIGHTNESS_MODE_USER);
                    mH.sendMessageDelayed(Message.obtain(mH, 1, this), onMS);
                }
            }
        }
+29 −6
Original line number Diff line number Diff line
@@ -91,6 +91,10 @@ class NotificationManagerService extends INotificationManager.Stub
    private LightsService.Light mNotificationLight;
    private LightsService.Light mAttentionLight;

    private int mDefaultNotificationColor;
    private int mDefaultNotificationLedOn;
    private int mDefaultNotificationLedOff;

    private NotificationRecord mSoundNotification;
    private AsyncPlayer mSound;
    private boolean mSystemReady;
@@ -398,6 +402,14 @@ class NotificationManagerService extends INotificationManager.Stub
        mNotificationLight = lights.getLight(LightsService.LIGHT_ID_NOTIFICATIONS);
        mAttentionLight = lights.getLight(LightsService.LIGHT_ID_ATTENTION);

        Resources resources = mContext.getResources();
        mDefaultNotificationColor = resources.getColor(
                com.android.internal.R.color.config_defaultNotificationColor);
        mDefaultNotificationLedOn = resources.getInteger(
                com.android.internal.R.integer.config_defaultNotificationLedOn);
        mDefaultNotificationLedOff = resources.getInteger(
                com.android.internal.R.integer.config_defaultNotificationLedOff);

        // Don't start allowing notifications until the setup wizard has run once.
        // After that, including subsequent boots, init with notifications turned on.
        // This works on the first boot because the setup wizard will toggle this
@@ -1024,14 +1036,25 @@ class NotificationManagerService extends INotificationManager.Stub
        }

        // we only flash if screen is off and persistent pulsing is enabled
        if (mLedNotification == null || mScreenOn || !mNotificationPulseEnabled) {
        if (mLedNotification == null || mScreenOn) {
            mNotificationLight.turnOff();
        } else {
            mNotificationLight.setFlashing(
                    mLedNotification.notification.ledARGB,
                    LightsService.LIGHT_FLASH_TIMED,
                    mLedNotification.notification.ledOnMS,
                    mLedNotification.notification.ledOffMS);
            int ledARGB = mLedNotification.notification.ledARGB;
            int ledOnMS = mLedNotification.notification.ledOnMS;
            int ledOffMS = mLedNotification.notification.ledOffMS;
            if ((mLedNotification.notification.defaults & Notification.DEFAULT_LIGHTS) != 0) {
                ledARGB = mDefaultNotificationColor;
                ledOnMS = mDefaultNotificationLedOn;
                ledOffMS = mDefaultNotificationLedOff;
            }
            if (mNotificationPulseEnabled) {
                // pulse repeatedly
                mNotificationLight.setFlashing(ledARGB, LightsService.LIGHT_FLASH_TIMED,
                        ledOnMS, ledOffMS);
            } else {
                // pulse only once
                mNotificationLight.pulse(ledARGB, ledOnMS);
            }
        }
    }