diff options
author | Daniel Sandler <dsandler@google.com> | 2011-02-03 14:51:35 -0500 |
---|---|---|
committer | Daniel Sandler <dsandler@google.com> | 2011-02-03 21:11:46 -0500 |
commit | e40451a89dc91dfd636af7cb32a23b4a4cc93fdc (patch) | |
tree | 875a847a9a638ce36310887dc7818e02e8cb96dc /services | |
parent | 8275c6087897e8fd614681d1cd12db62e6b9fcd5 (diff) | |
download | frameworks_base-e40451a89dc91dfd636af7cb32a23b4a4cc93fdc.zip frameworks_base-e40451a89dc91dfd636af7cb32a23b4a4cc93fdc.tar.gz frameworks_base-e40451a89dc91dfd636af7cb32a23b4a4cc93fdc.tar.bz2 |
Ongoing notification for GPS use.
This change improves upon the notification priority API
introduced in change I9e738cc4, allowing privileged clients
to set the priority of a notification when posting it
directly to INotificationManager. StatusBarTest is updated
to test this new feature.
The new LocationController in SystemUI uses this facility to
post a high-priority ongoing notification whenever GPS is in
use (replacing the functionality of the legacy GPS status
bar icon).
Also happens to fix http://b/3325472 (adding a log message
when notifications are dropped because of a missing icon).
Bug: 3412807
Change-Id: I523016ffa53bf979be98ddc4a2deb55a6270c68a
Diffstat (limited to 'services')
-rwxr-xr-x | services/java/com/android/server/NotificationManagerService.java | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index 0490190..47dce41 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -156,10 +156,11 @@ public class NotificationManagerService extends INotificationManager.Stub final int id; final int uid; final int initialPid; + final int priority; final Notification notification; IBinder statusBarKey; - NotificationRecord(String pkg, String tag, int id, int uid, int initialPid, + NotificationRecord(String pkg, String tag, int id, int uid, int initialPid, int priority, Notification notification) { this.pkg = pkg; @@ -167,6 +168,7 @@ public class NotificationManagerService extends INotificationManager.Stub this.id = id; this.uid = uid; this.initialPid = initialPid; + this.priority = priority; this.notification = notification; } @@ -194,7 +196,9 @@ public class NotificationManagerService extends INotificationManager.Stub + Integer.toHexString(System.identityHashCode(this)) + " pkg=" + pkg + " id=" + Integer.toHexString(id) - + " tag=" + tag + "}"; + + " tag=" + tag + + " pri=" + priority + + "}"; } } @@ -649,11 +653,27 @@ public class NotificationManagerService extends INotificationManager.Stub tag, id, notification, idOut); } + public void enqueueNotificationWithTagPriority(String pkg, String tag, int id, int priority, + Notification notification, int[] idOut) + { + enqueueNotificationInternal(pkg, Binder.getCallingUid(), Binder.getCallingPid(), + tag, id, priority, notification, idOut); + } + // Not exposed via Binder; for system use only (otherwise malicious apps could spoof the // uid/pid of another application) public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid, String tag, int id, Notification notification, int[] idOut) { + enqueueNotificationInternal(pkg, callingUid, callingPid, tag, id, + ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0) + ? StatusBarNotification.PRIORITY_ONGOING + : StatusBarNotification.PRIORITY_NORMAL, + notification, idOut); + } + public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid, + String tag, int id, int priority, Notification notification, int[] idOut) + { checkIncomingCall(pkg); // Limit the number of notifications that any given package except the android @@ -695,8 +715,10 @@ public class NotificationManagerService extends INotificationManager.Stub } synchronized (mNotificationList) { - NotificationRecord r = new NotificationRecord(pkg, tag, id, - callingUid, callingPid, notification); + NotificationRecord r = new NotificationRecord(pkg, tag, id, + callingUid, callingPid, + priority, + notification); NotificationRecord old = null; int index = indexOfNotificationLocked(pkg, tag, id); @@ -722,6 +744,8 @@ public class NotificationManagerService extends INotificationManager.Stub if (notification.icon != 0) { StatusBarNotification n = new StatusBarNotification(pkg, id, tag, r.uid, r.initialPid, notification); + n.priority = r.priority; + if (old != null && old.statusBarKey != null) { r.statusBarKey = old.statusBarKey; long identity = Binder.clearCallingIdentity(); @@ -743,6 +767,7 @@ public class NotificationManagerService extends INotificationManager.Stub } sendAccessibilityEvent(notification, pkg); } else { + Slog.e(TAG, "Ignoring notification with icon==0: " + notification); if (old != null && old.statusBarKey != null) { long identity = Binder.clearCallingIdentity(); try { |