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

Commit e76e96bd authored by Stanley Wang's avatar Stanley Wang Committed by Android (Google) Code Review
Browse files

Merge "Update search indexable interface for dynamic indexing."

parents aeb356ca a6d940fc
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -96,6 +96,22 @@ public class SearchIndexablesContract {
     */
    public static final String SLICE_URI_PAIRS_PATH = SETTINGS + "/" + SLICE_URI_PAIRS;


    /**
     * Dynamic indexable raw data names.
     *
     * @hide
     */
    public static final String DYNAMIC_INDEXABLES_RAW = "dynamic_indexables_raw";

    /**
     * ContentProvider path for dynamic indexable raw data.
     *
     * @hide
     */
    public static final String DYNAMIC_INDEXABLES_RAW_PATH =
            SETTINGS + "/" + DYNAMIC_INDEXABLES_RAW;

    /**
     * Indexable xml resources columns.
     */
+23 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
    private static final int MATCH_NON_INDEXABLE_KEYS_CODE = 3;
    private static final int MATCH_SITE_MAP_PAIRS_CODE = 4;
    private static final int MATCH_SLICE_URI_PAIRS_CODE = 5;
    private static final int MATCH_DYNAMIC_RAW_CODE = 6;

    /**
     * Implementation is provided by the parent class.
@@ -96,6 +97,8 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
                MATCH_SITE_MAP_PAIRS_CODE);
        mMatcher.addURI(mAuthority, SearchIndexablesContract.SLICE_URI_PAIRS_PATH,
                MATCH_SLICE_URI_PAIRS_CODE);
        mMatcher.addURI(mAuthority, SearchIndexablesContract.DYNAMIC_INDEXABLES_RAW_PATH,
                MATCH_DYNAMIC_RAW_CODE);

        // Sanity check our setup
        if (!info.exported) {
@@ -126,6 +129,8 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
                    return querySiteMapPairs();
                case MATCH_SLICE_URI_PAIRS_CODE:
                    return querySliceUriPairs();
                case MATCH_DYNAMIC_RAW_CODE:
                    return queryDynamicRawData(null);
                default:
                    throw new UnsupportedOperationException("Unknown Uri " + uri);
            }
@@ -191,12 +196,30 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
        return null;
    }

    /**
     * Returns all {@link android.provider.SearchIndexablesContract.RawData}.
     *
     * Those are the dynamic raw indexable data.
     *
     * @param projection list of {@link android.provider.SearchIndexablesContract.RawData} columns
     *                   to put into the cursor. If {@code null} all supported columns should be
     *                   included.
     *
     * @hide
     */
    @Nullable
    public Cursor queryDynamicRawData(String[] projection) {
        // By default no-op;
        return null;
    }

    @Override
    public String getType(Uri uri) {
        switch (mMatcher.match(uri)) {
            case MATCH_RES_CODE:
                return SearchIndexablesContract.XmlResource.MIME_TYPE;
            case MATCH_RAW_CODE:
            case MATCH_DYNAMIC_RAW_CODE:
                return SearchIndexablesContract.RawData.MIME_TYPE;
            case MATCH_NON_INDEXABLE_KEYS_CODE:
                return SearchIndexablesContract.NonIndexableKey.MIME_TYPE;