Skip to content

Commit 2561b0b

Browse files
committed
New notification priority and related APIs.
This change introduces a few new bits of data on Notification that will help the Notification Manager and System UI route and display them more intelligently: -> priority: an integer in a predefined range that indicates the app's best guess as to the relative importance (to the user, right now) of that information -> kind: a tag (really, set of tags) indicating the general type of notification (realtime, asynchronous, etc) -> extras: a Bundle of additional key/value pairs associated with this notification (currently @hidden) The notification manager takes these data into account when assigning to each notification a score which is passed with the notification on to the system UI, where it can be used to affect presentation. For example: - Spammy apps (identified explicitly by the user or by some other means) will have their notifications scored very negatively by the notification manager, allowing the UI to suppress them - Notifications of higher score might be shown larger or in a different way - Very important notifications (indicated by a very high score) might interrupt the user during an otherwise important task (videochat, game, etc) Implementation note: This replaces/extends the old internal notion of "priority", which was mostly used to organize ongoings and system notifications at the top of the panel. Change-Id: Ie063dc75f198a68e2b5734a3aa0cacb5aba1ac39
1 parent c725a37 commit 2561b0b

File tree

10 files changed

+572
-252
lines changed

10 files changed

+572
-252
lines changed

api/current.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3626,12 +3626,22 @@ package android.app {
36263626
field public static final int DEFAULT_VIBRATE = 2; // 0x2
36273627
field public static final int FLAG_AUTO_CANCEL = 16; // 0x10
36283628
field public static final int FLAG_FOREGROUND_SERVICE = 64; // 0x40
3629-
field public static final int FLAG_HIGH_PRIORITY = 128; // 0x80
3629+
field public static final deprecated int FLAG_HIGH_PRIORITY = 128; // 0x80
36303630
field public static final int FLAG_INSISTENT = 4; // 0x4
36313631
field public static final int FLAG_NO_CLEAR = 32; // 0x20
36323632
field public static final int FLAG_ONGOING_EVENT = 2; // 0x2
36333633
field public static final int FLAG_ONLY_ALERT_ONCE = 8; // 0x8
36343634
field public static final int FLAG_SHOW_LIGHTS = 1; // 0x1
3635+
field public static final java.lang.String KIND_CALL = "android.call";
3636+
field public static final java.lang.String KIND_EMAIL = "android.email";
3637+
field public static final java.lang.String KIND_EVENT = "android.event";
3638+
field public static final java.lang.String KIND_MESSAGE = "android.message";
3639+
field public static final java.lang.String KIND_PROMO = "android.promo";
3640+
field public static final int PRIORITY_DEFAULT = 0; // 0x0
3641+
field public static final int PRIORITY_HIGH = 1; // 0x1
3642+
field public static final int PRIORITY_LOW = -1; // 0xffffffff
3643+
field public static final int PRIORITY_MAX = 2; // 0x2
3644+
field public static final int PRIORITY_MIN = -2; // 0xfffffffe
36353645
field public static final int STREAM_DEFAULT = -1; // 0xffffffff
36363646
field public int audioStreamType;
36373647
field public android.app.PendingIntent contentIntent;
@@ -3642,11 +3652,13 @@ package android.app {
36423652
field public android.app.PendingIntent fullScreenIntent;
36433653
field public int icon;
36443654
field public int iconLevel;
3655+
field public java.lang.String[] kind;
36453656
field public android.graphics.Bitmap largeIcon;
36463657
field public int ledARGB;
36473658
field public int ledOffMS;
36483659
field public int ledOnMS;
36493660
field public int number;
3661+
field public int priority;
36503662
field public android.net.Uri sound;
36513663
field public java.lang.CharSequence tickerText;
36523664
field public android.widget.RemoteViews tickerView;
@@ -3656,6 +3668,7 @@ package android.app {
36563668

36573669
public static class Notification.Builder {
36583670
ctor public Notification.Builder(android.content.Context);
3671+
method public android.app.Notification.Builder addKind(java.lang.String);
36593672
method public android.app.Notification getNotification();
36603673
method public android.app.Notification.Builder setAutoCancel(boolean);
36613674
method public android.app.Notification.Builder setContent(android.widget.RemoteViews);
@@ -3671,6 +3684,7 @@ package android.app {
36713684
method public android.app.Notification.Builder setNumber(int);
36723685
method public android.app.Notification.Builder setOngoing(boolean);
36733686
method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
3687+
method public android.app.Notification.Builder setPriority(int);
36743688
method public android.app.Notification.Builder setProgress(int, int, boolean);
36753689
method public android.app.Notification.Builder setSmallIcon(int);
36763690
method public android.app.Notification.Builder setSmallIcon(int, int);

core/java/android/app/INotificationManager.aidl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ interface INotificationManager
3333
void enqueueToast(String pkg, ITransientNotification callback, int duration);
3434
void cancelToast(String pkg, ITransientNotification callback);
3535
void enqueueNotificationWithTag(String pkg, String tag, int id, in Notification notification, inout int[] idReceived);
36-
void enqueueNotificationWithTagPriority(String pkg, String tag, int id, int priority, in Notification notification, inout int[] idReceived);
3736
void cancelNotificationWithTag(String pkg, String tag, int id);
3837
}
3938

0 commit comments

Comments
 (0)