diff --git a/sdk/src/java/org/lineageos/internal/notification/LedValues.java b/sdk/src/java/org/lineageos/internal/notification/LedValues.java index 4d6d17391e35a059412cd673821c30a658b186d7..7af80f09358b0603c70033cb0e0cf0cdbe7bb9de 100644 --- a/sdk/src/java/org/lineageos/internal/notification/LedValues.java +++ b/sdk/src/java/org/lineageos/internal/notification/LedValues.java @@ -97,7 +97,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 42355a152ab9fcb19eee24cf260014787ef25d8d..44d4fbea43e775d06b196ab954a7e50f8eec4ca4 100644 --- a/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java +++ b/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java @@ -50,6 +50,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; @@ -154,7 +155,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) { @@ -441,9 +480,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));