Merge "Add visitUri method to Person and MessagingStyle.Message." into udc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
75acc33927
@@ -2833,12 +2833,14 @@ public class Notification implements Parcelable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note all {@link Uri} that are referenced internally, with the expectation
|
* Note all {@link Uri} that are referenced internally, with the expectation that Uri permission
|
||||||
* that Uri permission grants will need to be issued to ensure the recipient
|
* grants will need to be issued to ensure the recipient of this object is able to render its
|
||||||
* of this object is able to render its contents.
|
* contents.
|
||||||
*
|
* See b/281044385 for more context and examples about what happens when this isn't done
|
||||||
* @hide
|
* correctly.
|
||||||
*/
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
public void visitUris(@NonNull Consumer<Uri> visitor) {
|
public void visitUris(@NonNull Consumer<Uri> visitor) {
|
||||||
if (publicVersion != null) {
|
if (publicVersion != null) {
|
||||||
publicVersion.visitUris(visitor);
|
publicVersion.visitUris(visitor);
|
||||||
@@ -2882,13 +2884,13 @@ public class Notification implements Parcelable
|
|||||||
ArrayList<Person> people = extras.getParcelableArrayList(EXTRA_PEOPLE_LIST, android.app.Person.class);
|
ArrayList<Person> people = extras.getParcelableArrayList(EXTRA_PEOPLE_LIST, android.app.Person.class);
|
||||||
if (people != null && !people.isEmpty()) {
|
if (people != null && !people.isEmpty()) {
|
||||||
for (Person p : people) {
|
for (Person p : people) {
|
||||||
visitor.accept(p.getIconUri());
|
p.visitUris(visitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Person person = extras.getParcelable(EXTRA_MESSAGING_PERSON, Person.class);
|
final Person person = extras.getParcelable(EXTRA_MESSAGING_PERSON, Person.class);
|
||||||
if (person != null) {
|
if (person != null) {
|
||||||
visitor.accept(person.getIconUri());
|
person.visitUris(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
final RemoteInputHistoryItem[] history = extras.getParcelableArray(
|
final RemoteInputHistoryItem[] history = extras.getParcelableArray(
|
||||||
@@ -2910,12 +2912,7 @@ public class Notification implements Parcelable
|
|||||||
if (!ArrayUtils.isEmpty(messages)) {
|
if (!ArrayUtils.isEmpty(messages)) {
|
||||||
for (MessagingStyle.Message message : MessagingStyle.Message
|
for (MessagingStyle.Message message : MessagingStyle.Message
|
||||||
.getMessagesFromBundleArray(messages)) {
|
.getMessagesFromBundleArray(messages)) {
|
||||||
visitor.accept(message.getDataUri());
|
message.visitUris(visitor);
|
||||||
|
|
||||||
Person senderPerson = message.getSenderPerson();
|
|
||||||
if (senderPerson != null) {
|
|
||||||
visitor.accept(senderPerson.getIconUri());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2924,12 +2921,7 @@ public class Notification implements Parcelable
|
|||||||
if (!ArrayUtils.isEmpty(historic)) {
|
if (!ArrayUtils.isEmpty(historic)) {
|
||||||
for (MessagingStyle.Message message : MessagingStyle.Message
|
for (MessagingStyle.Message message : MessagingStyle.Message
|
||||||
.getMessagesFromBundleArray(historic)) {
|
.getMessagesFromBundleArray(historic)) {
|
||||||
visitor.accept(message.getDataUri());
|
message.visitUris(visitor);
|
||||||
|
|
||||||
Person senderPerson = message.getSenderPerson();
|
|
||||||
if (senderPerson != null) {
|
|
||||||
visitor.accept(senderPerson.getIconUri());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2939,7 +2931,7 @@ public class Notification implements Parcelable
|
|||||||
if (isStyle(CallStyle.class) & extras != null) {
|
if (isStyle(CallStyle.class) & extras != null) {
|
||||||
Person callPerson = extras.getParcelable(EXTRA_CALL_PERSON, Person.class);
|
Person callPerson = extras.getParcelable(EXTRA_CALL_PERSON, Person.class);
|
||||||
if (callPerson != null) {
|
if (callPerson != null) {
|
||||||
visitor.accept(callPerson.getIconUri());
|
callPerson.visitUris(visitor);
|
||||||
}
|
}
|
||||||
visitIconUri(visitor, extras.getParcelable(EXTRA_VERIFICATION_ICON, Icon.class));
|
visitIconUri(visitor, extras.getParcelable(EXTRA_VERIFICATION_ICON, Icon.class));
|
||||||
}
|
}
|
||||||
@@ -8832,6 +8824,18 @@ public class Notification implements Parcelable
|
|||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Returns a list of messages read from the given bundle list, e.g.
|
||||||
* {@link #EXTRA_MESSAGES} or {@link #EXTRA_HISTORIC_MESSAGES}.
|
* {@link #EXTRA_MESSAGES} or {@link #EXTRA_HISTORIC_MESSAGES}.
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an immutable reference to an entity that appears repeatedly on different surfaces of the
|
* Provides an immutable reference to an entity that appears repeatedly on different surfaces of the
|
||||||
@@ -177,6 +178,19 @@ public final class Person implements Parcelable {
|
|||||||
dest.writeBoolean(mIsBot);
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
/** Builder for the immutable {@link Person} class. */
|
/** Builder for the immutable {@link Person} class. */
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
@Nullable private CharSequence mName;
|
@Nullable private CharSequence mName;
|
||||||
|
|||||||
Reference in New Issue
Block a user