aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/src
diff options
context:
space:
mode:
authorSam Mortimer <sam@mortimer.me.uk>2018-05-26 18:02:55 -0700
committerSam Mortimer <sam@mortimer.me.uk>2018-06-05 20:26:52 +0200
commite703ff0a0b7d9b9b14781c0ae328f284857082e1 (patch)
tree7a5fa96d9160917423d11416f04fc7ec7f169f40 /sdk/src
parent506bef406ee210329f82dc1b4269bdd9e5266eed (diff)
downloadlineage-sdk-e703ff0a0b7d9b9b14781c0ae328f284857082e1.tar.gz
lineage-sdk-e703ff0a0b7d9b9b14781c0ae328f284857082e1.tar.bz2
lineage-sdk-e703ff0a0b7d9b9b14781c0ae328f284857082e1.zip
Add led capability LIGHTS_ADJUSTABLE_BATTERY_LED_BRIGHTNESS
*) Many existing liblights support notification brightness control via the alpha channel but do not support similar for the battery led. *) https://github.com/LineageOS/android_lineage-sdk/commit/8f7a4559ab4a81855f399eae32ebe4a3f531e8b2 introduced a dependency on light capability LIGHTS_ADJUSTABLE_BATTERY_LED_BRIGHTNESS such that, when set, it was assumed that the battery led brightness is also liblights adjustable. It turned out that this was not the case. *) Create a new capability to allow devices to distinguish whether their liblights supports adjustable brightness control for notification and battery leds independently of one another. *) Document how brightness support works in LightsCapabilities. *) Copy LightsCapabilities comments to the default lights config to raise visibility. Change-Id: Id95905f07128c78c6acacf3b60d71bb37f70bcfb
Diffstat (limited to 'sdk/src')
-rw-r--r--sdk/src/java/org/lineageos/internal/notification/LightsCapabilities.java15
-rw-r--r--sdk/src/java/org/lineageos/internal/notification/LineageBatteryLights.java2
2 files changed, 15 insertions, 2 deletions
diff --git a/sdk/src/java/org/lineageos/internal/notification/LightsCapabilities.java b/sdk/src/java/org/lineageos/internal/notification/LightsCapabilities.java
index a1ee26a6..81815ae1 100644
--- a/sdk/src/java/org/lineageos/internal/notification/LightsCapabilities.java
+++ b/sdk/src/java/org/lineageos/internal/notification/LightsCapabilities.java
@@ -36,12 +36,25 @@ public final class LightsCapabilities {
// segments to show (in order to represent battery level).
public static final int LIGHTS_SEGMENTED_BATTERY_LED = 16;
- // The notification light supports adjustable brightness.
+ // The notification light supports HAL adjustable brightness
+ // via the alpha channel.
+ // Note: if a device notification light supports LIGHTS_RGB_NOTIFICATION_LED
+ // then HAL support is not necessary for brightness control. In this case,
+ // brightness support will be provided by lineage-sdk through the scaling of
+ // RGB color values.
public static final int LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS = 32;
// Device has a battery light.
public static final int LIGHTS_BATTERY_LED = 64;
+ // The battery light supports HAL adjustable brightness via
+ // the alpha channel.
+ // Note: if a device battery light supports LIGHTS_RGB_BATTERY_LED then HAL
+ // support is not necessary for brightness control. In this case,
+ // brightness support will be provided by lineage-sdk through the scaling of
+ // RGB color values.
+ public static final int LIGHTS_ADJUSTABLE_BATTERY_LED_BRIGHTNESS = 128;
+
public static boolean supports(Context context, final int capability) {
final int capabilities = context.getResources().getInteger(
org.lineageos.platform.internal.R.integer.config_deviceLightCapabilities);
diff --git a/sdk/src/java/org/lineageos/internal/notification/LineageBatteryLights.java b/sdk/src/java/org/lineageos/internal/notification/LineageBatteryLights.java
index a318ce12..121ac8e3 100644
--- a/sdk/src/java/org/lineageos/internal/notification/LineageBatteryLights.java
+++ b/sdk/src/java/org/lineageos/internal/notification/LineageBatteryLights.java
@@ -81,7 +81,7 @@ public final class LineageBatteryLights {
mContext, LightsCapabilities.LIGHTS_RGB_BATTERY_LED);
mHALAdjustableBrightness = LightsCapabilities.supports(
- mContext, LightsCapabilities.LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS);
+ mContext, LightsCapabilities.LIGHTS_ADJUSTABLE_BATTERY_LED_BRIGHTNESS);
// We support brightness adjustment if either the HAL supports it
// or the light is RGB adjustable.