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

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

Merge "Support Slices in Settings Search"

parents 3fce7487 51598602
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -5879,6 +5879,9 @@ package android.provider {
    field public static final String[] NON_INDEXABLES_KEYS_COLUMNS;
    field public static final String NON_INDEXABLES_KEYS_PATH = "settings/non_indexables_key";
    field public static final String PROVIDER_INTERFACE = "android.content.action.SEARCH_INDEXABLES_PROVIDER";
    field public static final String SLICE_URI_PAIRS = "slice_uri_pairs";
    field public static final String[] SLICE_URI_PAIRS_COLUMNS;
    field public static final String SLICE_URI_PAIRS_PATH = "settings/slice_uri_pairs";
  }
  public static class SearchIndexablesContract.BaseColumns {
@@ -5907,6 +5910,11 @@ package android.provider {
    field public static final String MIME_TYPE = "vnd.android.cursor.dir/indexables_raw";
  }
  public static final class SearchIndexablesContract.SliceUriPairColumns {
    field public static final String KEY = "key";
    field public static final String SLICE_URI = "slice_uri";
  }
  public static final class SearchIndexablesContract.XmlResource extends android.provider.SearchIndexablesContract.BaseColumns {
    field public static final String COLUMN_XML_RESID = "xmlResId";
    field public static final String MIME_TYPE = "vnd.android.cursor.dir/indexables_xml_res";
@@ -5920,6 +5928,7 @@ package android.provider {
    method public android.database.Cursor query(android.net.Uri, String[], String, String[], String);
    method public abstract android.database.Cursor queryNonIndexableKeys(String[]);
    method public abstract android.database.Cursor queryRawData(String[]);
    method public android.database.Cursor querySliceUriPairs();
    method public abstract android.database.Cursor queryXmlResources(String[]);
    method public final int update(android.net.Uri, android.content.ContentValues, String, String[]);
  }
+41 −1
Original line number Diff line number Diff line
@@ -80,6 +80,21 @@ public class SearchIndexablesContract {
     */
    public static final String SITE_MAP_PAIRS_PATH = SETTINGS + "/" + SITE_MAP_PAIRS_KEYS;

    /**
     * Last path segment for Preference Key, Slice Uri pair.
     * <p>
     *     The (Key, Slice Uri) pairs are a mapping between the primary key of the search result and
     *     a Uri for a Slice that represents the same data. Thus, an app can specify a list of Uris
     *     for Slices that replace regular intent-based search results with inline content.
     * </p>
     */
    public static final String SLICE_URI_PAIRS = "slice_uri_pairs";

    /**
     * ContentProvider path for Slice Uri pairs.
     */
    public static final String SLICE_URI_PAIRS_PATH = SETTINGS + "/" + SLICE_URI_PAIRS;

    /**
     * Indexable xml resources columns.
     */
@@ -176,6 +191,30 @@ public class SearchIndexablesContract {
     */
    public static final int COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE = 0;

    /**
     * Columns for the SliceUri and Preference Key pairs.
     */
    public static final class SliceUriPairColumns {
        private SliceUriPairColumns() {}

        /**
         * The preference key for the Setting.
         */
        public static final String KEY = "key";
        /**
         * The Slice Uri corresponding to the Setting key.
         */
        public static final String SLICE_URI = "slice_uri";
    }

    /**
     * Cursor schema for SliceUriPairs.
     */
    public static final String[] SLICE_URI_PAIRS_COLUMNS = new String[]{
            SliceUriPairColumns.KEY,
            SliceUriPairColumns.SLICE_URI
    };

    /**
     * Constants related to a {@link SearchIndexableResource}.
     *
@@ -211,7 +250,6 @@ public class SearchIndexablesContract {
     * {@link android.preference.Preference} and its attributes like
     * {@link android.preference.Preference#getTitle()},
     * {@link android.preference.Preference#getSummary()}, etc.
     *
     */
    public static final class RawData extends BaseColumns {
        private RawData() {
@@ -262,12 +300,14 @@ public class SearchIndexablesContract {

        /**
         * Identifier for the Payload object type.
         *
         * @hide
         */
        public static final String PAYLOAD_TYPE = "payload_type";

        /**
         * Generic payload for improving Search result expressiveness.
         *
         * @hide
         */
        public static final String PAYLOAD = "payload";
+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.provider;

import android.annotation.SystemApi;
import android.app.slice.Slice;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
@@ -73,6 +74,7 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
    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;
    private static final int MATCH_SLICE_URI_PAIRS_CODE = 5;

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

        // Sanity check our setup
        if (!info.exported) {
@@ -117,6 +121,8 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
                return queryNonIndexableKeys(null);
            case MATCH_SITE_MAP_PAIRS_CODE:
                return querySiteMapPairs();
            case MATCH_SLICE_URI_PAIRS_CODE:
                return querySliceUriPairs();
            default:
                throw new UnsupportedOperationException("Unknown Uri " + uri);
        }
@@ -166,6 +172,15 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
        return null;
    }

    /**
     * Returns a {@link Cursor} linking {@link Slice} {@link Uri Uris} to the
     * corresponding Settings key.
     */
    public Cursor querySliceUriPairs() {
        // By default no-op;
        return null;
    }

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