Allow notifications to be autocanceled at a time.
Test: cts
Change-Id: I24ebcab2c0fa2028ec5d2984dc3b7ec19391b590
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 82917d2..4172ed7 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1022,6 +1022,7 @@
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 @@
if (parcel.readInt() != 0) {
mChannelId = parcel.readString();
}
+ mTimeout = parcel.readLong();
}
@Override
@@ -1872,6 +1874,7 @@
that.color = this.color;
that.mChannelId = this.mChannelId;
+ that.mTimeout = this.mTimeout;
if (!heavy) {
that.lightenPayload(); // will clean out extras
@@ -2128,6 +2131,7 @@
} else {
parcel.writeInt(0);
}
+ parcel.writeLong(mTimeout);
}
/**
@@ -2325,6 +2329,13 @@
}
/**
+ * 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 @@
}
/**
+ * 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