From 1075d5196b1ac719501f35c1adcf63772759cdb5 Mon Sep 17 00:00:00 2001 From: Pavel Grafov Date: Wed, 31 May 2023 17:33:01 +0100 Subject: [PATCH] Don't cancel notifications when pausing work apps Previously when the profile was turned off, all apps were killed, so it made sense to cancel all the notifications after that. If the profile is kept running, and suspension is used instead, there is no need to cancel the notifications, because they'll be hidden for suspended apps anyway. Also, if the notification gets cancelled, it is possible that the user will never see it, especially when the profile is paused by schedule. This CL makes the behavior consistent with focus mode - when the profile gets unpaused, all work notifications reappear, those that existed before the profile was paused and those that were posted while it was paused. Bug: 285129642 Test: manual with Telegram messenger Change-Id: I45bfa87c36478237d04375a51473b35ec7704e0b --- .../android/server/notification/NotificationManagerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 services/core/java/com/android/server/notification/NotificationManagerService.java diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java old mode 100755 new mode 100644 index e56eba659d372..aeff2b0f9af67 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -1843,7 +1843,7 @@ public class NotificationManagerService extends SystemService { } } else if (action.equals(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE)) { int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); - if (userHandle >= 0) { + if (userHandle >= 0 && !mDpm.isKeepProfilesRunningEnabled()) { cancelAllNotificationsInt(MY_UID, MY_PID, null, null, 0, 0, true, userHandle, REASON_PROFILE_TURNED_OFF, null); mSnoozeHelper.clearData(userHandle);