From 670f93283b5e2445c58998153de9c476acddc37b Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Wed, 20 Jan 2010 12:13:36 -0500 Subject: [PATCH] Implement Notification.DEFAULT_LIGHTS flag. This flag was already in the public API but did not do anything until now. We now use it so we can override the default notification LED color on a per device basis. Change-Id: I0d6e239b7da2fdbeda9608d6d4de3e778aa88e2c BUG: 2329568 Signed-off-by: Mike Lockwood --- core/res/res/values/config.xml | 9 +++++ .../com/android/server/LightsService.java | 9 +++-- .../server/NotificationManagerService.java | 35 +++++++++++++++---- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index cc54ba34c43a1..9a8af3f50eaae 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -164,6 +164,15 @@ 20 + + #ff00ff00 + + + 500 + + + 2000 + false diff --git a/services/java/com/android/server/LightsService.java b/services/java/com/android/server/LightsService.java index 1937b043f530a..9cc74e814c451 100644 --- a/services/java/com/android/server/LightsService.java +++ b/services/java/com/android/server/LightsService.java @@ -80,11 +80,16 @@ public class LightsService { } } + public void pulse() { + pulse(0x00ffffff, 7); + } + + public void pulse(int color, int onMS) { synchronized (this) { if (mColor == 0 && !mFlashing) { - setLightLocked(0x00ffffff, LIGHT_FLASH_HARDWARE, 7, 0, BRIGHTNESS_MODE_USER); - mH.sendMessageDelayed(Message.obtain(mH, 1, this), 3000); + setLightLocked(color, LIGHT_FLASH_HARDWARE, onMS, 1000, BRIGHTNESS_MODE_USER); + mH.sendMessageDelayed(Message.obtain(mH, 1, this), onMS); } } } diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index 436a60e377f5f..fc89ec8482a86 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -91,6 +91,10 @@ class NotificationManagerService extends INotificationManager.Stub private LightsService.Light mNotificationLight; private LightsService.Light mAttentionLight; + private int mDefaultNotificationColor; + private int mDefaultNotificationLedOn; + private int mDefaultNotificationLedOff; + private NotificationRecord mSoundNotification; private AsyncPlayer mSound; private boolean mSystemReady; @@ -398,6 +402,14 @@ class NotificationManagerService extends INotificationManager.Stub mNotificationLight = lights.getLight(LightsService.LIGHT_ID_NOTIFICATIONS); mAttentionLight = lights.getLight(LightsService.LIGHT_ID_ATTENTION); + Resources resources = mContext.getResources(); + mDefaultNotificationColor = resources.getColor( + com.android.internal.R.color.config_defaultNotificationColor); + mDefaultNotificationLedOn = resources.getInteger( + com.android.internal.R.integer.config_defaultNotificationLedOn); + mDefaultNotificationLedOff = resources.getInteger( + com.android.internal.R.integer.config_defaultNotificationLedOff); + // Don't start allowing notifications until the setup wizard has run once. // After that, including subsequent boots, init with notifications turned on. // This works on the first boot because the setup wizard will toggle this @@ -1024,14 +1036,25 @@ class NotificationManagerService extends INotificationManager.Stub } // we only flash if screen is off and persistent pulsing is enabled - if (mLedNotification == null || mScreenOn || !mNotificationPulseEnabled) { + if (mLedNotification == null || mScreenOn) { mNotificationLight.turnOff(); } else { - mNotificationLight.setFlashing( - mLedNotification.notification.ledARGB, - LightsService.LIGHT_FLASH_TIMED, - mLedNotification.notification.ledOnMS, - mLedNotification.notification.ledOffMS); + int ledARGB = mLedNotification.notification.ledARGB; + int ledOnMS = mLedNotification.notification.ledOnMS; + int ledOffMS = mLedNotification.notification.ledOffMS; + if ((mLedNotification.notification.defaults & Notification.DEFAULT_LIGHTS) != 0) { + ledARGB = mDefaultNotificationColor; + ledOnMS = mDefaultNotificationLedOn; + ledOffMS = mDefaultNotificationLedOff; + } + if (mNotificationPulseEnabled) { + // pulse repeatedly + mNotificationLight.setFlashing(ledARGB, LightsService.LIGHT_FLASH_TIMED, + ledOnMS, ledOffMS); + } else { + // pulse only once + mNotificationLight.pulse(ledARGB, ledOnMS); + } } }