diff options
-rw-r--r-- | sdk/src/java/org/lineageos/internal/notification/LineageNotification.java | 22 | ||||
-rw-r--r-- | sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java | 39 |
2 files changed, 61 insertions, 0 deletions
diff --git a/sdk/src/java/org/lineageos/internal/notification/LineageNotification.java b/sdk/src/java/org/lineageos/internal/notification/LineageNotification.java index f71c6a7a..68462521 100644 --- a/sdk/src/java/org/lineageos/internal/notification/LineageNotification.java +++ b/sdk/src/java/org/lineageos/internal/notification/LineageNotification.java @@ -33,4 +33,26 @@ public class LineageNotification { * a specific light brightness. */ public static final String EXTRA_FORCE_LIGHT_BRIGHTNESS = "lineage.forceLightBrightness"; + + /** + * Used by light picker in Settings to force + * a specific light color. + */ + public static final String EXTRA_FORCE_COLOR = "lineage.forceColor"; + + /** + * Used by light picker in Settings to force + * a specific light on duration. + * + * Value must be greater than or equal to 0. + */ + public static final String EXTRA_FORCE_LIGHT_ON_MS = "lineage.forceLightOnMs"; + + /** + * Used by light picker in Settings to force + * a specific light off duration. + * + * Value must be greater than or equal to 0. + */ + public static final String EXTRA_FORCE_LIGHT_OFF_MS = "lineage.forceLightOffMs"; } diff --git a/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java b/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java index 75a325fb..283cefc1 100644 --- a/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java +++ b/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java @@ -222,6 +222,27 @@ public final class LineageNotificationLights { return 0; } + public int getForcedColor(Notification n) { + if (n.extras != null) { + return n.extras.getInt(LineageNotification.EXTRA_FORCE_COLOR, 0); + } + return 0; + } + + public int getForcedLightOnMs(Notification n) { + if (n.extras != null) { + return n.extras.getInt(LineageNotification.EXTRA_FORCE_LIGHT_ON_MS, -1); + } + return -1; + } + + public int getForcedLightOffMs(Notification n) { + if (n.extras != null) { + return n.extras.getInt(LineageNotification.EXTRA_FORCE_LIGHT_OFF_MS, -1); + } + return -1; + } + public void setZenMode(int zenMode) { mZenMode = zenMode; mLedUpdater.update(); @@ -234,6 +255,9 @@ public final class LineageNotificationLights { boolean screenActive, int suppressedEffects) { final boolean forcedOn = isForcedOn(n); final int forcedBrightness = getForcedBrightness(n); + final int forcedColor = getForcedColor(n); + final int forcedLightOnMs = getForcedLightOnMs(n); + final int forcedLightOffMs = getForcedLightOffMs(n); final boolean suppressScreenOff = (suppressedEffects & SUPPRESSED_EFFECT_SCREEN_OFF) != 0; final boolean suppressScreenOn = @@ -248,6 +272,9 @@ public final class LineageNotificationLights { + " suppressedEffects=" + suppressedEffects + " forcedOn=" + forcedOn + " forcedBrightness=" + forcedBrightness + + " forcedColor=" + forcedColor + + " forcedLightOnMs=" + forcedLightOnMs + + " forcedLightOffMs=" + forcedLightOffMs + " suppressScreenOff=" + suppressScreenOff + " suppressScreenOn=" + suppressScreenOn + " mCanAdjustBrightness=" + mCanAdjustBrightness @@ -318,6 +345,18 @@ public final class LineageNotificationLights { ledValues.setOnMs(mDefaultNotificationLedOn); ledValues.setOffMs(mDefaultNotificationLedOff); } + + // Use forced color and durations, if specified + if (forcedColor != 0) { + ledValues.setColor(forcedColor); + } + if (forcedLightOnMs >= 0) { + ledValues.setOnMs(forcedLightOnMs); + } + if (forcedLightOffMs >= 0) { + ledValues.setOffMs(forcedLightOffMs); + } + // If lights HAL does not support adjustable notification brightness then // scale color value here instead. if (mCanAdjustBrightness && !mHALAdjustableBrightness) { |