LightsService cleanup:
Add Light subclass to replace LightsService light setting methods
Remove LightsService.setAttentionLight() and LightsService.pulseBreathingLight()
Add support for Wifi and Bluetooth lights
Change-Id: I707f53cda27481c25649f402567a665d52e9cb62
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index b89cd3f..c179eb8 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -87,6 +87,9 @@
private WorkerHandler mHandler;
private StatusBarService mStatusBarService;
private LightsService mLightsService;
+ private LightsService.Light mBatteryLight;
+ private LightsService.Light mNotificationLight;
+ private LightsService.Light mAttentionLight;
private NotificationRecord mSoundNotification;
private AsyncPlayer mSound;
@@ -376,6 +379,10 @@
mStatusBarService = statusBar;
statusBar.setNotificationCallbacks(mNotificationCallbacks);
+ mBatteryLight = lights.getLight(LightsService.LIGHT_ID_BATTERY);
+ mNotificationLight = lights.getLight(LightsService.LIGHT_ID_NOTIFICATIONS);
+ mAttentionLight = lights.getLight(LightsService.LIGHT_ID_ATTENTION);
+
// 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
@@ -678,7 +685,7 @@
long identity = Binder.clearCallingIdentity();
try {
r.statusBarKey = mStatusBarService.addIcon(icon, n);
- mLightsService.pulseBreathingLight();
+ mAttentionLight.pulse();
}
finally {
Binder.restoreCallingIdentity(identity);
@@ -969,24 +976,20 @@
// Battery low always shows, other states only show if charging.
if (mBatteryLow) {
if (mBatteryCharging) {
- mLightsService.setLightColor(LightsService.LIGHT_ID_BATTERY,
- BATTERY_LOW_ARGB);
+ mBatteryLight.setColor(BATTERY_LOW_ARGB);
} else {
// Flash when battery is low and not charging
- mLightsService.setLightFlashing(LightsService.LIGHT_ID_BATTERY,
- BATTERY_LOW_ARGB, LightsService.LIGHT_FLASH_TIMED,
- BATTERY_BLINK_ON, BATTERY_BLINK_OFF);
+ mBatteryLight.setFlashing(BATTERY_LOW_ARGB, LightsService.LIGHT_FLASH_TIMED,
+ BATTERY_BLINK_ON, BATTERY_BLINK_OFF);
}
} else if (mBatteryCharging) {
if (mBatteryFull) {
- mLightsService.setLightColor(LightsService.LIGHT_ID_BATTERY,
- BATTERY_FULL_ARGB);
+ mBatteryLight.setColor(BATTERY_FULL_ARGB);
} else {
- mLightsService.setLightColor(LightsService.LIGHT_ID_BATTERY,
- BATTERY_MEDIUM_ARGB);
+ mBatteryLight.setColor(BATTERY_MEDIUM_ARGB);
}
} else {
- mLightsService.setLightOff(LightsService.LIGHT_ID_BATTERY);
+ mBatteryLight.turnOff();
}
// handle notification lights
@@ -998,10 +1001,9 @@
}
}
if (mLedNotification == null) {
- mLightsService.setLightOff(LightsService.LIGHT_ID_NOTIFICATIONS);
+ mNotificationLight.turnOff();
} else {
- mLightsService.setLightFlashing(
- LightsService.LIGHT_ID_NOTIFICATIONS,
+ mNotificationLight.setFlashing(
mLedNotification.notification.ledARGB,
LightsService.LIGHT_FLASH_TIMED,
mLedNotification.notification.ledOnMS,