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

Commit 0b294a71 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Merge "[2/2] Framework: instant led test" into cm-11.0

parents ed21ef6e de97b257
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -560,6 +560,13 @@ public class Notification implements Parcelable
     */
    public static final String EXTRA_AS_HEADS_UP = "headsup";

    /**
     * Used by light picker in Settings to force
     * notification lights on when screen is on
     * @hide
     */
    public static final String EXTRA_FORCE_SHOW_LIGHTS = "android.forceShowLights";

    /**
     * Value for {@link #EXTRA_AS_HEADS_UP}.
     * @hide
+28 −3
Original line number Diff line number Diff line
@@ -1249,8 +1249,10 @@ public class NotificationManagerService extends INotificationManager.Stub
            } else if (action.equals(Intent.ACTION_USER_PRESENT)) {
                // turn off LED when user passes through lock screen
                if (!mDreaming) {
                    if (mLedNotification == null || !isLedNotificationForcedOn(mLedNotification)) {
                        mNotificationLight.turnOff();
                    }
                }
            } else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
                // reload per-user settings
                mSettingsObserver.update(null);
@@ -2368,6 +2370,16 @@ public class NotificationManagerService extends INotificationManager.Stub
        }
    }

    private boolean isLedNotificationForcedOn(NotificationRecord r) {
        if (r != null) {
            final Notification n = r.sbn.getNotification();
            if (n.extras != null) {
                return n.extras.getBoolean(Notification.EXTRA_FORCE_SHOW_LIGHTS, false);
            }
        }
        return false;
    }

    // lock on mNotificationList
    private void updateLightsLocked() {
        // handle notification lights
@@ -2384,8 +2396,21 @@ public class NotificationManagerService extends INotificationManager.Stub

        // Don't flash while we are in a call, screen is on or we are
        // in quiet hours with light dimmed
        if (mLedNotification == null || mInCall || (mScreenOn && !mDreaming)
                || (QuietHoursUtils.inQuietHours(mContext, Settings.System.QUIET_HOURS_DIM))) {
        // (unless Notification has EXTRA_FORCE_SHOW_LGHTS)
        final boolean enableLed;
        if (mLedNotification == null) {
            enableLed = false;
        } else if (isLedNotificationForcedOn(mLedNotification)) {
            enableLed = true;
        } else if (mInCall || (mScreenOn && !mDreaming)) {
            enableLed = false;
        } else if (QuietHoursUtils.inQuietHours(mContext, Settings.System.QUIET_HOURS_DIM)) {
            enableLed = false;
        } else {
            enableLed = true;
        }

        if (!enableLed) {
            mNotificationLight.turnOff();
        } else if (mNotificationPulseEnabled) {
            final Notification ledno = mLedNotification.sbn.getNotification();