Fabrice Di Meglio | e5ee4a3 | 2014-03-14 19:04:10 -0700 | [diff] [blame] | 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.phone; |
| 18 | |
| 19 | import android.database.Cursor; |
| 20 | import android.database.MatrixCursor; |
| 21 | import android.provider.SearchIndexableResource; |
| 22 | import android.provider.SearchIndexablesProvider; |
| 23 | |
Fabrice Di Meglio | 2a52761 | 2014-04-09 19:35:24 -0700 | [diff] [blame] | 24 | import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RANK; |
| 25 | import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID; |
| 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_PACKAGE; |
| 30 | import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS; |
| 31 | |
Fabrice Di Meglio | e5ee4a3 | 2014-03-14 19:04:10 -0700 | [diff] [blame] | 32 | import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS; |
| 33 | import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS; |
| 34 | |
| 35 | public class PhoneSearchIndexablesProvider extends SearchIndexablesProvider { |
| 36 | private static final String TAG = "PhoneSearchIndexablesProvider"; |
| 37 | |
| 38 | private static SearchIndexableResource[] INDEXABLE_RES = new SearchIndexableResource[] { |
| 39 | new SearchIndexableResource(1, R.xml.network_setting, |
| 40 | MobileNetworkSettings.class.getName(), |
| 41 | R.mipmap.ic_launcher_phone), |
| 42 | }; |
| 43 | |
| 44 | @Override |
| 45 | public boolean onCreate() { |
| 46 | return true; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public Cursor queryXmlResources(String[] projection) { |
| 51 | MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS); |
| 52 | final int count = INDEXABLE_RES.length; |
| 53 | for (int n = 0; n < count; n++) { |
| 54 | Object[] ref = new Object[7]; |
Fabrice Di Meglio | 2a52761 | 2014-04-09 19:35:24 -0700 | [diff] [blame] | 55 | ref[COLUMN_INDEX_XML_RES_RANK] = INDEXABLE_RES[n].rank; |
| 56 | ref[COLUMN_INDEX_XML_RES_RESID] = INDEXABLE_RES[n].xmlResId; |
| 57 | ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = null; |
| 58 | ref[COLUMN_INDEX_XML_RES_ICON_RESID] = INDEXABLE_RES[n].iconResId; |
| 59 | ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = "android.intent.action.MAIN"; |
| 60 | ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = "com.android.phone"; |
| 61 | ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = INDEXABLE_RES[n].className; |
Fabrice Di Meglio | e5ee4a3 | 2014-03-14 19:04:10 -0700 | [diff] [blame] | 62 | cursor.addRow(ref); |
| 63 | } |
| 64 | return cursor; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public Cursor queryRawData(String[] projection) { |
| 69 | MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS); |
| 70 | return cursor; |
| 71 | } |
| 72 | } |