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

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

Lights with Screen On [1/2]: Optional allowment of lights

Implement a setting allowing lights to be activated
for new notifications even if the screen is on.

Lights with screen on and Custom values are separated
in an advanced section for a cleaner overview.

This setting gives the user an oportunity to activate lights
with the screen on and also during DayDream screensaver.
The option is not activated by default.

Changes include :
  frameworks/base
  packages/Apps/Settings

Screenshot of the Settings :
  http://i1285.photobucket.com/albums/a583/adriandc/Screenshot_2015-07-20-23-47-13_zpstpmemwwn.png~original



Change-Id: I2071147d8ddab80ba0e1e7310e785ac3e03b3c7c
Signed-off-by: default avatarAdrianDC <radian.dc@gmail.com>

Lights with screen on: Don't disable leds after the lockscreen

- If lights with screen on is enabled, do not disable leds
  when user passes through the lockscreen.

Change-Id: If8f5b867a34be09fb061bb7ad040b16730f4e263
Signed-off-by: default avatarAdrianDC <radian.dc@gmail.com>
parent 23681cb2
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -3330,6 +3330,14 @@ public final class Settings {
        /** @hide */
        public static final Validator SHOW_WEB_SUGGESTIONS_VALIDATOR = sBooleanValidator;

        /**
         * Whether to allow notifications with the screen on or DayDreams.
         * The value is boolean (1 or 0). Default will always be false.
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_SCREEN_ON =
                "notification_light_screen_on_enable";

        /**
         * Whether the notification LED should repeatedly flash when a notification is
         * pending. The value is boolean (1 or 0).
@@ -3733,7 +3741,8 @@ public final class Settings {
            RINGTONE,
            LOCK_TO_APP_ENABLED,
            NOTIFICATION_SOUND,
            ACCELEROMETER_ROTATION
            ACCELEROMETER_ROTATION,
            NOTIFICATION_LIGHT_SCREEN_ON
        };

        /**
+20 −4
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 The Android Open Source Project
 * Copyright (C) 2015 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -247,6 +248,9 @@ public class NotificationManagerService extends SystemService {
    private int mDefaultNotificationLedOff;
    private long[] mDefaultVibrationPattern;

    private boolean mScreenOnEnabled = false;
    private boolean mScreenOnDefault = false;

    private long[] mFallbackVibrationPattern;
    private boolean mUseAttentionLight;
    boolean mSystemReady;
@@ -800,10 +804,14 @@ public class NotificationManagerService extends SystemService {
                }
            } else if (action.equals(Intent.ACTION_USER_PRESENT)) {
                // turn off LED when user passes through lock screen
                // if lights with screen on is disabled.
                if (!mScreenOnEnabled) {
                    mNotificationLight.turnOff();

                    if (mStatusBar != null) {
                        mStatusBar.notificationLightOff();
                    }
                }
            } else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
                final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
                // reload per-user settings
@@ -864,6 +872,9 @@ public class NotificationManagerService extends SystemService {
                    false, this, UserHandle.USER_ALL);
            resolver.registerContentObserver(NOTIFICATION_RATE_LIMIT_URI,
                    false, this, UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.NOTIFICATION_LIGHT_SCREEN_ON),
                    false, this, UserHandle.USER_ALL);
            update(null);
        }

@@ -907,6 +918,11 @@ public class NotificationManagerService extends SystemService {
                            Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE, mMaxPackageEnqueueRate);
            }

            // Notification lights with screen on
            mScreenOnEnabled = (Settings.System.getIntForUser(resolver,
                    Settings.System.NOTIFICATION_LIGHT_SCREEN_ON,
                    mScreenOnDefault ? 1 : 0, UserHandle.USER_CURRENT) != 0);

            updateNotificationPulse();
        }
    }
@@ -3651,7 +3667,7 @@ public class NotificationManagerService extends SystemService {
            enableLed = false;
        } else if (isLedNotificationForcedOn(ledNotification)) {
            enableLed = true;
        } else if (mInCall || mScreenOn) {
        } else if (!mScreenOnEnabled && (mInCall || mScreenOn)) {
            enableLed = false;
        } else {
            enableLed = true;