1- From c0c16283997bbca63edc79d820652587cbde15bb Mon Sep 17 00:00:00 2001
1+ From 179a5a7b48c4ec3ffebbf53b9833f6be6ef4e2b1 Mon Sep 17 00:00:00 2001
22From: Valentin Iftime <
[email protected] >
33Date: Thu, 1 Feb 2024 13:58:49 +0100
44Subject: [PATCH] Verify URI permission for channel sound update from
@@ -10,19 +10,19 @@ Subject: [PATCH] Verify URI permission for channel sound update from
1010Test: atest com.android.server.notification.NotificationManagerServiceTest#testUpdateNotificationChannelFromPrivilegedListener_noSoundUriPermission
1111Bug: 317357401
1212(cherry picked from commit 9b7bbbf5ad542ecf9ecbf8cd819b468791b443c0)
13- (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2f26c0def503d3b8032c99adc8a11be87e35cdeb )
13+ (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f090c0538a27d8658d8a860046d5c5e931302341 )
1414Merged-In: Ic7d2e96e43565e98d2aa29b8f2ba35c142387ba9
1515Change-Id: Ic7d2e96e43565e98d2aa29b8f2ba35c142387ba9
1616---
17- .../NotificationManagerService.java | 22 +++++++
18- .../NotificationManagerServiceTest.java | 63 +++++++++++++++++++
19- 2 files changed, 85 insertions(+)
17+ .../NotificationManagerService.java | 22 ++++++
18+ .../NotificationManagerServiceTest.java | 67 +++++++++++++++++++
19+ 2 files changed, 89 insertions(+)
2020
2121diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
22- index ecd446519c09..4d1abc61aa73 100755
22+ index dfc9c135c7da7..40f6ed45174e2 100755
2323--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
2424+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
25- @@ -5705 ,6 +5705 ,10 @@ public void updateNotificationChannelFromPrivilegedListener(INotificationListene
25+ @@ -5151 ,6 +5151 ,10 @@ public void updateNotificationChannelFromPrivilegedListener(INotificationListene
2626 Objects.requireNonNull(user);
2727
2828 verifyPrivilegedListener(token, user, false);
@@ -33,7 +33,7 @@ index ecd446519c09..4d1abc61aa73 100755
3333 updateNotificationChannelInt(pkg, getUidForPackageAndUser(pkg, user), channel, true);
3434 }
3535
36- @@ -5796 ,6 +5800 ,24 @@ private void verifyPrivilegedListener(INotificationListener token, UserHandle us
36+ @@ -5230 ,6 +5234 ,24 @@ private void verifyPrivilegedListener(INotificationListener token, UserHandle us
3737 }
3838 }
3939
@@ -56,22 +56,24 @@ index ecd446519c09..4d1abc61aa73 100755
5656+ }
5757+
5858 private int getUidForPackageAndUser(String pkg, UserHandle user) throws RemoteException {
59- int uid = INVALID_UID ;
60- final long identity = Binder.clearCallingIdentity();
59+ int uid = 0 ;
60+ long identity = Binder.clearCallingIdentity();
6161diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
62- index 4f0a7ca0ad51..755bc1d35cf3 100755
62+ index 011c408492fa3..a1d6b56ff9cdb 100755
6363--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
6464+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
65- @@ -3319 ,6 +3319,69 @@ public void testUpdateNotificationChannelFromPrivilegedListener_badUser() throws
65+ @@ -2664 ,6 +2664,73 @@ public void testUpdateNotificationChannelFromPrivilegedListener_badUser() throws
6666 eq(NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_UPDATED));
6767 }
6868
6969+ @Test
7070+ public void testUpdateNotificationChannelFromPrivilegedListener_noSoundUriPermission()
7171+ throws Exception {
7272+ mService.setPreferencesHelper(mPreferencesHelper);
73+ + List<String> associations = new ArrayList<>();
74+ + associations.add("a");
7375+ when(mCompanionMgr.getAssociations(PKG, UserHandle.getUserId(mUid)))
74- + .thenReturn(singletonList(mock(AssociationInfo.class)) );
76+ + .thenReturn(associations );
7577+ when(mPreferencesHelper.getNotificationChannel(eq(PKG), anyInt(),
7678+ eq(mTestNotificationChannel.getId()), anyBoolean()))
7779+ .thenReturn(mTestNotificationChannel);
@@ -102,8 +104,10 @@ index 4f0a7ca0ad51..755bc1d35cf3 100755
102104+ public void testUpdateNotificationChannelFromPrivilegedListener_noSoundUriPermission_sameSound()
103105+ throws Exception {
104106+ mService.setPreferencesHelper(mPreferencesHelper);
107+ + List<String> associations = new ArrayList<>();
108+ + associations.add("a");
105109+ when(mCompanionMgr.getAssociations(PKG, UserHandle.getUserId(mUid)))
106- + .thenReturn(singletonList(mock(AssociationInfo.class)) );
110+ + .thenReturn(associations );
107111+ when(mPreferencesHelper.getNotificationChannel(eq(PKG), anyInt(),
108112+ eq(mTestNotificationChannel.getId()), anyBoolean()))
109113+ .thenReturn(mTestNotificationChannel);
0 commit comments