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>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user