Added in API level 29

ZenPolicy


class ZenPolicy : Parcelable
kotlin.Any
   ↳ android.service.notification.ZenPolicy

ZenPolicy determines whether to allow certain notifications and their corresponding sounds to play when a device is in Do Not Disturb mode. ZenPolicy also dictates the visual effects of notifications that are intercepted when a device is in Do Not Disturb mode.

Summary

Nested classes

Builder class for ZenPolicy objects.

Constants
static Int

Used to indicate all conversations can bypass dnd.

static Int

Used to indicate important conversations can bypass dnd.

static Int

Used to indicate no conversations can bypass dnd.

static Int

Used to indicate no preference for the type of conversations that can bypass dnd.

static Int

Used to indicate all calls or messages can bypass dnd.

static Int

Used to indicate calls or messages from contacts can bypass dnd.

static Int

Used to indicate no calls or messages can bypass dnd.

static Int

Used to indicate calls or messages from starred contacts can bypass dnd.

static Int

Used to indicate no preference for the type of people that can bypass dnd for either calls or messages.

static Int

Indicates a type of sound or visual effect is allowed to play/show when DND is active.

static Int

Indicates a type of sound or visual effect is not allowed to play/show when DND is active.

static Int

Indicates no preference for whether a type of sound or visual effect is or isn't allowed to play/show when DND is active.

Inherited constants
Public methods
Int

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

Int

Callers that can bypass DND.

Int

Whether this policy wants to allow notifications with category Notification.CATEGORY_ALARM to play sounds and visually appear or to intercept them when DND is active.

Int

Whether this policy wants to allow notifications with category Notification.CATEGORY_CALL to play sounds and visually appear or to intercept them when DND is active.

Int

Whether this policy wants to allow conversation notifications (see NotificationChannel.getConversationId()) to play sounds and visually appear or to intercept them when DND is active.

Int

Whether this policy wants to allow notifications with category Notification.CATEGORY_EVENT to play sounds and visually appear or to intercept them when DND is active.

Int

Whether this policy wants to allow media notifications to play sounds and visually appear or to intercept them when DND is active.

Int

Whether this policy wants to allow notifications with category Notification.CATEGORY_MESSAGE to play sounds and visually appear or to intercept them when DND is active.

Int

Whether this policy wants to allow notifications with category Notification.CATEGORY_REMINDER to play sounds and visually appear or to intercept them when DND is active.

Int

Whether this policy wants to allow repeat callers (notifications with category Notification.CATEGORY_CALL that have recently called) to play sounds and visually appear or to intercept them when DND is active.

Int

Whether this policy wants to allow system sounds when DND is active.

Int

Whether this policy allows channels marked as NotificationChannel.canBypassDnd() to bypass DND.

Int

Conversation type that can bypass DND.

Int

Message senders that can bypass DND.

Int

Whether this policy allows notifications intercepted by DND from appearing on ambient displays on devices that support ambient display.

Int

Whether this policy allows badges from notifications intercepted by DND on devices that support badging.

Int

Whether this policy allows full screen intents from notifications intercepted by DND.

Int

Whether this policy allows notification from notifications intercepted by DND.

Int

Whether this policy allows notifications intercepted by DND from appearing in notification list views like the notification shade or lockscreen on devices that support those views.

Int

Whether this policy allows peeking from notifications intercepted by DND.

Int

Whether this policy allows notifications intercepted by DND from appearing in the status bar on devices that support status bars.

Int

Returns a hash code value for the object.

String

Returns a string representation of the object.

Unit
writeToParcel(dest: Parcel, flags: Int)

Flatten this object in to a Parcel.

Properties
static Parcelable.Creator<ZenPolicy!>

Constants

CONVERSATION_SENDERS_ANYONE

Added in API level 30
static val CONVERSATION_SENDERS_ANYONE: Int

Used to indicate all conversations can bypass dnd.

Value: 1

CONVERSATION_SENDERS_IMPORTANT

Added in API level 30
static val CONVERSATION_SENDERS_IMPORTANT: Int

Used to indicate important conversations can bypass dnd.

Value: 2

CONVERSATION_SENDERS_NONE

Added in API level 30
static val CONVERSATION_SENDERS_NONE: Int

Used to indicate no conversations can bypass dnd.

Value: 3

CONVERSATION_SENDERS_UNSET

Added in API level 30
static val CONVERSATION_SENDERS_UNSET: Int

Used to indicate no preference for the type of conversations that can bypass dnd.

Value: 0

PEOPLE_TYPE_ANYONE

Added in API level 29
static val PEOPLE_TYPE_ANYONE: Int

Used to indicate all calls or messages can bypass dnd.

Value: 1

PEOPLE_TYPE_CONTACTS

Added in API level 29
static val PEOPLE_TYPE_CONTACTS: Int

Used to indicate calls or messages from contacts can bypass dnd.

Value: 2

PEOPLE_TYPE_NONE

Added in API level 29
static val PEOPLE_TYPE_NONE: Int

Used to indicate no calls or messages can bypass dnd.

Value: 4

PEOPLE_TYPE_STARRED

Added in API level 29
static val PEOPLE_TYPE_STARRED: Int

Used to indicate calls or messages from starred contacts can bypass dnd.

Value: 3

PEOPLE_TYPE_UNSET

Added in API level 29
static val PEOPLE_TYPE_UNSET: Int

Used to indicate no preference for the type of people that can bypass dnd for either calls or messages.

Value: 0

STATE_ALLOW

Added in API level 29
static val STATE_ALLOW: Int

Indicates a type of sound or visual effect is allowed to play/show when DND is active.

Value: 1

STATE_DISALLOW

Added in API level 29
static val STATE_DISALLOW: Int

Indicates a type of sound or visual effect is not allowed to play/show when DND is active.

Value: 2

STATE_UNSET

Added in API level 29
static val STATE_UNSET: Int

Indicates no preference for whether a type of sound or visual effect is or isn't allowed to play/show when DND is active. Will default to the current set policy.

Value: 0

Public methods

describeContents

Added in API level 29
fun describeContents(): Int

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel,int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
Value is either 0 or

equals

Added in API level 29
fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj the reference object with which to compare.
o This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getPriorityCallSenders

Added in API level 29
fun getPriorityCallSenders(): Int

Callers that can bypass DND.

Return
Int PEOPLE_TYPE_UNSET, PEOPLE_TYPE_ANYONE, PEOPLE_TYPE_CONTACTS, PEOPLE_TYPE_STARRED or PEOPLE_TYPE_NONE
Value is one of the following:

getPriorityCategoryAlarms

Added in API level 29
fun getPriorityCategoryAlarms(): Int

Whether this policy wants to allow notifications with category Notification.CATEGORY_ALARM to play sounds and visually appear or to intercept them when DND is active. When alarms are disallowed, the alarm stream will be muted when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW
Value is one of the following:

getPriorityCategoryCalls

Added in API level 29
fun getPriorityCategoryCalls(): Int

Whether this policy wants to allow notifications with category Notification.CATEGORY_CALL to play sounds and visually appear or to intercept them when DND is active. Types of callers that are allowed are specified by getPriorityCallSenders().

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW
Value is one of the following:

getPriorityCategoryConversations

Added in API level 30
fun getPriorityCategoryConversations(): Int

Whether this policy wants to allow conversation notifications (see NotificationChannel.getConversationId()) to play sounds and visually appear or to intercept them when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW
Value is one of the following:

getPriorityCategoryEvents

Added in API level 29
fun getPriorityCategoryEvents(): Int

Whether this policy wants to allow notifications with category Notification.CATEGORY_EVENT to play sounds and visually appear or to intercept them when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW
Value is one of the following:

getPriorityCategoryMedia

Added in API level 29
fun getPriorityCategoryMedia(): Int

Whether this policy wants to allow media notifications to play sounds and visually appear or to intercept them when DND is active. When media is disallowed, the media stream will be muted when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW
Value is one of the following:

getPriorityCategoryMessages

Added in API level 29
fun getPriorityCategoryMessages(): Int

Whether this policy wants to allow notifications with category Notification.CATEGORY_MESSAGE to play sounds and visually appear or to intercept them when DND is active. Types of message senders that are allowed are specified by getPriorityMessageSenders.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW
Value is one of the following:

getPriorityCategoryReminders

Added in API level 29
fun getPriorityCategoryReminders(): Int

Whether this policy wants to allow notifications with category Notification.CATEGORY_REMINDER to play sounds and visually appear or to intercept them when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW
Value is one of the following:

getPriorityCategoryRepeatCallers

Added in API level 29
fun getPriorityCategoryRepeatCallers(): Int

Whether this policy wants to allow repeat callers (notifications with category Notification.CATEGORY_CALL that have recently called) to play sounds and visually appear or to intercept them when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW
Value is one of the following:

getPriorityCategorySystem

Added in API level 29
fun getPriorityCategorySystem(): Int

Whether this policy wants to allow system sounds when DND is active. When system is STATE_DISALLOW, the system stream will be muted when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW
Value is one of the following:

getPriorityChannelsAllowed

Added in API level 35
fun getPriorityChannelsAllowed(): Int

Whether this policy allows channels marked as NotificationChannel.canBypassDnd() to bypass DND. If STATE_ALLOW, these channels may bypass; if STATE_DISALLOW, then even notifications from channels with NotificationChannel.canBypassDnd() will be intercepted.

Return
Int Value is one of the following:

getPriorityConversationSenders

Added in API level 30
fun getPriorityConversationSenders(): Int

Conversation type that can bypass DND.

Return
Int CONVERSATION_SENDERS_UNSET, CONVERSATION_SENDERS_ANYONE, CONVERSATION_SENDERS_IMPORTANT, CONVERSATION_SENDERS_NONE.
Value is one of the following:

getPriorityMessageSenders

Added in API level 29
fun getPriorityMessageSenders(): Int

Message senders that can bypass DND.

Return
Int PEOPLE_TYPE_UNSET, PEOPLE_TYPE_ANYONE, PEOPLE_TYPE_CONTACTS, PEOPLE_TYPE_STARRED or PEOPLE_TYPE_NONE
Value is one of the following:

getVisualEffectAmbient

Added in API level 29
fun getVisualEffectAmbient(): Int

Whether this policy allows notifications intercepted by DND from appearing on ambient displays on devices that support ambient display.

Return
Int Value is one of the following:

getVisualEffectBadge

Added in API level 29
fun getVisualEffectBadge(): Int

Whether this policy allows badges from notifications intercepted by DND on devices that support badging.

Return
Int Value is one of the following:

getVisualEffectFullScreenIntent

Added in API level 29
fun getVisualEffectFullScreenIntent(): Int

Whether this policy allows full screen intents from notifications intercepted by DND.

Return
Int Value is one of the following:

getVisualEffectLights

Added in API level 29
fun getVisualEffectLights(): Int

Whether this policy allows notification from notifications intercepted by DND.

Return
Int Value is one of the following:

getVisualEffectNotificationList

Added in API level 29
fun getVisualEffectNotificationList(): Int

Whether this policy allows notifications intercepted by DND from appearing in notification list views like the notification shade or lockscreen on devices that support those views.

Return
Int Value is one of the following:

getVisualEffectPeek

Added in API level 29
fun getVisualEffectPeek(): Int

Whether this policy allows peeking from notifications intercepted by DND.

Return
Int Value is one of the following:

getVisualEffectStatusBar

Added in API level 29
fun getVisualEffectStatusBar(): Int

Whether this policy allows notifications intercepted by DND from appearing in the status bar on devices that support status bars.

Return
Int Value is one of the following:

hashCode

Added in API level 29
fun hashCode(): Int

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Return
Int a hash code value for this object.

toString

Added in API level 29
fun toString(): String

Returns a string representation of the object.

Return
String a string representation of the object.

writeToParcel

Added in API level 29
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written.
This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.
Value is either 0 or a combination of the following:

Properties

CREATOR

Added in API level 29
static val CREATOR: Parcelable.Creator<ZenPolicy!>