From 130a028f33944cb3bd557f0d0425067ff31bf2dc Mon Sep 17 00:00:00 2001 From: Alison Cichowlas Date: Tue, 6 Jun 2017 15:06:14 -0400 Subject: [PATCH] If two groups are posted to settings, remove old group and log. Bug: 62136650 Test: manual: set debugger in asynctask at line 110 to force race condition, triggered task twice then released both. also ran existing tests with no new failures. Change-Id: I8508fe9f191ca6cd0bb6dfbc62d884420d3fd747 --- .../settings/notification/AppNotificationSettings.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java index 6c4f27cd409..fb894028dcc 100644 --- a/src/com/android/settings/notification/AppNotificationSettings.java +++ b/src/com/android/settings/notification/AppNotificationSettings.java @@ -51,7 +51,6 @@ import com.android.settings.widget.MasterSwitchPreference; import com.android.settings.widget.SwitchBar; import com.android.settingslib.RestrictedSwitchPreference; -import java.text.Collator; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -147,6 +146,15 @@ public class AppNotificationSettings extends NotificationSettingsBase { } private void populateChannelList() { + if (!mChannelGroups.isEmpty()) { + // If there's anything in mChannelGroups, we've called populateChannelList twice. + // Clear out existing channels and log. + Log.w(TAG, "Notification channel group posted twice to settings - old size " + + mChannelGroups.size() + ", new size " + mChannelGroupList.size()); + for (Preference p : mChannelGroups) { + getPreferenceScreen().removePreference(p); + } + } if (mChannelGroupList.isEmpty()) { PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext()); groupCategory.setTitle(R.string.notification_channels);