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
This commit is contained in:
Pavel Grafov
2023-05-31 17:33:01 +01:00
parent 43fb288ec1
commit 1075d5196b

View File

@@ -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);