blob: 4b2476cdd0ee32689bbbcef1726b4839747a0b14 [file] [log] [blame]
Fabrice Di Meglioe5ee4a32014-03-14 19:04:10 -07001/*
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
17package com.android.phone;
18
19import android.database.Cursor;
20import android.database.MatrixCursor;
21import android.provider.SearchIndexableResource;
22import android.provider.SearchIndexablesProvider;
23
Fabrice Di Meglio2a527612014-04-09 19:35:24 -070024import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RANK;
25import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID;
26import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_CLASS_NAME;
27import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_ICON_RESID;
28import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_ACTION;
29import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE;
30import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS;
31
Fabrice Di Meglioe5ee4a32014-03-14 19:04:10 -070032import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
33import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
Fabrice Di Meglio7b18c722014-04-11 18:52:00 -070034import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS;
Fabrice Di Meglioe5ee4a32014-03-14 19:04:10 -070035
36public class PhoneSearchIndexablesProvider extends SearchIndexablesProvider {
37 private static final String TAG = "PhoneSearchIndexablesProvider";
38
39 private static SearchIndexableResource[] INDEXABLE_RES = new SearchIndexableResource[] {
40 new SearchIndexableResource(1, R.xml.network_setting,
41 MobileNetworkSettings.class.getName(),
42 R.mipmap.ic_launcher_phone),
43 };
44
45 @Override
46 public boolean onCreate() {
47 return true;
48 }
49
50 @Override
51 public Cursor queryXmlResources(String[] projection) {
52 MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS);
53 final int count = INDEXABLE_RES.length;
54 for (int n = 0; n < count; n++) {
55 Object[] ref = new Object[7];
Fabrice Di Meglio2a527612014-04-09 19:35:24 -070056 ref[COLUMN_INDEX_XML_RES_RANK] = INDEXABLE_RES[n].rank;
57 ref[COLUMN_INDEX_XML_RES_RESID] = INDEXABLE_RES[n].xmlResId;
58 ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = null;
59 ref[COLUMN_INDEX_XML_RES_ICON_RESID] = INDEXABLE_RES[n].iconResId;
60 ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = "android.intent.action.MAIN";
61 ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = "com.android.phone";
62 ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = INDEXABLE_RES[n].className;
Fabrice Di Meglioe5ee4a32014-03-14 19:04:10 -070063 cursor.addRow(ref);
64 }
65 return cursor;
66 }
67
68 @Override
69 public Cursor queryRawData(String[] projection) {
70 MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
71 return cursor;
72 }
Fabrice Di Meglio7b18c722014-04-11 18:52:00 -070073 @Override
74 public Cursor queryNonIndexableKeys(String[] projection) {
75 MatrixCursor cursor = new MatrixCursor(NON_INDEXABLES_KEYS_COLUMNS);
76 return cursor;
77 }
Fabrice Di Meglioe5ee4a32014-03-14 19:04:10 -070078}