diff options
author | 2025-03-20 16:04:41 -0400 | |
---|---|---|
committer | 2025-03-20 16:04:41 -0400 | |
commit | 6f9d00968b68d7680a41994dd1697afca6b3525b (patch) | |
tree | 644960b4ca5c856099d88de793077b083a552c0c | |
parent | eb8f40616374b77c5e9a9344c09ee93f88989a75 (diff) |
Add elements to existing mChannelsList instead of overwriting in setChannels
This means that mChannels, which is initialized as an empty list upon declaration, cannot be overwritten (thus cannot be null) by a call to setChannels. This passes through the same channels in the list but does not keep the passed in structure.
Bug: 381131846
Flag: EXEMPT non-behavioral change
Test: NotificationManagerTest, NotificationManagerServiceTest, NotifictionChannelGroupTest
Change-Id: If8f564012b4000109734abab2339f776112cd146
-rw-r--r-- | core/java/android/app/NotificationChannelGroup.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/java/android/app/NotificationChannelGroup.java b/core/java/android/app/NotificationChannelGroup.java index d48cede04680..06b492c417d8 100644 --- a/core/java/android/app/NotificationChannelGroup.java +++ b/core/java/android/app/NotificationChannelGroup.java @@ -221,7 +221,10 @@ public final class NotificationChannelGroup implements Parcelable { * @hide */ public void setChannels(List<NotificationChannel> channels) { - mChannels = channels; + mChannels.clear(); + if (channels != null) { + mChannels.addAll(channels); + } } /** @@ -331,10 +334,8 @@ public final class NotificationChannelGroup implements Parcelable { NotificationChannelGroup cloned = new NotificationChannelGroup(getId(), getName()); cloned.setDescription(getDescription()); cloned.setBlocked(isBlocked()); - if (mChannels != null) { - for (NotificationChannel c : mChannels) { - cloned.addChannel(c.copy()); - } + for (NotificationChannel c : mChannels) { + cloned.addChannel(c.copy()); } cloned.lockFields(mUserLockedFields); return cloned; |