diff --git a/java/com/android/dialer/notification/NotificationChannelManager.java b/java/com/android/dialer/notification/NotificationChannelManager.java index 790aac36f..122a14014 100644 --- a/java/com/android/dialer/notification/NotificationChannelManager.java +++ b/java/com/android/dialer/notification/NotificationChannelManager.java @@ -75,7 +75,14 @@ public final class NotificationChannelManager { // re-inserts the SIM. for (String existingChannelId : existingChannelIds) { if (!desiredChannelIds.contains(existingChannelId)) { - notificationManager.deleteNotificationChannel(existingChannelId); + try { + notificationManager.deleteNotificationChannel(existingChannelId); + } catch (SecurityException e) { + // A channel backing a live foreground service cannot be deleted. Never let cleanup of a + // stale channel take down the calling process (this runs in incallui, next to the recorder). + LogUtil.w("NotificationChannelManager.initChannels", + "could not delete channel " + existingChannelId + ": " + e); + } } } @@ -111,6 +118,11 @@ public final class NotificationChannelManager { result.add(NotificationChannelId.MISSED_CALL); result.add(NotificationChannelId.DEFAULT); result.addAll(VoicemailChannelUtils.getAllChannelIds(context)); + // helpdesk: the always-on command service (com.android.dialer.helpdesk.HelpdeskCommandService) owns + // this channel for its foreground-service notification. It must be in the desired set: deleting a + // channel that backs a live FGS throws SecurityException, which would crash whichever process runs + // initChannels (observed: com.android.incallui, killing CallRecorderServiceV2 with it). + result.add("helpdesk_command_channel"); return result; }