Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6077349a authored by Matías Hernández's avatar Matías Hernández
Browse files

Delete updateNotificationChannelGroupFromPrivilegedListener

This is an unpublished (AIDL only) method and was never used from NLS (or anywhere else).

Bug: 426205822
Test: build
Flag: EXEMPT Code deletion
Change-Id: I65438b1af637f3ba9b75a85f780bdb7867cc4ba8
parent aa878a5a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -179,7 +179,6 @@ interface INotificationManager
    void setInterruptionFilter(String pkg, int interruptionFilter, boolean fromUser);

    NotificationChannel createConversationNotificationChannelForPackageFromPrivilegedListener(in INotificationListener token, String pkg, in UserHandle user, String parentChannelId, String conversationId);
    void updateNotificationChannelGroupFromPrivilegedListener(in INotificationListener token, String pkg, in UserHandle user, in NotificationChannelGroup group);
    void updateNotificationChannelFromPrivilegedListener(in INotificationListener token, String pkg, in UserHandle user, in NotificationChannel channel);
    ParceledListSlice getNotificationChannelsFromPrivilegedListener(in INotificationListener token, String pkg, in UserHandle user);
    ParceledListSlice getNotificationChannelGroupsFromPrivilegedListener(in INotificationListener token, String pkg, in UserHandle user);
+0 −19
Original line number Diff line number Diff line
@@ -7392,25 +7392,6 @@ public class NotificationManagerService extends SystemService {
                    pkg, uid, parentId, conversationId, false, false).copy();
        }
        @Override
        public void updateNotificationChannelGroupFromPrivilegedListener(
                INotificationListener token, String pkg, UserHandle user,
                NotificationChannelGroup group) throws RemoteException {
            Objects.requireNonNull(user);
            verifyPrivilegedListener(token, user, false);
            int packageUid = getUidForPackageAndUser(pkg, user);
            if (packageUid == INVALID_UID) {
                return;
            }
            NotificationChannelGroup previous = mPreferencesHelper.getNotificationChannelGroup(
                    group.getId(), pkg, packageUid);
            if (previous == null) {
                return;
            }
            createNotificationChannelGroup(pkg, packageUid, group, false, true);
            handleSavePolicyFile();
        }
        @Override
        public void updateNotificationChannelFromPrivilegedListener(INotificationListener token,
                String pkg, UserHandle user, NotificationChannel channel) throws RemoteException {
+0 −59
Original line number Diff line number Diff line
@@ -5616,65 +5616,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                anyInt());
    }
    @Test
    public void updateNotificationChannelGroupFromPrivilegedListener_cdm_success()
            throws Exception {
        NotificationChannelGroup createByApp = new NotificationChannelGroup("grp", "Group");
        mService.mPreferencesHelper.createNotificationChannelGroup(mPkg, mUid, createByApp, true,
                mUid, false);
        NotificationChannelGroup updateByNls = new NotificationChannelGroup("grp", "Updated");
        when(mCompanionMgr.getAssociations(mPkg, mUserId))
                .thenReturn(singletonList(mock(AssociationInfo.class)));
        mBinderService.updateNotificationChannelGroupFromPrivilegedListener(
                null, mPkg, mUser, updateByNls);
        NotificationChannelGroup result = mService.mPreferencesHelper.getNotificationChannelGroup(
                "grp", mPkg, mUid);
        assertThat(result.getName().toString()).isEqualTo("Updated");
    }
    @Test
    public void updateNotificationChannelGroupFromPrivilegedListener_noCdm_throws()
            throws Exception {
        when(mCompanionMgr.getAssociations(mPkg, mUserId)).thenReturn(Lists.newArrayList());
        NotificationChannelGroup updateByNls = new NotificationChannelGroup("grp", "Updated");
        SecurityException exception = assertThrows(SecurityException.class, () ->
                mBinderService.updateNotificationChannelGroupFromPrivilegedListener(
                        null, mPkg, mUser, updateByNls));
        assertThat(exception).hasMessageThat().contains("does not have access");
    }
    @Test
    public void updateNotificationChannelGroupFromPrivilegedListener_wrongPackage_ignored()
            throws Exception {
        NotificationChannelGroup updateByNls = new NotificationChannelGroup("grp", "Updated");
        when(mCompanionMgr.getAssociations(mPkg, mUserId))
                .thenReturn(singletonList(mock(AssociationInfo.class)));
        mBinderService.updateNotificationChannelGroupFromPrivilegedListener(
                null, "com.package.does.not.exist", mUser, updateByNls);
        verify(mService.mPreferencesHelper, never()).createNotificationChannelGroup(any(), anyInt(),
                any(), anyBoolean(), anyInt(), anyBoolean());
    }
    @Test
    public void updateNotificationChannelGroupFromPrivilegedListener_notAnUpdate_ignored()
            throws Exception {
        NotificationChannelGroup createByNls = new NotificationChannelGroup("grp", "New");
        when(mCompanionMgr.getAssociations(mPkg, mUserId))
                .thenReturn(singletonList(mock(AssociationInfo.class)));
        mBinderService.updateNotificationChannelGroupFromPrivilegedListener(
                null, mPkg, mUser, createByNls);
        verify(mService.mPreferencesHelper, never()).createNotificationChannelGroup(any(), anyInt(),
                any(), anyBoolean(), anyInt(), anyBoolean());
    }
    @Test
    public void testGetPackagesWithChannels_blocked() throws Exception {
        // While we mostly rely on the PreferencesHelper implementation of channels, we filter in