From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Wed, 29 Jan 2020 11:41:58 -0800 Subject: [PATCH] Make sure we visit the icon URIs of Person objects on Notifications Test: manual - have bubbles test app with uri based icons, send notifs, notice the notifications show pictures of people instead of blank spaces & there are no exceptions in the logs Fixes: 148543216 Change-Id: Idfb7c75d9c5541f2dcebfb0f20daa99f039f4181 --- core/java/android/app/Notification.java | 24 ++++++++++++++++++++++++ core/java/android/app/Person.java | 14 ++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 9d0a5e93e2d8..068e85b24321 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -2482,6 +2482,20 @@ public class Notification implements Parcelable if (extras.containsKey(EXTRA_BACKGROUND_IMAGE_URI)) { visitor.accept(Uri.parse(extras.getString(EXTRA_BACKGROUND_IMAGE_URI))); } + + ArrayList people = extras.getParcelableArrayList(EXTRA_PEOPLE_LIST); + if (people != null && !people.isEmpty()) { + for (Person p : people) { + if (p.getIconUri() != null) { + visitor.accept(p.getIconUri()); + } + } + } + + final Person person = extras.getParcelable(EXTRA_MESSAGING_PERSON); + if (person != null && person.getIconUri() != null) { + visitor.accept(person.getIconUri()); + } } if (MessagingStyle.class.equals(getNotificationStyle()) && extras != null) { @@ -2490,6 +2504,11 @@ public class Notification implements Parcelable for (MessagingStyle.Message message : MessagingStyle.Message .getMessagesFromBundleArray(messages)) { visitor.accept(message.getDataUri()); + + Person senderPerson = message.getSenderPerson(); + if (senderPerson != null && senderPerson.getIconUri() != null) { + visitor.accept(senderPerson.getIconUri()); + } } } @@ -2498,6 +2517,11 @@ public class Notification implements Parcelable for (MessagingStyle.Message message : MessagingStyle.Message .getMessagesFromBundleArray(historic)) { visitor.accept(message.getDataUri()); + + Person senderPerson = message.getSenderPerson(); + if (senderPerson != null && senderPerson.getIconUri() != null) { + visitor.accept(senderPerson.getIconUri()); + } } } } diff --git a/core/java/android/app/Person.java b/core/java/android/app/Person.java index 14a5589c04c2..b5820ba70020 100644 --- a/core/java/android/app/Person.java +++ b/core/java/android/app/Person.java @@ -19,6 +19,7 @@ package android.app; import android.annotation.NonNull; import android.annotation.Nullable; import android.graphics.drawable.Icon; +import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; @@ -122,6 +123,19 @@ public final class Person implements Parcelable { return ""; } + /** + * @return the URI associated with the {@link #getIcon()} for this person, iff the icon exists + * and is URI based. + * @hide + */ + @Nullable + public Uri getIconUri() { + if (mIcon != null && mIcon.getType() == Icon.TYPE_URI) { + return mIcon.getUri(); + } + return null; + } + @Override public boolean equals(Object obj) { if (obj instanceof Person) {