diff options
| author | Jeff Sharkey <jsharkey@google.com> | 2018-04-19 14:58:02 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-04-19 14:58:02 +0000 |
| commit | 1cd96854d4b396fa083fe2cd58b94a111f7a12cb (patch) | |
| tree | 6a94777cedba7d916b67f862179a8a984a3c7d36 /core/java/android/app/Notification.java | |
| parent | 4fca6d6b31c457118f8691f62b538e076f8f3b9e (diff) | |
| parent | 23b3118f288d2beff0519ca294baac8093995989 (diff) | |
Merge "Visit Uris in RemoteViews for granting purposes." into pi-dev
Diffstat (limited to 'core/java/android/app/Notification.java')
| -rw-r--r-- | core/java/android/app/Notification.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 22da924d1b8f..4f88a03db435 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -91,6 +91,7 @@ import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Set; +import java.util.function.Consumer; /** * A class that represents how a persistent notification is to be presented to @@ -2306,6 +2307,45 @@ public class Notification implements Parcelable } /** + * Note all {@link Uri} that are referenced internally, with the expectation + * that Uri permission grants will need to be issued to ensure the recipient + * of this object is able to render its contents. + * + * @hide + */ + public void visitUris(@NonNull Consumer<Uri> visitor) { + visitor.accept(sound); + + if (tickerView != null) tickerView.visitUris(visitor); + if (contentView != null) contentView.visitUris(visitor); + if (bigContentView != null) bigContentView.visitUris(visitor); + if (headsUpContentView != null) headsUpContentView.visitUris(visitor); + + if (extras != null) { + visitor.accept(extras.getParcelable(EXTRA_AUDIO_CONTENTS_URI)); + visitor.accept(extras.getParcelable(EXTRA_BACKGROUND_IMAGE_URI)); + } + + if (MessagingStyle.class.equals(getNotificationStyle()) && extras != null) { + final Parcelable[] messages = extras.getParcelableArray(EXTRA_MESSAGES); + if (!ArrayUtils.isEmpty(messages)) { + for (MessagingStyle.Message message : MessagingStyle.Message + .getMessagesFromBundleArray(messages)) { + visitor.accept(message.getDataUri()); + } + } + + final Parcelable[] historic = extras.getParcelableArray(EXTRA_HISTORIC_MESSAGES); + if (!ArrayUtils.isEmpty(historic)) { + for (MessagingStyle.Message message : MessagingStyle.Message + .getMessagesFromBundleArray(historic)) { + visitor.accept(message.getDataUri()); + } + } + } + } + + /** * Removes heavyweight parts of the Notification object for archival or for sending to * listeners when the full contents are not necessary. * @hide |
