diff options
author | 2023-07-26 19:08:51 +0000 | |
---|---|---|
committer | 2023-07-26 19:08:51 +0000 | |
commit | fce74476b97908ca41a6df98d020b795700b0367 (patch) | |
tree | c1566c3509e32f872ce7ea1af22b83a856dcfbf1 | |
parent | 0651c6f711750a4c2380f63499616042926eb424 (diff) | |
parent | 6a44ac49cdbed20bbf3269286dcc4343103dfaea (diff) |
Merge "Partial revert of ag/24190245." into udc-mainline-prod am: 6a44ac49cd
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Permission/+/24210764
Change-Id: I87ea55733f0dc33a4d30adf7687ec0f8a8c30bac
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | service/java/com/android/safetycenter/SafetyCenterService.java | 8 | ||||
-rw-r--r-- | service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java | 26 |
2 files changed, 7 insertions, 27 deletions
diff --git a/service/java/com/android/safetycenter/SafetyCenterService.java b/service/java/com/android/safetycenter/SafetyCenterService.java index 52768950d..cac8bfc61 100644 --- a/service/java/com/android/safetycenter/SafetyCenterService.java +++ b/service/java/com/android/safetycenter/SafetyCenterService.java @@ -906,8 +906,14 @@ public final class SafetyCenterService extends SystemService { @GuardedBy("mApiLock") private void onApiDisabledLocked() { + // We're not clearing the Safety Center notification channels here. The reason for this + // is that the NotificationManager will post a runnable to cancel all associated + // notifications when clearing the channels. Given this happens asynchronously, this can + // leak between test cases and cause notifications that should be active to be cleared + // inadvertently. We're ok with the inconsistency because the channels are hidden + // somewhat deeply under Settings anyway, and we're unlikely to turn off Safety Center + // in production. clearDataLocked(); - mNotificationChannels.clearAllChannelsForAllUsers(getContext()); mSafetyCenterListeners.clear(); mSafetyCenterBroadcastDispatcher.sendEnabledChanged(); } diff --git a/service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java b/service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java index 56476bd65..ccd2bfabc 100644 --- a/service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java +++ b/service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java @@ -150,32 +150,6 @@ public final class SafetyCenterNotificationChannels { } } - /** Clears all Safety Center {@link NotificationChannel}s, for all current users. */ - public void clearAllChannelsForAllUsers(Context context) { - List<UserHandle> users = UserUtils.getUserHandles(context); - for (int i = 0; i < users.size(); i++) { - clearAllChannelsForUser(context, users.get(i)); - } - } - - // This method is private and not public as it is assumed that clearing channels on user removal - // is already handled by the NotificationManagerService. - private void clearAllChannelsForUser(Context context, UserHandle user) { - NotificationManager notificationManager = getNotificationManagerForUser(context, user); - if (notificationManager == null) { - return; - } - - try { - clearAllChannelsWithoutCallingIdentity(notificationManager); - } catch (RuntimeException e) { - Log.w( - TAG, - "Error clearing notification channels for user id: " + user.getIdentifier(), - e); - } - } - @Nullable private String getChannelIdForIssue(SafetySourceIssue issue) { int issueSeverityLevel = issue.getSeverityLevel(); |