diff options
| author | 2024-08-22 10:03:56 +0000 | |
|---|---|---|
| committer | 2024-08-22 10:03:56 +0000 | |
| commit | 0a3dcfeed5e9332b02f546236ea6b274b1b0d47e (patch) | |
| tree | 3fec22ae4576dd0589fbc19c7f2414f16cee5f50 | |
| parent | dda07ea9e4c0b8b2117cc10650b9f837ec960525 (diff) | |
| parent | cf887f52946d7e740fa29ea05baa21fed0e113fe (diff) | |
Merge "Check more URIs in notifications" into sc-dev am: 9b874d3559 am: 01b4536dd1 am: a12cfb552e am: cf887f5294
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/28470438
Change-Id: I0ec45889dcb91d14f7e7a618b0b8bf0d664276f9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | core/java/android/app/Notification.java | 32 | ||||
| -rw-r--r-- | core/java/android/app/Person.java | 17 | ||||
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 23 |
3 files changed, 57 insertions, 15 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index aff21ef9c5b8..787d920ba992 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -2854,7 +2854,7 @@ public class Notification implements Parcelable Person.class); if (people != null && !people.isEmpty()) { for (Person p : people) { - visitor.accept(p.getIconUri()); + p.visitUris(visitor); } } @@ -2874,7 +2874,7 @@ public class Notification implements Parcelable // Notification Listeners might use directly (without the isStyle check). final Person person = extras.getParcelable(EXTRA_MESSAGING_PERSON, Person.class); if (person != null) { - visitor.accept(person.getIconUri()); + person.visitUris(visitor); } final Parcelable[] messages = extras.getParcelableArray(EXTRA_MESSAGES, @@ -2882,12 +2882,7 @@ public class Notification implements Parcelable if (!ArrayUtils.isEmpty(messages)) { for (MessagingStyle.Message message : MessagingStyle.Message .getMessagesFromBundleArray(messages)) { - visitor.accept(message.getDataUri()); - - Person senderPerson = message.getSenderPerson(); - if (senderPerson != null) { - visitor.accept(senderPerson.getIconUri()); - } + message.visitUris(visitor); } } @@ -2896,12 +2891,7 @@ public class Notification implements Parcelable if (!ArrayUtils.isEmpty(historic)) { for (MessagingStyle.Message message : MessagingStyle.Message .getMessagesFromBundleArray(historic)) { - visitor.accept(message.getDataUri()); - - Person senderPerson = message.getSenderPerson(); - if (senderPerson != null) { - visitor.accept(senderPerson.getIconUri()); - } + message.visitUris(visitor); } } @@ -2910,7 +2900,7 @@ public class Notification implements Parcelable // Extras for CallStyle (same reason for visiting without checking isStyle). Person callPerson = extras.getParcelable(EXTRA_CALL_PERSON, Person.class); if (callPerson != null) { - visitor.accept(callPerson.getIconUri()); + callPerson.visitUris(visitor); } visitIconUri(visitor, extras.getParcelable(EXTRA_VERIFICATION_ICON, Icon.class)); } @@ -8755,6 +8745,18 @@ public class Notification implements Parcelable } /** + * See {@link Notification#visitUris(Consumer)}. + * + * @hide + */ + public void visitUris(@NonNull Consumer<Uri> visitor) { + visitor.accept(getDataUri()); + if (mSender != null) { + mSender.visitUris(visitor); + } + } + + /** * Returns a list of messages read from the given bundle list, e.g. * {@link #EXTRA_MESSAGES} or {@link #EXTRA_HISTORIC_MESSAGES}. */ diff --git a/core/java/android/app/Person.java b/core/java/android/app/Person.java index 97a794d4e4ea..c7432c571e43 100644 --- a/core/java/android/app/Person.java +++ b/core/java/android/app/Person.java @@ -24,6 +24,7 @@ import android.os.Parcel; import android.os.Parcelable; import java.util.Objects; +import java.util.function.Consumer; /** * Provides an immutable reference to an entity that appears repeatedly on different surfaces of the @@ -177,6 +178,22 @@ public final class Person implements Parcelable { dest.writeBoolean(mIsBot); } + /** + * 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. + * See b/281044385 for more context and examples about what happens when this isn't done + * correctly. + * + * @hide + */ + public void visitUris(@NonNull Consumer<Uri> visitor) { + visitor.accept(getIconUri()); + if (mUri != null && !mUri.isEmpty()) { + visitor.accept(Uri.parse(mUri)); + } + } + /** Builder for the immutable {@link Person} class. */ public static class Builder { @Nullable private CharSequence mName; diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 6b3645f0c33a..cb5dff024ff7 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -960,6 +960,13 @@ public class RemoteViews implements Parcelable, Filter { return SET_REMOTE_VIEW_ADAPTER_LIST_TAG; } + @Override + public void visitUris(@NonNull Consumer<Uri> visitor) { + for (RemoteViews remoteViews : list) { + remoteViews.visitUris(visitor); + } + } + int viewTypeCount; ArrayList<RemoteViews> list; } @@ -1082,6 +1089,13 @@ public class RemoteViews implements Parcelable, Filter { public int getActionTag() { return SET_REMOTE_COLLECTION_ITEMS_ADAPTER_TAG; } + + @Override + public void visitUris(@NonNull Consumer<Uri> visitor) { + if (mItems != null) { + mItems.visitUris(visitor); + } + } } private class SetRemoteViewsAdapterIntent extends Action { @@ -7009,6 +7023,15 @@ public class RemoteViews implements Parcelable, Filter { Math.max(mViewTypeCount, 1)); } } + + /** + * See {@link RemoteViews#visitUris(Consumer)}. + */ + private void visitUris(@NonNull Consumer<Uri> visitor) { + for (RemoteViews view : mViews) { + view.visitUris(visitor); + } + } } /** |