From 36006a21a71f2d034293fc5b11bce81b25a51b24 Mon Sep 17 00:00:00 2001 From: Jackeagle Date: Wed, 20 Aug 2025 04:00:58 -0400 Subject: [PATCH] lineage-sdk: Fix missed call LED color settings support * Add support for dedicated missed call LED settings when custom values are enabled * Only check dedicated phone/voicemail LED settings when custom LED values are enabled * Preserve alpha channel during brightness scaling to prevent color corruption * Fixes issue where custom missed call LED colors were ignored Change-Id: I97a8f5e63d31276dd0a61e4180a990fbfed154f7 Signed-off-by: Jackeagle --- .../internal/notification/LedValues.java | 2 +- .../LineageNotificationLights.java | 46 +++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/sdk/src/java/org/lineageos/internal/notification/LedValues.java b/sdk/src/java/org/lineageos/internal/notification/LedValues.java index df468a1f..7528bd2e 100644 --- a/sdk/src/java/org/lineageos/internal/notification/LedValues.java +++ b/sdk/src/java/org/lineageos/internal/notification/LedValues.java @@ -108,7 +108,7 @@ public class LedValues { int red = ((mColor >> 16) & 0xFF) * mBrightness / 255; int green = ((mColor >> 8) & 0xFF) * mBrightness / 255; int blue = (mColor & 0xFF) * mBrightness / 255; - mColor = (red << 16) | (green << 8) | blue; + mColor = (mColor & 0xFF000000) | (red << 16) | (green << 8) | blue; mBrightness = 255; } } diff --git a/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java b/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java index 5d23c70e..0dcfdc88 100644 --- a/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java +++ b/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java @@ -60,6 +60,7 @@ public final class LineageNotificationLights { private boolean mScreenOnEnabled; private boolean mZenAllowLights; private boolean mNotificationLedEnabled; + private boolean mCustomLedValuesEnabled; private int mNotificationLedBrightnessLevel; private int mNotificationLedBrightnessLevelZen; private int mDefaultNotificationColor; @@ -165,7 +166,45 @@ public final class LineageNotificationLights { } private LedValues getLedValuesForPackageName(String packageName) { - return mNotificationPulseCustomLedValues.get(mapPackage(packageName)); + final String mappedPackage = mapPackage(packageName); + + // Only check dedicated settings if custom LED values are enabled + if (mCustomLedValuesEnabled) { + // Check for phone app specific settings first + if ("com.android.phone".equals(mappedPackage) || "com.android.dialer".equals(mappedPackage)) { + final ContentResolver resolver = mContext.getContentResolver(); + final int callColor = LineageSettings.System.getIntForUser(resolver, + LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_COLOR, 0, UserHandle.USER_CURRENT); + final int callLedOn = LineageSettings.System.getIntForUser(resolver, + LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_LED_ON, mDefaultNotificationLedOn, UserHandle.USER_CURRENT); + final int callLedOff = LineageSettings.System.getIntForUser(resolver, + LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_LED_OFF, mDefaultNotificationLedOff, UserHandle.USER_CURRENT); + + if (callColor != 0) { + return new LedValues(callColor, callLedOn, callLedOff); + } + } + + // Check for voicemail app specific settings + if (mappedPackage.contains("voicemail") || mappedPackage.contains("vvm")) { + final ContentResolver resolver = mContext.getContentResolver(); + final int vmailColor = LineageSettings.System.getIntForUser(resolver, + LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_COLOR, 0, UserHandle.USER_CURRENT); + final int vmailLedOn = LineageSettings.System.getIntForUser(resolver, + LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_LED_ON, mDefaultNotificationLedOn, UserHandle.USER_CURRENT); + final int vmailLedOff = LineageSettings.System.getIntForUser(resolver, + LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_LED_OFF, mDefaultNotificationLedOff, UserHandle.USER_CURRENT); + + if (vmailColor != 0) { + return new LedValues(vmailColor, vmailLedOn, vmailLedOff); + } + } + + return mNotificationPulseCustomLedValues.get(mappedPackage); + } + + // When custom values are disabled, return null to use default behavior + return null; } private int generateLedColorForPackageName(String packageName) { @@ -452,9 +491,10 @@ public final class LineageNotificationLights { // LED custom notification colors mNotificationPulseCustomLedValues.clear(); - if (LineageSettings.System.getIntForUser(resolver, + mCustomLedValuesEnabled = LineageSettings.System.getIntForUser(resolver, LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE, 0, - UserHandle.USER_CURRENT) != 0) { + UserHandle.USER_CURRENT) != 0; + if (mCustomLedValuesEnabled) { parseNotificationPulseCustomValuesString(LineageSettings.System.getStringForUser( resolver, LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_VALUES, UserHandle.USER_CURRENT)); -- GitLab