diff options
author | Mike Lockwood <lockwood@android.com> | 2010-01-20 12:13:36 -0500 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-01-20 22:43:47 -0500 |
commit | 670f93283b5e2445c58998153de9c476acddc37b (patch) | |
tree | 6f55352c72e6a31ee30c26afb81b65f5f31d22a0 /services/java/com | |
parent | 867e8eb753422bb9ef83297b72f925b92040daf9 (diff) | |
download | frameworks_base-670f93283b5e2445c58998153de9c476acddc37b.zip frameworks_base-670f93283b5e2445c58998153de9c476acddc37b.tar.gz frameworks_base-670f93283b5e2445c58998153de9c476acddc37b.tar.bz2 |
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 <lockwood@android.com>
Diffstat (limited to 'services/java/com')
-rw-r--r-- | services/java/com/android/server/LightsService.java | 9 | ||||
-rwxr-xr-x | services/java/com/android/server/NotificationManagerService.java | 35 |
2 files changed, 36 insertions, 8 deletions
diff --git a/services/java/com/android/server/LightsService.java b/services/java/com/android/server/LightsService.java index 1937b04..9cc74e8 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 436a60e..fc89ec8 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); + } } } |