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

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

Merge "Extend SearchIndexablesProvider to support query sitemap."

parents 68081e7e 9a0f6feb
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -61,11 +61,25 @@ public class SearchIndexablesContract {
     */
    public static final String NON_INDEXABLES_KEYS = "non_indexables_key";

    /**
     * Site map pairs data key
     *
     * @hide
     */
    public static final String SITE_MAP_PAIRS_KEYS = "site_map_pairs";

    /**
     * ContentProvider path for non indexable data keys.
     */
    public static final String NON_INDEXABLES_KEYS_PATH = SETTINGS + "/" + NON_INDEXABLES_KEYS;

    /**
     * ContentProvider path for sitemap keys.
     *
     * @hide
     */
    public static final String SITE_MAP_PAIRS_PATH = SETTINGS + "/" + SITE_MAP_PAIRS_KEYS;

    /**
     * Indexable xml resources columns.
     */
@@ -112,6 +126,18 @@ public class SearchIndexablesContract {
            RawData.PAYLOAD                         // 15
    };

    /**
     * Columns for site map queries.
     *
     * @hide
     */
    public static final String[] SITE_MAP_COLUMNS = new String[] {
            SiteMapColumns.PARENT_CLASS,
            SiteMapColumns.PARENT_TITLE,
            SiteMapColumns.CHILD_CLASS,
            SiteMapColumns.CHILD_TITLE,
    };

    /**
     * Indexable raw data columns indices.
     */
@@ -168,6 +194,16 @@ public class SearchIndexablesContract {
        public static final String COLUMN_XML_RESID = "xmlResId";
    }

    /**
     * @hide
     */
    public static final class SiteMapColumns {
        public static final String PARENT_CLASS = "parent_class";
        public static final String CHILD_CLASS = "child_class";
        public static final String PARENT_TITLE = "parent_title";
        public static final String CHILD_TITLE = "child_title";
    }

    /**
     * Constants related to a {@link SearchIndexableData}.
     *
+16 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
    private static final int MATCH_RES_CODE = 1;
    private static final int MATCH_RAW_CODE = 2;
    private static final int MATCH_NON_INDEXABLE_KEYS_CODE = 3;
    private static final int MATCH_SITE_MAP_PAIRS_CODE = 4;

    /**
     * Implementation is provided by the parent class.
@@ -87,6 +88,8 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
                MATCH_RAW_CODE);
        mMatcher.addURI(mAuthority, SearchIndexablesContract.NON_INDEXABLES_KEYS_PATH,
                MATCH_NON_INDEXABLE_KEYS_CODE);
        mMatcher.addURI(mAuthority, SearchIndexablesContract.SITE_MAP_PAIRS_PATH,
                MATCH_SITE_MAP_PAIRS_CODE);

        // Sanity check our setup
        if (!info.exported) {
@@ -112,6 +115,8 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
                return queryRawData(null);
            case MATCH_NON_INDEXABLE_KEYS_CODE:
                return queryNonIndexableKeys(null);
            case MATCH_SITE_MAP_PAIRS_CODE:
                return querySiteMapPairs();
            default:
                throw new UnsupportedOperationException("Unknown Uri " + uri);
        }
@@ -150,6 +155,17 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
     */
    public abstract Cursor queryNonIndexableKeys(String[] projection);

    /**
     * Returns a {@link Cursor}, where rows are [parent class, child class] entries to form a site
     * map. The list of pairs should be as complete as possible.
     *
     * @hide
     */
    public Cursor querySiteMapPairs() {
        // By default no-op.
        return null;
    }

    @Override
    public String getType(Uri uri) {
        switch (mMatcher.match(uri)) {