summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Elliot Sisteron <elliotsisteron@google.com> 2023-07-26 17:51:51 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-07-26 17:51:51 +0000
commit6a44ac49cdbed20bbf3269286dcc4343103dfaea (patch)
tree022cb2f70c5136e6014b06fd36b917b6a02b35f1
parent4f19cfa7aae2badcfbb844cc713089481ff793a7 (diff)
parent5f7f5b53dde972e9932173124e09a4c625cd01a4 (diff)
Merge "Partial revert of ag/24190245." into udc-mainline-prod
-rw-r--r--service/java/com/android/safetycenter/SafetyCenterService.java8
-rw-r--r--service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java26
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();