Skip to content

Commit

Permalink
Verify URI permissions for EXTRA_REMOTE_INPUT_HISTORY_ITEMS.
Browse files Browse the repository at this point in the history
Also added a step to serialize & deserialize the notification in the
test, to prevent exceptions about not being able to cast e.g.
Parcelable[] to RemoteInputHistoryItem[].

Test: atest NotificationManagerServiceTest & tested with POC from bug
Bug: 276729064
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:4e19431a60300c6ea6c7f7dd64299916e4eb09bc)
Merged-In: I7053ca59f9c7f1df5226418594109cfb8b609b1e
Change-Id: I7053ca59f9c7f1df5226418594109cfb8b609b1e
  • Loading branch information
Ioana Alexandru authored and thestinger committed Oct 3, 2023
1 parent d1765c4 commit cbb1a0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/java/android/app/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -2858,8 +2858,9 @@ public void visitUris(@NonNull Consumer<Uri> visitor) {
visitor.accept(person.getIconUri());
}

final RemoteInputHistoryItem[] history = (RemoteInputHistoryItem[])
extras.getParcelableArray(Notification.EXTRA_REMOTE_INPUT_HISTORY_ITEMS);
final RemoteInputHistoryItem[] history = extras.getParcelableArray(
Notification.EXTRA_REMOTE_INPUT_HISTORY_ITEMS,
RemoteInputHistoryItem.class);
if (history != null) {
for (int i = 0; i < history.length; i++) {
RemoteInputHistoryItem item = history[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5439,6 +5439,13 @@ public void testVisitUris() throws Exception {
.addExtras(extras)
.build();

// Serialize and deserialize the notification to make sure nothing breaks in the process,
// since that's what will usually happen before we get to call visitUris.
Parcel parcel = Parcel.obtain();
n.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
n = new Notification(parcel);

Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class);
n.visitUris(visitor);
verify(visitor, times(1)).accept(eq(audioContents));
Expand Down

0 comments on commit cbb1a0e

Please sign in to comment.