mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-10-01 01:35:54 -04:00
103 lines
5.5 KiB
Diff
103 lines
5.5 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Ioana Alexandru <aioana@google.com>
|
||
|
Date: Fri, 21 Apr 2023 15:39:22 +0000
|
||
|
Subject: [PATCH] Verify URI permissions for EXTRA_REMOTE_INPUT_HISTORY_ITEMS.
|
||
|
|
||
|
Also added the person URIs in the test, since they weren't being
|
||
|
checked.
|
||
|
|
||
|
Test: atest NotificationManagerServiceTest & tested with POC from bug
|
||
|
Bug: 276729064
|
||
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e0d8602a0200ba92283463bd54cefcf97394bfa8)
|
||
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:63f8ce3efd9a564ae83f1de38791a6d67c5a8ddb)
|
||
|
Merged-In: I848545f7aee202495c515f47a32871a2cb6ae707
|
||
|
Change-Id: I848545f7aee202495c515f47a32871a2cb6ae707
|
||
|
---
|
||
|
core/java/android/app/Notification.java | 11 +++++++
|
||
|
.../NotificationManagerServiceTest.java | 32 +++++++++++++++++++
|
||
|
2 files changed, 43 insertions(+)
|
||
|
|
||
|
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
|
||
|
index 3e75c52bf893..9fe3583df601 100644
|
||
|
--- a/core/java/android/app/Notification.java
|
||
|
+++ b/core/java/android/app/Notification.java
|
||
|
@@ -2454,6 +2454,17 @@ public class Notification implements Parcelable
|
||
|
if (extras.containsKey(EXTRA_BACKGROUND_IMAGE_URI)) {
|
||
|
visitor.accept(Uri.parse(extras.getString(EXTRA_BACKGROUND_IMAGE_URI)));
|
||
|
}
|
||
|
+
|
||
|
+ final RemoteInputHistoryItem[] history = (RemoteInputHistoryItem[])
|
||
|
+ extras.getParcelableArray(Notification.EXTRA_REMOTE_INPUT_HISTORY_ITEMS);
|
||
|
+ if (history != null) {
|
||
|
+ for (int i = 0; i < history.length; i++) {
|
||
|
+ RemoteInputHistoryItem item = history[i];
|
||
|
+ if (item.getUri() != null) {
|
||
|
+ visitor.accept(item.getUri());
|
||
|
+ }
|
||
|
+ }
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
if (MessagingStyle.class.equals(getNotificationStyle()) && extras != null) {
|
||
|
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
|
||
|
index 6c1620751866..b2ce41f5b373 100755
|
||
|
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
|
||
|
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
|
||
|
@@ -93,6 +93,7 @@ import android.app.NotificationManager;
|
||
|
import android.app.PendingIntent;
|
||
|
import android.app.Person;
|
||
|
import android.app.RemoteInput;
|
||
|
+import android.app.RemoteInputHistoryItem;
|
||
|
import android.app.admin.DevicePolicyManagerInternal;
|
||
|
import android.app.usage.UsageStatsManagerInternal;
|
||
|
import android.companion.ICompanionDeviceManager;
|
||
|
@@ -3414,10 +3415,36 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
||
|
public void testVisitUris() throws Exception {
|
||
|
final Uri audioContents = Uri.parse("content://com.example/audio");
|
||
|
final Uri backgroundImage = Uri.parse("content://com.example/background");
|
||
|
+ final Icon personIcon1 = Icon.createWithContentUri("content://media/person1");
|
||
|
+ final Icon personIcon2 = Icon.createWithContentUri("content://media/person2");
|
||
|
+ final Icon personIcon3 = Icon.createWithContentUri("content://media/person3");
|
||
|
+ final Person person1 = new Person.Builder()
|
||
|
+ .setName("Messaging Person")
|
||
|
+ .setIcon(personIcon1)
|
||
|
+ .build();
|
||
|
+ final Person person2 = new Person.Builder()
|
||
|
+ .setName("People List Person 1")
|
||
|
+ .setIcon(personIcon2)
|
||
|
+ .build();
|
||
|
+ final Person person3 = new Person.Builder()
|
||
|
+ .setName("People List Person 2")
|
||
|
+ .setIcon(personIcon3)
|
||
|
+ .build();
|
||
|
+ final Uri historyUri1 = Uri.parse("content://com.example/history1");
|
||
|
+ final Uri historyUri2 = Uri.parse("content://com.example/history2");
|
||
|
+ final RemoteInputHistoryItem historyItem1 = new RemoteInputHistoryItem(null, historyUri1,
|
||
|
+ "a");
|
||
|
+ final RemoteInputHistoryItem historyItem2 = new RemoteInputHistoryItem(null, historyUri2,
|
||
|
+ "b");
|
||
|
|
||
|
Bundle extras = new Bundle();
|
||
|
extras.putParcelable(Notification.EXTRA_AUDIO_CONTENTS_URI, audioContents);
|
||
|
extras.putString(Notification.EXTRA_BACKGROUND_IMAGE_URI, backgroundImage.toString());
|
||
|
+ extras.putParcelable(Notification.EXTRA_MESSAGING_PERSON, person1);
|
||
|
+ extras.putParcelableArrayList(Notification.EXTRA_PEOPLE_LIST,
|
||
|
+ new ArrayList<>(Arrays.asList(person2, person3)));
|
||
|
+ extras.putParcelableArray(Notification.EXTRA_REMOTE_INPUT_HISTORY_ITEMS,
|
||
|
+ new RemoteInputHistoryItem[]{historyItem1, historyItem2});
|
||
|
|
||
|
Notification n = new Notification.Builder(mContext, "a")
|
||
|
.setContentTitle("notification with uris")
|
||
|
@@ -3429,6 +3456,11 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
||
|
n.visitUris(visitor);
|
||
|
verify(visitor, times(1)).accept(eq(audioContents));
|
||
|
verify(visitor, times(1)).accept(eq(backgroundImage));
|
||
|
+ verify(visitor, times(1)).accept(eq(personIcon1.getUri()));
|
||
|
+ verify(visitor, times(1)).accept(eq(personIcon2.getUri()));
|
||
|
+ verify(visitor, times(1)).accept(eq(personIcon3.getUri()));
|
||
|
+ verify(visitor, times(1)).accept(eq(historyUri1));
|
||
|
+ verify(visitor, times(1)).accept(eq(historyUri2));
|
||
|
}
|
||
|
|
||
|
@Test
|