am 652d8fc9: Merge "PRIORITY_MIN notifications should be truly ambient." into jb-mr1.1-dev

* commit '652d8fc944c011eb15202f678588723aa9f38a84':
  PRIORITY_MIN notifications should be truly ambient.
This commit is contained in:
Sascha Prueter
2012-12-04 16:32:05 -08:00
committed by Android Git Automerger

View File

@@ -110,6 +110,11 @@ public class NotificationManagerService extends INotificationManager.Stub
private static final int NOTIFICATION_PRIORITY_MULTIPLIER = 10; private static final int NOTIFICATION_PRIORITY_MULTIPLIER = 10;
private static final int SCORE_DISPLAY_THRESHOLD = Notification.PRIORITY_MIN * NOTIFICATION_PRIORITY_MULTIPLIER; private static final int SCORE_DISPLAY_THRESHOLD = Notification.PRIORITY_MIN * NOTIFICATION_PRIORITY_MULTIPLIER;
// Notifications with scores below this will not interrupt the user, either via LED or
// sound or vibration
private static final int SCORE_INTERRUPTION_THRESHOLD =
Notification.PRIORITY_LOW * NOTIFICATION_PRIORITY_MULTIPLIER;
private static final boolean ENABLE_BLOCKED_NOTIFICATIONS = true; private static final boolean ENABLE_BLOCKED_NOTIFICATIONS = true;
private static final boolean ENABLE_BLOCKED_TOASTS = true; private static final boolean ENABLE_BLOCKED_TOASTS = true;
@@ -991,6 +996,9 @@ public class NotificationManagerService extends INotificationManager.Stub
return; return;
} }
// Should this notification make noise, vibe, or use the LED?
final boolean canInterrupt = (score >= SCORE_INTERRUPTION_THRESHOLD);
synchronized (mNotificationList) { synchronized (mNotificationList) {
NotificationRecord r = new NotificationRecord(pkg, tag, id, NotificationRecord r = new NotificationRecord(pkg, tag, id,
callingUid, callingPid, userId, callingUid, callingPid, userId,
@@ -1042,7 +1050,8 @@ public class NotificationManagerService extends INotificationManager.Stub
long identity = Binder.clearCallingIdentity(); long identity = Binder.clearCallingIdentity();
try { try {
r.statusBarKey = mStatusBar.addNotification(n); r.statusBarKey = mStatusBar.addNotification(n);
if ((n.notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0) { if ((n.notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0
&& canInterrupt) {
mAttentionLight.pulse(); mAttentionLight.pulse();
} }
} }
@@ -1073,6 +1082,7 @@ public class NotificationManagerService extends INotificationManager.Stub
&& (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 )) && (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 ))
&& (r.userId == UserHandle.USER_ALL || && (r.userId == UserHandle.USER_ALL ||
(r.userId == userId && r.userId == currentUser)) (r.userId == userId && r.userId == currentUser))
&& canInterrupt
&& mSystemReady) { && mSystemReady) {
final AudioManager audioManager = (AudioManager) mContext final AudioManager audioManager = (AudioManager) mContext
@@ -1171,7 +1181,8 @@ public class NotificationManagerService extends INotificationManager.Stub
} }
//Slog.i(TAG, "notification.lights=" //Slog.i(TAG, "notification.lights="
// + ((old.notification.lights.flags & Notification.FLAG_SHOW_LIGHTS) != 0)); // + ((old.notification.lights.flags & Notification.FLAG_SHOW_LIGHTS) != 0));
if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0) { if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0
&& canInterrupt) {
mLights.add(r); mLights.add(r);
updateLightsLocked(); updateLightsLocked();
} else { } else {