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

Skip to content
Unverified Commit 9c143302 authored by Sam Mortimer's avatar Sam Mortimer Committed by Michael Bestas
Browse files

frameworks/base: Battery and Notification Lights

A reworked implementation based on code in the
commits listed further below.

Key changes from the original implementation:

*) Settings observation and most lineage lights
   feature specific code has been moved to the
   lineage-sdk.

*) Battery and notification frameworks services
   call out to the sdk to allow our features
   to make changes to lights values.

Original commits:

Author: DvTonder <david.vantonder@gmail.com>
Date:   Sun Jul 15 10:28:15 2012 -0400

    Framework: Port CM9 features to CM10

    This commit includes:
     - Power menu Reboot
     - Power menu screenshot
     - Profiles
     - Lock screen Calendar
     - Lock screen Weather
     - Notification light customization
     - Battery light customization
     - IME Selector notification toggle
     - and a few more things to support Settings

    Change-Id: Ibd63116df90b06f6ce6adb8a0343059bbb999bfb

Author: Pawit Pornkitprasan <p.pawit@gmail.com>
Date:   Sun Dec 8 15:24:41 2013 +0700

    BatteryService: fix FC on boot until battery stat is present

    updateLightsLocked() can be called from CM's added SettingsObserver
    when battery stat is not present, causing an FC and a loop until
    battery stat is present.

    I/SystemServer(  502): Battery Service
    E/System  (  502): ******************************************
    E/System  (  502): ************ Failure starting core service
    E/System  (  502): java.lang.NullPointerException
    E/System  (  502):      at com.android.server.BatteryService$Led.updateLightsLocked(BatteryService.java:735)
    E/System  (  502):      at com.android.server.BatteryService.updateLedPulse(BatteryService.java:709)
    E/System  (  502):      at com.android.server.BatteryService.access$1600(BatteryService.java:86)
    E/System  (  502):      at com.android.server.BatteryService$SettingsObserver.update(BatteryService.java:860)
    E/System  (  502):      at com.android.server.BatteryService$SettingsObserver.observe(BatteryService.java:822)
    E/System  (  502):      at com.android.server.BatteryService.<init>(BatteryService.java:187)
    E/System  (  502):      at com.android.server.ServerThread.initAndLoop(SystemServer.java:328)
    E/System  (  502):      at com.android.server.SystemServer.main(SystemServer.java:1309)
    E/System  (  502):      at java.lang.reflect.Method.invokeNative(Native Method)
    E/System  (  502):      at java.lang.reflect.Method.invoke(Method.java:515)
    E/System  (  502):      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:781)
    E/System  (  502):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    E/System  (  502):      at dalvik.system.NativeStart.main(Native Method)

    Change-Id: Ic4438fe50e98f1aa05ae1d0d26240bf9410fd92f

Author: Sam Mortimer <sam@mortimer.me.uk>
Date:   Tue Dec 31 16:22:05 2013 -0800

    [2/2] Framework: instant led test

    Adds support a new notification extra boolean
    EXTRA_FORCE_SHOW_LIGHTS.  Used by settings
    notification light picker to force lights on
    when the screen is on.

    Change-Id: If0a42d32b28fe8c02ef5f7dd148db7eb478fac17

Author: Michael Bestas <mikeioannina@gmail.com>
Date:   Mon Aug 18 04:56:28 2014 +0300

    Add support for single color notification LED (1/2)

    Change-Id: I367af77036da9e87c6dd0df552ce4c56d945a44d

Author: Danesh M <daneshm90@gmail.com>
Date:   Thu Nov 12 10:52:11 2015 -0800

    Framework : Move System settings to CMSettings

    Change-Id: I4e9fb06db7b9ba05e4a7bbe11916bb2271af4727

Author: Adnan Begovic <adnan@cyngn.com>
Date:   Mon Nov 9 16:26:00 2015 -0800

    fw: Move battery light settings to CMSettings.

    Change-Id: I28e60473356b2a9af152df82d34ad7abc9918682

Author: Steve Kondik <steve@cyngn.com>
Date:   Thu Sep 24 11:27:59 2015 -0700

    lights: Automatically generate an LED color for notifications

     * When an app doesn't specify a color for the LED, as is the usual
       case, we currently just show the default color. This is boring.
       It's also a pain in the ass to manually map all your apps to
       colors.
     * Use our new helpers to generate this color based on the application's
       icon color. Keep a cache to avoid wasting cycles.

    Change-Id: I7288e52499819a6a6c75ed9d9ba7cfa1b13c5669

Author: Steve Kondik <steve@cyngn.com>
Date:   Mon May 2 13:08:35 2016 -0700

    nms: Only generate LED colors if the device has a multicolored LED

     * Check the overlay value before doing any of this stuff.

    Change-Id: Iedfceba6bfc86b2761d8af57ecab51026bfa4c19

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: I21d424433bb52a17eea7974c4ea29a3a16fe1be5

Author: AdrianDC <radian.dc@gmail.com>
Date:   Sat Jul 18 12:20:51 2015 +0200

    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>

Author: Altaf-Mahdi <altaf.mahdi@gmail.com>
Date:   Mon Aug 31 22:51:09 2015 +0100

    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>

Author: Michael W <baddaemon87@gmail.com>
Date:   Mon Oct 9 22:04:00 2017 +0200

    Core: Battery warning levels are inclusive, not exclusive

    Change-Id: Ib35b154b6117f7e26b4a3a5aee9254dda3adda12

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: Sam Mortimer <sam@mortimer.me.uk>
Date:   Tue Nov 21 23:18:16 2017 -0800

    frameworks/base: Improve interface to LineageNotificationLights

    Change-Id: I43af52dd236e802d232a4cf96ccd6f69af6b26b7

Author: Sam Mortimer <sam@mortimer.me.uk>
Date:   Wed Dec 13 11:54:23 2017 -0800

    frameworks/base: prevent lights service calls when battery led does not exist

    Change-Id: I9eefff1f587c978c0aa2b31d03e664dc7ccf42de

Author: Sam Mortimer <sam@mortimer.me.uk>
Date:   Fri Feb 9 14:04:35 2018 -0800

    frameworks/base: disable warning about mLineageBatteryLights not being ready

    Change-Id: I96852f83a739924ac47260de511ddbea81465c52

Author: Luca Stefani <luca.stefani.ge1@gmail.com>
Date:   Sat Jul 14 10:34:53 2018 -0700

    fw/b lights: Allow black notification color

    * Color 0 is used to mean "lineage-sdk should pick a default"

    * Explictly requesting black made the led blue (eg lineageparts light picker), fix that

    Change-Id: Ia03f898c1b6cd0f77af8bb155139b587664f47af

Author: Sam Mortimer <sam@mortimer.me.uk>
Date:   Fri Feb 16 00:51:38 2018 -0800

    frameworks/base lights: Let Lineage lights decide if notification led is on/off

    *) Allows us to cater for the case where the notification led is turned off
       and yet the user wants to adjust battery light settings (which requires
       posting led notifications to illustrate the change).

    Change-Id: Iea52feb907f99ecf7925aff1fc1baf008642f7d7

Author: Sam Mortimer <sam@mortimer.me.uk>
Date:   Sat Feb 10 22:33:51 2018 -0800

    frameworks/base lights: Always allow LineageNotificationLights set the default color

    *) Oreo sdk onwards deprecates notification DEFAULT_LIGHTS.  However,
       LineageNotificationLights currently uses this flag to determine
       if we should generate an app specific color.
    *) Use a light color of 0 to indicate that the app (or channel) has not
       set an explicit preference and that lineage lights should set a
       default.

    Change-Id: I1f655aa17cb97c5a042a424ad1e8bd9d5ddec9a2

Author: Alexander Martinz <amartinz@shiftphones.com>
Date:   Tue Mar 19 19:06:11 2019 +0100

    NotificationManagerService: do not use flashing API for staying always on

    We allow to let the user set, that the notification light should stay
    always on instead of flashing.

    For that we are setting on duration to 1 and off duration to 0.
    This can confuse some light HALs and/or kernel drivers.

    Instead of using setFlashing, use setColor if duration is 1:0, like
    we are already using for battery lights.

    Change-Id: I4953592c72e0d095178757211dce2e206d8adb3c
Signed-off-by: Alexander Martinz's avatarAlexander Martinz <amartinz@shiftphones.com>

Author: Adrian DC <radian.dc@gmail.com>
Date:   Fri Aug 14 12:07:13 2020 +0200

    fw/b: Resolve black forced lights with notifications channels

     * The initial fix for blue lights upon 0x00000000 color selection
       in the settings by change Ia03f898c1b6cd0f77af8bb155139b587664f47af
       (fw/b lights: Allow black notification color) no longer works
       because the notification now uses channels, hence bypassing
       the "mPreChannelsNotification" checks used in this condition

     * Instead, validate the lights is forced on and black
       before calling the Lineage lights colors calculation

    Change-Id: Iafac2c51878d84afd980b378b1c53f6c31073d2c

Change-Id: I564fdb6ca6c5bbcf890afa4b9a2f9fa7bf8b9604
parent 195e966c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment