From 5ec0410e5b14850f4344490a89dd82c3fc20e480 Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Wed, 14 Apr 2021 18:38:46 +0800 Subject: [PATCH] Prevent failed dynamic index In the original design, if a controller in page initializes failed, then it will impact all the dynamic index mechanism. In this change, we will only skip controllers in a specfic page. All other pages which controllers initialize correctly should work proerly. Test: See correct dynamic result Bug: 185325344 Change-Id: I4f959a23635739e1064318ccdddd6d97016dac23 --- .../android/settings/search/BaseSearchIndexProvider.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/search/BaseSearchIndexProvider.java b/src/com/android/settings/search/BaseSearchIndexProvider.java index da890622bee..3c2df9627e0 100644 --- a/src/com/android/settings/search/BaseSearchIndexProvider.java +++ b/src/com/android/settings/search/BaseSearchIndexProvider.java @@ -128,8 +128,13 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider { } public List getPreferenceControllers(Context context) { - final List controllersFromCode = - createPreferenceControllers(context); + List controllersFromCode = new ArrayList<>(); + try { + controllersFromCode = createPreferenceControllers(context); + } catch (Exception e) { + Log.w(TAG, "Error initial controller"); + } + final List res = getXmlResourcesToIndex(context, true); if (res == null || res.isEmpty()) { return controllersFromCode;