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_CLASS_NAME;
     27 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_ICON_RESID;
     28 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_ACTION;
     29 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS;
     30 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE;
     31 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RANK;
     32 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID;
     33 import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
     34 import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
     35 import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS;
     36 
     37 public class SettingsSearchIndexablesProvider extends SearchIndexablesProvider {
     38     private static final String TAG = "SettingsSearchIndexablesProvider";
     39 
     40     @Override
     41     public boolean onCreate() {
     42         return true;
     43     }
     44 
     45     @Override
     46     public Cursor queryXmlResources(String[] projection) {
     47         MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS);
     48         Collection<SearchIndexableResource> values = SearchIndexableResources.values();
     49         for (SearchIndexableResource val : values) {
     50             Object[] ref = new Object[7];
     51             ref[COLUMN_INDEX_XML_RES_RANK] = val.rank;
     52             ref[COLUMN_INDEX_XML_RES_RESID] = val.xmlResId;
     53             ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = val.className;
     54             ref[COLUMN_INDEX_XML_RES_ICON_RESID] = val.iconResId;
     55             ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = null; // intent action
     56             ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = null; // intent target package
     57             ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = null; // intent target class
     58             cursor.addRow(ref);
     59         }
     60         return cursor;
     61     }
     62 
     63     @Override
     64     public Cursor queryRawData(String[] projection) {
     65         MatrixCursor result = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
     66         return result;
     67     }
     68 
     69     @Override
     70     public Cursor queryNonIndexableKeys(String[] projection) {
     71         MatrixCursor cursor = new MatrixCursor(NON_INDEXABLES_KEYS_COLUMNS);
     72         return cursor;
     73     }
     74 }
     75