Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 988c82ea authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix crash from Settings Search"

parents 1e870364 9c3c7d8c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -834,6 +834,8 @@ public class SecuritySettings extends SettingsPreferenceFragment

    private static class SecuritySearchIndexProvider extends BaseSearchIndexProvider {

        // TODO (b/68001777) Refactor indexing to include all XML and block other settings.

        @Override
        public List<SearchIndexableResource> getXmlResourcesToIndex(
                Context context, boolean enabled) {
+5 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.search.indexing;

import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.provider.SearchIndexableData;
import android.provider.SearchIndexableResource;
@@ -307,9 +308,11 @@ public class IndexDataConverter {
                resourceIndexData.add(headerBuilder.build(mContext));
            }
        } catch (XmlPullParserException e) {
            throw new RuntimeException("Error parsing PreferenceScreen", e);
            Log.w(LOG_TAG, "XML Error parsing PreferenceScreen: ", e);
        } catch (IOException e) {
            throw new RuntimeException("Error parsing PreferenceScreen", e);
            Log.w(LOG_TAG, "IO Error parsing PreferenceScreen: " , e);
        } catch (Resources.NotFoundException e ) {
            Log.w(LOG_TAG, "Resoucre not found error parsing PreferenceScreen: ", e);
        } finally {
            if (parser != null) parser.close();
        }
+11 −0
Original line number Diff line number Diff line
@@ -334,6 +334,17 @@ public class IndexDataConverterTest {
        assertThat(nonTitlePref.enabled).isTrue();
    }

    @Test
    public void testResourceWithoutXml_shouldNotCrash() {
        final SearchIndexableResource resource = getFakeResource(0);
        final PreIndexData preIndexData = new PreIndexData();
        preIndexData.dataToUpdate.add(resource);

        List<IndexData> indexData = mConverter.convertPreIndexDataToIndexData(preIndexData);

        assertThat(indexData).isEmpty();
    }

    private void assertDisplaySetting(IndexData row, String title, String summaryOn,
            String summaryOff, String key) {
        assertThat(row.normalizedTitle).isEqualTo(title);