Prevent crash in Search from Stack overflow

NotificationSettingBase's getPreferenceController call
is recursive with no base case which crashes search.

Root cause here is that NotificationSettingsBase should
not be indexed for seacrh but was probably failing the
code inspection test. Added NotificationSettingsBase
child classes to grandfather list of classes that
should be ignored for search.

Change-Id: I04ed242db3a394b88e0d0ac420aaaff6f9301cb5
Fixes: 69096424
Test: robotests
(cherry picked from commit f6cf598d0325c3c96927285b22c84f042e95b6fb)
diff --git a/src/com/android/settings/notification/ChannelImportanceSettings.java b/src/com/android/settings/notification/ChannelImportanceSettings.java
index bffed08..27b23b8 100644
--- a/src/com/android/settings/notification/ChannelImportanceSettings.java
+++ b/src/com/android/settings/notification/ChannelImportanceSettings.java
@@ -163,15 +163,4 @@
         mChannel.lockFields(USER_LOCKED_IMPORTANCE);
         mBackend.updateChannel(mAppRow.pkg, mAppRow.uid, mChannel);
     }
-
-    // This page exists per notification channel; should not be included
-    // in search
-    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider() {
-                @Override
-                public List<SearchIndexableResource> getXmlResourcesToIndex(
-                        Context context, boolean enabled) {
-                    return null;
-                }
-            };
 }
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index e9da5d9..9afb618 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -208,15 +208,19 @@
                 intent,
                 0 //PackageManager.MATCH_DEFAULT_ONLY
         );
-        if (DEBUG) Log.d(TAG, "Found " + resolveInfos.size() + " preference activities"
-                + (resolveInfos.size() == 0 ? " ;_;" : ""));
+        if (DEBUG) {
+            Log.d(TAG, "Found " + resolveInfos.size() + " preference activities"
+                    + (resolveInfos.size() == 0 ? " ;_;" : ""));
+        }
         for (ResolveInfo ri : resolveInfos) {
             final ActivityInfo activityInfo = ri.activityInfo;
             final ApplicationInfo appInfo = activityInfo.applicationInfo;
             if (mAppRow.settingsIntent != null) {
-                if (DEBUG) Log.v(TAG, "Ignoring duplicate notification preference activity ("
-                        + activityInfo.name + ") for package "
-                        + activityInfo.packageName);
+                if (DEBUG) {
+                    Log.d(TAG, "Ignoring duplicate notification preference activity ("
+                            + activityInfo.name + ") for package "
+                            + activityInfo.packageName);
+                }
                 continue;
             }
             mAppRow.settingsIntent = intent
@@ -280,7 +284,7 @@
                     public boolean onPreferenceChange(Preference preference,
                             Object o) {
                         boolean value = (Boolean) o;
-                        int importance = value ?  IMPORTANCE_LOW : IMPORTANCE_NONE;
+                        int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
                         channel.setImportance(importance);
                         channel.lockFields(
                                 NotificationChannel.USER_LOCKED_IMPORTANCE);
@@ -365,8 +369,10 @@
         public void onReceive(Context context, Intent intent) {
             String packageName = intent.getData().getSchemeSpecificPart();
             if (mPkgInfo == null || TextUtils.equals(mPkgInfo.packageName, packageName)) {
-                if (DEBUG) Log.d(TAG, "Package (" + packageName + ") removed. Removing"
-                        + "NotificationSettingsBase.");
+                if (DEBUG) {
+                    Log.d(TAG, "Package (" + packageName + ") removed. Removing"
+                            + "NotificationSettingsBase.");
+                }
                 onPackageRemoved();
             }
         }
@@ -380,24 +386,6 @@
                 return left.getId().compareTo(right.getId());
             };
 
-    /**
-     * These screens aren't searchable - they only make sense in the context of an app, so
-     * surfacing a generic version would be impossible.
-     */
-    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider() {
-                @Override
-                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
-                        boolean enabled) {
-                    return new ArrayList<>();
-                }
-
-                @Override
-                public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
-                    return getPreferenceControllers(context);
-                }
-            };
-
     protected class ImportanceListener {
         protected void onImportanceChanged() {
             final PreferenceScreen screen = getPreferenceScreen();
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 4548342..c524346 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -64,10 +64,6 @@
 import com.android.settings.location.ScanningSettings;
 import com.android.settings.network.NetworkDashboardFragment;
 import com.android.settings.nfc.PaymentSettings;
-import com.android.settings.notification.AppNotificationSettings;
-import com.android.settings.notification.ChannelGroupNotificationSettings;
-import com.android.settings.notification.ChannelImportanceSettings;
-import com.android.settings.notification.ChannelNotificationSettings;
 import com.android.settings.notification.ConfigureNotificationSettings;
 import com.android.settings.notification.SoundSettings;
 import com.android.settings.notification.ZenModeAutomationSettings;
@@ -161,7 +157,6 @@
         addIndex(TtsEnginePreferenceFragment.class);
         addIndex(MagnificationPreferenceFragment.class);
         addIndex(AccessibilityShortcutPreferenceFragment.class);
-        addIndex(ChannelImportanceSettings.class);
         addIndex(DreamSettings.class);
         addIndex(SupportDashboardActivity.class);
         addIndex(AutomaticStorageManagerSettings.class);
@@ -171,10 +166,6 @@
         addIndex(LockscreenDashboardFragment.class);
         addIndex(ZenModeBehaviorSettings.class);
         addIndex(ZenModeAutomationSettings.class);
-        addIndex(AppNotificationSettings.class);
-        addIndex(ChannelNotificationSettings.class);
-        addIndex(ChannelImportanceSettings.class);
-        addIndex(ChannelGroupNotificationSettings.class);
     }
 
     private SearchIndexableResources() {
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index fda5c8a..6704fc3 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -7,6 +7,10 @@
 com.android.settings.development.featureflags.FeatureFlagsDashboard
 com.android.settings.development.qstile.DevelopmentTileConfigFragment
 com.android.settings.deviceinfo.StorageProfileFragment
+com.android.settings.notification.ChannelNotificationSettings
+com.android.settings.notification.ChannelImportanceSettings
+com.android.settings.notification.ChannelGroupNotificationSettings
+com.android.settings.notification.AppNotificationSettings
 com.android.settings.wifi.details.WifiNetworkDetailsFragment
 com.android.settings.wifi.p2p.WifiP2pSettings
 com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionCamera
@@ -15,4 +19,4 @@
 com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages
 com.android.settings.enterprise.EnterpriseSetDefaultAppsListFragment
 com.android.settings.wifi.tether.WifiTetherSettings
-com.android.settings.wifi.SavedAccessPointsWifiSettings
+com.android.settings.wifi.SavedAccessPointsWifiSettings
\ No newline at end of file
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index 7c82e78..c2a084c 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -79,4 +79,4 @@
 com.android.settings.TetherSettings
 com.android.settings.ApnEditor
 com.android.settings.UserCredentialsSettings
-com.android.settings.TestingSettings
+com.android.settings.TestingSettings
\ No newline at end of file