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

Commit 82029067 authored by Adrian DC's avatar Adrian DC Committed by Michael Bestas
Browse files

frameworks/base: Lights notifications brightness support



Implement the support of an overall brightness control for the LEDs.

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
  packages/Apps/Settings

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

Author: Adnan Begovic <adnan@cyngn.com>
Date:   Mon, 9 Nov 2015 16:26:00 -0800
fw: Move battery light settings to CMSettings.
Change-Id: I28e60473356b2a9af152df82d34ad7abc9918682

Author: Adrian DC <radian.dc@gmail.com>
Date:   Sat Oct 14 23:08:47 2017 +0200
fw: Rebrand to LineageOS and cleanup for Android Oreo
Change-Id: I845f866891386aee808a4e7e80f4ab7c3ad48830

Author: Gabriele M <moto.falcon.git@gmail.com>
Date:   Mon, 31 Aug 2015 19:38:16 +0100
Let liblights adjust the brightness of LEDs while previewing it
Each device might use the information about the brightness of LEDs
in a unique way. Currently the slider to adjust the brightness of
LEDs is using an already scaled RGB color to preview the intensity
of the light. Instead of doing this, use a white colored light and
add to it the information about the brightness.
Change-Id: I4dd35944debc744ea6c7f1fcc5dd7a909e8863fa

Author: AdrianDC <radian.dc@gmail.com>
Date:   Wed, 11 Nov 2015 21:06:22 +0100
LEDs Brightness: Update the slider for M
 * Add notification details needed for M
 * Sync with some changes made in the Display Brightness dialog
 * Clean ic_settings indents with Settings ic_settings_24dp.xml
Change-Id: I8b6ac1920704f43f4776cbd3bdfb3d0ed8d223dc
Signed-off-by: default avatarAdrianDC <radian.dc@gmail.com>

Change-Id: I1c0de01b1c6a2a2cf1432028a2e69f90b2373b2c
parent 2eb61d88
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1134,9 +1134,11 @@ public final class BatteryService extends SystemService {
            if (!ledValues.isEnabled()) {
                mBatteryLight.turnOff();
            } else if (ledValues.isPulsed()) {
                mBatteryLight.setModes(ledValues.getBrightness());
                mBatteryLight.setFlashing(ledValues.getColor(), Light.LIGHT_FLASH_TIMED,
                        ledValues.getOnMs(), ledValues.getOffMs());
            } else {
                mBatteryLight.setModes(ledValues.getBrightness());
                mBatteryLight.setColor(ledValues.getColor());
            }
        }
+2 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 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.
@@ -51,6 +52,7 @@ public abstract class Light {

    public abstract void setColor(int color);
    public abstract void setFlashing(int color, int mode, int onMS, int offMS);
    public abstract void setModes(int brightnessLevel);
    public abstract void pulse();
    public abstract void pulse(int color, int onMS);
    public abstract void turnOff();
+17 −3
Original line number Diff line number Diff line
/* * Copyright (C) 2008 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.
@@ -108,6 +109,14 @@ public class LightsService extends SystemService {
            }
        }

        @Override
        public void setModes(int brightnessLevel) {
            synchronized (this) {
                mBrightnessLevel = brightnessLevel;
                mModesUpdate = true;
            }
        }

        @Override
        public void pulse() {
            pulse(0x00ffffff, 7);
@@ -166,7 +175,7 @@ public class LightsService extends SystemService {
            }

            if (!mInitialized || color != mColor || mode != mMode || onMS != mOnMS ||
                    offMS != mOffMS || mBrightnessMode != brightnessMode) {
                    offMS != mOffMS || mBrightnessMode != brightnessMode || mModesUpdate) {
                if (DEBUG) Slog.v(TAG, "setLight #" + mId + ": color=#"
                        + Integer.toHexString(color) + ": brightnessMode=" + brightnessMode);
                mInitialized = true;
@@ -176,10 +185,12 @@ public class LightsService extends SystemService {
                mOnMS = onMS;
                mOffMS = offMS;
                mBrightnessMode = brightnessMode;
                mModesUpdate = false;
                Trace.traceBegin(Trace.TRACE_TAG_POWER, "setLight(" + mId + ", 0x"
                        + Integer.toHexString(color) + ")");
                try {
                    setLight_native(mId, color, mode, onMS, offMS, brightnessMode);
                    setLight_native(mId, color, mode, onMS, offMS,
                            brightnessMode, mBrightnessLevel);
                } finally {
                    Trace.traceEnd(Trace.TRACE_TAG_POWER);
                }
@@ -195,6 +206,7 @@ public class LightsService extends SystemService {
        private int mMode;
        private int mOnMS;
        private int mOffMS;
        private int mBrightnessLevel;
        private boolean mFlashing;
        private int mBrightnessMode;
        private int mLastBrightnessMode;
@@ -202,6 +214,8 @@ public class LightsService extends SystemService {
        private boolean mVrModeEnabled;
        private boolean mUseLowPersistenceForVR;
        private boolean mInitialized;
        private boolean mLocked;
        private boolean mModesUpdate;
    }

    public LightsService(Context context) {
@@ -249,5 +263,5 @@ public class LightsService extends SystemService {
    };

    static native void setLight_native(int light, int color, int mode,
            int onMS, int offMS, int brightnessMode);
            int onMS, int offMS, int brightnessMode, int brightnessLevel);
}
+1 −0
Original line number Diff line number Diff line
@@ -7114,6 +7114,7 @@ public class NotificationManagerService extends SystemService {
        if (!ledValues.isEnabled()) {
            mNotificationLight.turnOff();
        } else {
            mNotificationLight.setModes(ledValues.getBrightness());
            mNotificationLight.setFlashing(ledValues.getColor(), Light.LIGHT_FLASH_TIMED,
                    ledValues.getOnMs(), ledValues.getOffMs());
        }
+13 −2
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 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.
@@ -131,7 +132,8 @@ static void setLight_native(
        jint flashMode,
        jint onMS,
        jint offMS,
        jint brightnessMode) {
        jint brightnessMode,
        jint brightnessLevel) {

    if (!sLightSupported) {
        return;
@@ -141,6 +143,15 @@ static void setLight_native(
        return;
    }

    if (brightnessLevel > 0 && brightnessLevel <= 0xFF) {
        int colorAlpha = (colorARGB & 0xFF000000) >> 24;
        if (colorAlpha == 0x00) {
            colorAlpha = 0xFF;
        }
        colorAlpha = (colorAlpha * brightnessLevel) / 0xFF;
        colorARGB = (colorAlpha << 24) + (colorARGB & 0x00FFFFFF);
    }

    Type type = static_cast<Type>(light);
    LightState state = constructState(
        colorARGB, flashMode, onMS, offMS, brightnessMode);
@@ -159,7 +170,7 @@ static void setLight_native(
}

static const JNINativeMethod method_table[] = {
    { "setLight_native", "(IIIIII)V", (void*)setLight_native },
    { "setLight_native", "(IIIIIII)V", (void*)setLight_native },
};

int register_android_server_LightsService(JNIEnv *env) {