diff options
| author | 2017-01-20 10:39:22 -0800 | |
|---|---|---|
| committer | 2017-01-20 15:45:09 -0800 | |
| commit | b8a04eee40f7436149ac87a4dc84101c54320943 (patch) | |
| tree | 5e5e257d6f9bb1ef4ce85eab85c118639174dd81 | |
| parent | 9e9cfd93f18433cf9640126e7b1cd3d07f205c6c (diff) | |
Adding TvExtender channel override
The rationale is that the notification importance on TV doesn't
always align with their importance on other devices.
Thus we need the ability to post notification to different
channels just on TV.
Test: ag/1808384
Change-Id: I90a84e3f74d59ca45dac3c6414285bed26482008
| -rw-r--r-- | api/system-current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/app/Notification.java | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index ab064390255e..a178d2a8f83f 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5482,9 +5482,11 @@ package android.app { ctor public Notification.TvExtender(); ctor public Notification.TvExtender(android.app.Notification); method public android.app.Notification.Builder extend(android.app.Notification.Builder); + method public java.lang.String getChannel(); method public android.app.PendingIntent getContentIntent(); method public android.app.PendingIntent getDeleteIntent(); method public boolean isAvailableOnTv(); + method public android.app.Notification.TvExtender setChannel(java.lang.String); method public android.app.Notification.TvExtender setContentIntent(android.app.PendingIntent); method public android.app.Notification.TvExtender setDeleteIntent(android.app.PendingIntent); } diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 69f4cc0bdc9d..6033bfa493a2 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -6982,11 +6982,13 @@ public class Notification implements Parcelable private static final String EXTRA_FLAGS = "flags"; private static final String EXTRA_CONTENT_INTENT = "content_intent"; private static final String EXTRA_DELETE_INTENT = "delete_intent"; + private static final String EXTRA_CHANNEL_ID = "channel_id"; // Flags bitwise-ored to mFlags private static final int FLAG_AVAILABLE_ON_TV = 0x1; private int mFlags; + private String mChannelId; private PendingIntent mContentIntent; private PendingIntent mDeleteIntent; @@ -7007,6 +7009,7 @@ public class Notification implements Parcelable null : notif.extras.getBundle(EXTRA_TV_EXTENDER); if (bundle != null) { mFlags = bundle.getInt(EXTRA_FLAGS); + mChannelId = bundle.getString(EXTRA_CHANNEL_ID); mContentIntent = bundle.getParcelable(EXTRA_CONTENT_INTENT); mDeleteIntent = bundle.getParcelable(EXTRA_DELETE_INTENT); } @@ -7022,6 +7025,7 @@ public class Notification implements Parcelable Bundle bundle = new Bundle(); bundle.putInt(EXTRA_FLAGS, mFlags); + bundle.putString(EXTRA_CHANNEL_ID, mChannelId); if (mContentIntent != null) { bundle.putParcelable(EXTRA_CONTENT_INTENT, mContentIntent); } @@ -7043,6 +7047,23 @@ public class Notification implements Parcelable } /** + * Specifies the channel the notification should be delivered on when shown on TV. + * It can be different from the channel that the notification is delivered to when + * posting on a non-TV device. + */ + public TvExtender setChannel(String channelId) { + mChannelId = channelId; + return this; + } + + /** + * Returns the id of the channel this notification posts to on TV. + */ + public String getChannel() { + return mChannelId; + } + + /** * Supplies a {@link PendingIntent} to be sent when the notification is selected on TV. * If provided, it is used instead of the content intent specified * at the level of Notification. |