Home | History | Annotate | Download | only in search
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.settings.search;
     18 
     19 import android.database.Cursor;
     20 import android.database.MatrixCursor;
     21 import android.provider.SearchIndexableResource;
     22 import android.provider.SearchIndexablesProvider;
     23 
     24 import java.util.Collection;
     25 
     26 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RANK;
     27 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID;
     28 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_CLASS_NAME;
     29 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_ICON_RESID;
     30 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_ACTION;
     31 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE;
     32 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS;
     33 
     34 import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
     35 import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
     36 import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS;
     37 
     38 public class SettingsSearchIndexablesProvider extends SearchIndexablesProvider {
     39     private static final String TAG = "SettingsSearchIndexablesProvider";
     40 
     41     @Override
     42     public boolean onCreate() {
     43         return true;
     44     }
     45 
     46     @Override
     47     public Cursor queryXmlResources(String[] projection) {
     48         MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS);
     49         Collection<SearchIndexableResource> values = SearchIndexableResources.values();
     50         for (SearchIndexableResource val : values) {
     51             Object[] ref = new Object[7];
     52             ref[COLUMN_INDEX_XML_RES_RANK] = val.rank;
     53             ref[COLUMN_INDEX_XML_RES_RESID] = val.xmlResId;
     54             ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = val.className;
     55             ref[COLUMN_INDEX_XML_RES_ICON_RESID] = val.iconResId;
     56             ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = null; // intent action
     57             ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = null; // intent target package
     58             ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = null; // intent target class
     59             cursor.addRow(ref);
     60         }
     61         return cursor;
     62     }
     63 
     64     @Override
     65     public Cursor queryRawData(String[] projection) {
     66         MatrixCursor result = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
     67         return result;
     68     }
     69 
     70     @Override
     71     public Cursor queryNonIndexableKeys(String[] projection) {
     72         MatrixCursor cursor = new MatrixCursor(NON_INDEXABLES_KEYS_COLUMNS);
     73         return cursor;
     74     }
     75 }
     76