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
This commit is contained in:
Tsung-Mao Fang
2021-04-14 18:38:46 +08:00
parent 8d8877b6db
commit 5ec0410e5b

View File

@@ -128,8 +128,13 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider {
}
public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllersFromCode =
createPreferenceControllers(context);
List<AbstractPreferenceController> controllersFromCode = new ArrayList<>();
try {
controllersFromCode = createPreferenceControllers(context);
} catch (Exception e) {
Log.w(TAG, "Error initial controller");
}
final List<SearchIndexableResource> res = getXmlResourcesToIndex(context, true);
if (res == null || res.isEmpty()) {
return controllersFromCode;