From a1a30296ae67d3be27a3cb805bd4e26d70812640 Mon Sep 17 00:00:00 2001 From: Yanting Yang Date: Fri, 12 Mar 2021 15:47:31 +0800 Subject: [PATCH] Fix NPE for ConfigureNotificationSettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NPE is caused by that we have removed the advanced category from Notification page for android S design but it still tries to get category and call setInitialExpandedChildrenCount in onCreate(). Only run the relevant logic on the old design since it’s only used to expand the advanced category and we don’t need the expand feature anymore for android S. Bug: 182237530 Fixes: 182532954 Test: robotest & manual Change-Id: I96f35fa40221079d5498d9d2fab9c75d64698808 --- .../ConfigureNotificationSettings.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/com/android/settings/notification/ConfigureNotificationSettings.java b/src/com/android/settings/notification/ConfigureNotificationSettings.java index 0f3695a0a89..dcba273c6a2 100644 --- a/src/com/android/settings/notification/ConfigureNotificationSettings.java +++ b/src/com/android/settings/notification/ConfigureNotificationSettings.java @@ -127,20 +127,23 @@ public class ConfigureNotificationSettings extends DashboardFragment implements @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); - final PreferenceScreen screen = getPreferenceScreen(); - final Bundle arguments = getArguments(); + // TODO(b/182237530): This method should be removed when this flag is deprecated. + if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) { + final PreferenceScreen screen = getPreferenceScreen(); + final Bundle arguments = getArguments(); - if (screen == null) { - return; - } - if (arguments != null) { - final String highlightKey = arguments.getString(EXTRA_FRAGMENT_ARG_KEY); - if (!TextUtils.isEmpty(highlightKey)) { - final PreferenceCategory advancedCategory = - screen.findPreference(KEY_ADVANCED_CATEGORY); - // Has highlight row - expand everything - advancedCategory.setInitialExpandedChildrenCount(Integer.MAX_VALUE); - scrollToPreference(advancedCategory); + if (screen == null) { + return; + } + if (arguments != null) { + final String highlightKey = arguments.getString(EXTRA_FRAGMENT_ARG_KEY); + if (!TextUtils.isEmpty(highlightKey)) { + final PreferenceCategory advancedCategory = + screen.findPreference(KEY_ADVANCED_CATEGORY); + // Has highlight row - expand everything + advancedCategory.setInitialExpandedChildrenCount(Integer.MAX_VALUE); + scrollToPreference(advancedCategory); + } } } }