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

Commit 129ce3d5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE when updating deleted notification channels" into main

parents 34287c40 f2ee965f
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -3590,14 +3590,16 @@ public class NotificationManagerService extends SystemService {
        }
        if (notificationForceGrouping()) {
            final NotificationChannel updatedChannel = mPreferencesHelper.getNotificationChannel(
                    pkg, uid, channel.getId(), false);
                mHandler.postDelayed(() -> {
                    final NotificationChannel updatedChannel = mPreferencesHelper
                            .getNotificationChannel(pkg, uid, channel.getId(), false);
                    synchronized (mNotificationLock) {
                        if (updatedChannel != null) {
                            mGroupHelper.onChannelUpdated(
                                    UserHandle.getUserHandleForUid(uid).getIdentifier(), pkg,
                                    updatedChannel, mNotificationList, mSummaryByGroupKey);
                        }
                    }
                }, DELAY_FORCE_REGROUP_TIME);
        }
+18 −0
Original line number Diff line number Diff line
@@ -2866,6 +2866,24 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                eq(mPkg), eq(mTestNotificationChannel), any(), any());
    }
    @Test
    @EnableFlags(FLAG_NOTIFICATION_FORCE_GROUPING)
    public void testUpdateDeletedChannel_notifyGroupHelper() throws Exception {
        mService.setPreferencesHelper(mPreferencesHelper);
        mTestNotificationChannel.setLightColor(Color.CYAN);
        when(mPreferencesHelper.getNotificationChannel(eq(mPkg), anyInt(),
                eq(mTestNotificationChannel.getId()), eq(true)))
                .thenReturn(mTestNotificationChannel);
        when(mPreferencesHelper.getNotificationChannel(eq(mPkg), anyInt(),
                eq(mTestNotificationChannel.getId()), eq(false)))
                .thenReturn(null);
        mBinderService.updateNotificationChannelForPackage(mPkg, mUid, mTestNotificationChannel);
        mTestableLooper.moveTimeForward(DELAY_FORCE_REGROUP_TIME);
        waitForIdle();
        verify(mGroupHelper, never()).onChannelUpdated(anyInt(), anyString(), any(), any(), any());
    }
    @Test
    @EnableFlags(FLAG_NOTIFICATION_FORCE_GROUPING)
    public void testSnoozeRunnable_snoozeAggregateGroupChild_summaryNotSnoozed() throws Exception {