diff --git a/sdk/src/java/org/lineageos/internal/notification/LedValues.java b/sdk/src/java/org/lineageos/internal/notification/LedValues.java index df468a1f9750bfa3e659e219d421ea75a0f12717..7528bd2ebe8f2c267236fd2cdf703530c4d202f9 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 5d23c70ee85df68d598558520801d5a93560ede5..0dcfdc88851a5562770127e97f74b38f5394e48b 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));