diff --git a/api/current.txt b/api/current.txt index 6ca7bda1bcd05..c356e3bfaf540 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5300,6 +5300,13 @@ package android.app { field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED"; field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED"; field public static final java.lang.String ACTION_NOTIFICATION_POLICY_CHANGED = "android.app.action.NOTIFICATION_POLICY_CHANGED"; + field public static final int IMPORTANCE_DEFAULT = 3; // 0x3 + field public static final int IMPORTANCE_HIGH = 4; // 0x4 + field public static final int IMPORTANCE_LOW = 2; // 0x2 + field public static final int IMPORTANCE_MAX = 5; // 0x5 + field public static final int IMPORTANCE_MIN = 1; // 0x1 + field public static final int IMPORTANCE_NONE = 0; // 0x0 + field public static final int IMPORTANCE_UNSPECIFIED = -1000; // 0xfffffc18 field public static final int INTERRUPTION_FILTER_ALARMS = 4; // 0x4 field public static final int INTERRUPTION_FILTER_ALL = 1; // 0x1 field public static final int INTERRUPTION_FILTER_NONE = 3; // 0x3 @@ -34717,13 +34724,6 @@ package android.service.notification { method public int getSuppressedVisualEffects(); method public boolean isAmbient(); method public boolean matchesInterruptionFilter(); - field public static final int IMPORTANCE_DEFAULT = 3; // 0x3 - field public static final int IMPORTANCE_HIGH = 4; // 0x4 - field public static final int IMPORTANCE_LOW = 2; // 0x2 - field public static final int IMPORTANCE_MAX = 5; // 0x5 - field public static final int IMPORTANCE_MIN = 1; // 0x1 - field public static final int IMPORTANCE_NONE = 0; // 0x0 - field public static final int IMPORTANCE_UNSPECIFIED = -1000; // 0xfffffc18 } public static class NotificationListenerService.RankingMap implements android.os.Parcelable { diff --git a/api/system-current.txt b/api/system-current.txt index fab6d6f2d423a..5ad1b11ecbff1 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5447,6 +5447,13 @@ package android.app { field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED"; field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED"; field public static final java.lang.String ACTION_NOTIFICATION_POLICY_CHANGED = "android.app.action.NOTIFICATION_POLICY_CHANGED"; + field public static final int IMPORTANCE_DEFAULT = 3; // 0x3 + field public static final int IMPORTANCE_HIGH = 4; // 0x4 + field public static final int IMPORTANCE_LOW = 2; // 0x2 + field public static final int IMPORTANCE_MAX = 5; // 0x5 + field public static final int IMPORTANCE_MIN = 1; // 0x1 + field public static final int IMPORTANCE_NONE = 0; // 0x0 + field public static final int IMPORTANCE_UNSPECIFIED = -1000; // 0xfffffc18 field public static final int INTERRUPTION_FILTER_ALARMS = 4; // 0x4 field public static final int INTERRUPTION_FILTER_ALL = 1; // 0x1 field public static final int INTERRUPTION_FILTER_NONE = 3; // 0x3 @@ -37443,13 +37450,6 @@ package android.service.notification { method public int getSuppressedVisualEffects(); method public boolean isAmbient(); method public boolean matchesInterruptionFilter(); - field public static final int IMPORTANCE_DEFAULT = 3; // 0x3 - field public static final int IMPORTANCE_HIGH = 4; // 0x4 - field public static final int IMPORTANCE_LOW = 2; // 0x2 - field public static final int IMPORTANCE_MAX = 5; // 0x5 - field public static final int IMPORTANCE_MIN = 1; // 0x1 - field public static final int IMPORTANCE_NONE = 0; // 0x0 - field public static final int IMPORTANCE_UNSPECIFIED = -1000; // 0xfffffc18 } public static class NotificationListenerService.RankingMap implements android.os.Parcelable { diff --git a/api/test-current.txt b/api/test-current.txt index e9f1cda312bf1..3799107387a30 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -5301,6 +5301,13 @@ package android.app { field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED"; field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED"; field public static final java.lang.String ACTION_NOTIFICATION_POLICY_CHANGED = "android.app.action.NOTIFICATION_POLICY_CHANGED"; + field public static final int IMPORTANCE_DEFAULT = 3; // 0x3 + field public static final int IMPORTANCE_HIGH = 4; // 0x4 + field public static final int IMPORTANCE_LOW = 2; // 0x2 + field public static final int IMPORTANCE_MAX = 5; // 0x5 + field public static final int IMPORTANCE_MIN = 1; // 0x1 + field public static final int IMPORTANCE_NONE = 0; // 0x0 + field public static final int IMPORTANCE_UNSPECIFIED = -1000; // 0xfffffc18 field public static final int INTERRUPTION_FILTER_ALARMS = 4; // 0x4 field public static final int INTERRUPTION_FILTER_ALL = 1; // 0x1 field public static final int INTERRUPTION_FILTER_NONE = 3; // 0x3 @@ -34794,13 +34801,6 @@ package android.service.notification { method public int getSuppressedVisualEffects(); method public boolean isAmbient(); method public boolean matchesInterruptionFilter(); - field public static final int IMPORTANCE_DEFAULT = 3; // 0x3 - field public static final int IMPORTANCE_HIGH = 4; // 0x4 - field public static final int IMPORTANCE_LOW = 2; // 0x2 - field public static final int IMPORTANCE_MAX = 5; // 0x5 - field public static final int IMPORTANCE_MIN = 1; // 0x1 - field public static final int IMPORTANCE_NONE = 0; // 0x0 - field public static final int IMPORTANCE_UNSPECIFIED = -1000; // 0xfffffc18 } public static class NotificationListenerService.RankingMap implements android.os.Parcelable { diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index 47bff64403326..18b72e29e0e61 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -16,11 +16,8 @@ package android.app; -import com.android.internal.util.Preconditions; - import android.annotation.IntDef; import android.annotation.NonNull; -import android.annotation.Nullable; import android.annotation.SdkConstant; import android.app.Notification.Builder; import android.content.ComponentName; @@ -39,8 +36,7 @@ import android.os.ServiceManager; import android.os.StrictMode; import android.os.UserHandle; import android.provider.Settings.Global; -import android.service.notification.IConditionListener; -import android.service.notification.NotificationListenerService; +import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.StatusBarNotification; import android.service.notification.ZenModeConfig; import android.util.ArraySet; @@ -48,12 +44,10 @@ import android.util.Log; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.List; -import java.util.Set; /** * Class to notify the user of events that happen. This is how you tell @@ -186,6 +180,56 @@ public class NotificationManager */ public static final int INTERRUPTION_FILTER_UNKNOWN = 0; + /** @hide */ + @IntDef({VISIBILITY_NO_OVERRIDE, IMPORTANCE_UNSPECIFIED, IMPORTANCE_NONE, + IMPORTANCE_MIN, IMPORTANCE_LOW, IMPORTANCE_DEFAULT, IMPORTANCE_HIGH, + IMPORTANCE_MAX}) + @Retention(RetentionPolicy.SOURCE) + public @interface Importance {} + + /** Value signifying that the user has not expressed a per-app visibility override value. + * @hide */ + public static final int VISIBILITY_NO_OVERRIDE = -1000; + /** + * Value signifying that the user has not expressed an importance. + * + * This value is for persisting preferences, and should never be associated with + * an actual notification. + */ + public static final int IMPORTANCE_UNSPECIFIED = -1000; + + /** + * A notification with no importance: shows nowhere, is blocked. + */ + public static final int IMPORTANCE_NONE = 0; + + /** + * Min notification importance: only shows in the shade, below the fold. + */ + public static final int IMPORTANCE_MIN = 1; + + /** + * Low notification importance: shows everywhere, but is not intrusive. + */ + public static final int IMPORTANCE_LOW = 2; + + /** + * Default notification importance: shows everywhere, allowed to makes noise, + * but does not visually intrude. + */ + public static final int IMPORTANCE_DEFAULT = 3; + + /** + * Higher notification importance: shows everywhere, allowed to makes noise and peek. + */ + public static final int IMPORTANCE_HIGH = 4; + + /** + * Highest notification importance: shows everywhere, allowed to makes noise, peek, and + * use full screen intents. + */ + public static final int IMPORTANCE_MAX = 5; + private static INotificationManager sService; /** @hide */ @@ -538,8 +582,10 @@ public class NotificationManager /** * Returns the user specified importance for notifications from the calling package. + * + * @return An importance level, such as {@link #IMPORTANCE_DEFAULT}. */ - public @NotificationListenerService.Ranking.Importance int getImportance() { + public @Importance int getImportance() { INotificationManager service = getService(); try { return service.getPackageImportance(mContext.getPackageName()); diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java index cf783d25251e6..25fe4ffaa4719 100644 --- a/core/java/android/service/notification/NotificationListenerService.java +++ b/core/java/android/service/notification/NotificationListenerService.java @@ -1003,56 +1003,63 @@ public abstract class NotificationListenerService extends Service { */ public static class Ranking { - /** @hide */ - @IntDef({VISIBILITY_NO_OVERRIDE, IMPORTANCE_UNSPECIFIED, IMPORTANCE_NONE, - IMPORTANCE_MIN, IMPORTANCE_LOW, IMPORTANCE_DEFAULT, IMPORTANCE_HIGH, - IMPORTANCE_MAX}) - @Retention(RetentionPolicy.SOURCE) - public @interface Importance {} - /** Value signifying that the user has not expressed a per-app visibility override value. * @hide */ - public static final int VISIBILITY_NO_OVERRIDE = -1000; + public static final int VISIBILITY_NO_OVERRIDE = NotificationManager.VISIBILITY_NO_OVERRIDE; /** * Value signifying that the user has not expressed an importance. * * This value is for persisting preferences, and should never be associated with * an actual notification. + * + * @hide */ - public static final int IMPORTANCE_UNSPECIFIED = -1000; + public static final int IMPORTANCE_UNSPECIFIED = NotificationManager.IMPORTANCE_UNSPECIFIED; /** * A notification with no importance: shows nowhere, is blocked. + * + * @hide */ - public static final int IMPORTANCE_NONE = 0; + public static final int IMPORTANCE_NONE = NotificationManager.IMPORTANCE_NONE; /** * Min notification importance: only shows in the shade, below the fold. + * + * @hide */ - public static final int IMPORTANCE_MIN = 1; + public static final int IMPORTANCE_MIN = NotificationManager.IMPORTANCE_MIN; /** * Low notification importance: shows everywhere, but is not intrusive. + * + * @hide */ - public static final int IMPORTANCE_LOW = 2; + public static final int IMPORTANCE_LOW = NotificationManager.IMPORTANCE_LOW; /** * Default notification importance: shows everywhere, allowed to makes noise, * but does not visually intrude. + * + * @hide */ - public static final int IMPORTANCE_DEFAULT = 3; + public static final int IMPORTANCE_DEFAULT = NotificationManager.IMPORTANCE_DEFAULT; /** * Higher notification importance: shows everywhere, allowed to makes noise and peek. + * + * @hide */ - public static final int IMPORTANCE_HIGH = 4; + public static final int IMPORTANCE_HIGH = NotificationManager.IMPORTANCE_HIGH; /** * Highest notification importance: shows everywhere, allowed to makes noise, peek, and * use full screen intents. + * + * @hide */ - public static final int IMPORTANCE_MAX = 5; + public static final int IMPORTANCE_MAX = NotificationManager.IMPORTANCE_MAX; private String mKey; private int mRank = -1; @@ -1060,7 +1067,7 @@ public abstract class NotificationListenerService extends Service { private boolean mMatchesInterruptionFilter; private int mVisibilityOverride; private int mSuppressedVisualEffects; - private @Importance int mImportance; + private @NotificationManager.Importance int mImportance; private CharSequence mImportanceExplanation; // System specified group key. private String mOverrideGroupKey; @@ -1124,11 +1131,11 @@ public abstract class NotificationListenerService extends Service { /** * Returns the importance of the notification, which dictates its - * modes of presentation, see: {@link #IMPORTANCE_DEFAULT}, etc. + * modes of presentation, see: {@link NotificationManager#IMPORTANCE_DEFAULT}, etc. * * @return the rank of the notification */ - public @Importance int getImportance() { + public @NotificationManager.Importance int getImportance() { return mImportance; }