Properly handle Notification LED behavior.

* Handle notification lights when screen is ON/OFF
* Don't flash LED while we are in a call or screen is on

Issue: FP3-A11#233
Change-Id: Ia8697e5b55e4a057765f4bc1027514b09fca3376
Depends-On: I667535bbc628c4fb234c46802937d1aca659485f
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 2a3dc02..0050ea8 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1578,11 +1578,6 @@
                     cancelAllNotificationsInt(MY_UID, MY_PID, null, null, 0, 0, true, userHandle,
                             REASON_PROFILE_TURNED_OFF, null);
                 }
-            } else if (action.equals(Intent.ACTION_USER_PRESENT)) {
-                // turn off LED when user passes through lock screen
-                if (mNotificationLight != null) {
-                    mNotificationLight.turnOff();
-                }
             } else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
                 final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
                 mUserProfiles.updateCache(context);
@@ -7087,14 +7082,14 @@
         // Suppressed because it's a silent update
         final Notification notification = record.getNotification();
         if (record.isUpdate && (notification.flags & FLAG_ONLY_ALERT_ONCE) != 0) {
-            return false;
+            return true;
         }
         // Suppressed because another notification in its group handles alerting
         if (record.getSbn().isGroup() && record.getNotification().suppressAlertingDueToGrouping()) {
             return false;
         }
         // not if in call or the screen's on
-        if (isInCall() || mScreenOn) {
+        if (isInCall()) {
             return false;
         }
 
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index bae02ac..b9c0e6c 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -372,7 +372,8 @@
                 break;
         }
         stats.requestedImportance = requestedImportance;
-        stats.isNoisy = mSound != null || mVibration != null;
+        stats.isNoisy = mSound != null || mVibration != null
+          ||(n.defaults & Notification.DEFAULT_LIGHTS) != 0;
 
         // For pre-channels notifications, apply system overrides and then use requestedImportance
         // as importance.