summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2016-11-28 14:29:25 -0500
committerJulia Reynolds <juliacr@google.com>2017-01-25 09:28:01 -0500
commit2a128746b3466e75b6040147fa831fe12cc2ccbb (patch)
treefb778ee1cd1053781df4b6612ed06757ccedacb1 /core/java/android
parent573c6537081ab83e2f083e8057c7137e5754f423 (diff)
Allow notifications to be autocanceled at a time.
Test: cts Change-Id: I24ebcab2c0fa2028ec5d2984dc3b7ec19391b590
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/Notification.java20
-rw-r--r--core/java/android/service/notification/NotificationListenerService.java4
2 files changed, 22 insertions, 2 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 82917d27d0d6..4172ed7e57ea 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1022,6 +1022,7 @@ public class Notification implements Parcelable
private Icon mLargeIcon;
private String mChannelId;
+ private long mTimeout;
/**
* Structure to encapsulate a named action that can be shown as part of this notification.
@@ -1766,6 +1767,7 @@ public class Notification implements Parcelable
if (parcel.readInt() != 0) {
mChannelId = parcel.readString();
}
+ mTimeout = parcel.readLong();
}
@Override
@@ -1872,6 +1874,7 @@ public class Notification implements Parcelable
that.color = this.color;
that.mChannelId = this.mChannelId;
+ that.mTimeout = this.mTimeout;
if (!heavy) {
that.lightenPayload(); // will clean out extras
@@ -2128,6 +2131,7 @@ public class Notification implements Parcelable
} else {
parcel.writeInt(0);
}
+ parcel.writeLong(mTimeout);
}
/**
@@ -2325,6 +2329,13 @@ public class Notification implements Parcelable
}
/**
+ * Returns the time at which this notification should be canceled, if it's not canceled already.
+ */
+ public long getTimeout() {
+ return mTimeout;
+ }
+
+ /**
* The small icon representing this notification in the status bar and content view.
*
* @return the small icon representing this notification.
@@ -2532,6 +2543,15 @@ public class Notification implements Parcelable
}
/**
+ * Specifies the time at which this notification should be canceled, if it is not already
+ * canceled.
+ */
+ public Builder setTimeout(long when) {
+ mN.mTimeout = when;
+ return this;
+ }
+
+ /**
* Add a timestamp pertaining to the notification (usually the time the event occurred).
*
* For apps targeting {@link android.os.Build.VERSION_CODES#N} and above, this time is not
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 517b305e0a16..417be602be5b 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -183,8 +183,8 @@ public abstract class NotificationListenerService extends Service {
public static final int REASON_CHANNEL_BANNED = 17;
/** Notification was snoozed. */
public static final int REASON_SNOOZED = 18;
- /** Notification no longer visible because of user switch */
- public static final int REASON_USER_SWITCH = 19;
+ /** Notification was canceled due to timeout */
+ public static final int REASON_TIMEOUT = 19;
/**
* The full trim of the StatusBarNotification including all its features.