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 | |
| 24 | import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS; |
| 25 | import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS; |
| 26 | |
| 27 | public class PhoneSearchIndexablesProvider extends SearchIndexablesProvider { |
| 28 | private static final String TAG = "PhoneSearchIndexablesProvider"; |
| 29 | |
| 30 | private static SearchIndexableResource[] INDEXABLE_RES = new SearchIndexableResource[] { |
| 31 | new SearchIndexableResource(1, R.xml.network_setting, |
| 32 | MobileNetworkSettings.class.getName(), |
| 33 | R.mipmap.ic_launcher_phone), |
| 34 | }; |
| 35 | |
| 36 | @Override |
| 37 | public boolean onCreate() { |
| 38 | return true; |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public Cursor queryXmlResources(String[] projection) { |
| 43 | MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS); |
| 44 | final int count = INDEXABLE_RES.length; |
| 45 | for (int n = 0; n < count; n++) { |
| 46 | Object[] ref = new Object[7]; |
| 47 | ref[0] = INDEXABLE_RES[n].rank; |
| 48 | ref[1] = INDEXABLE_RES[n].xmlResId; |
| 49 | ref[2] = null; |
| 50 | ref[3] = INDEXABLE_RES[n].iconResId; |
| 51 | ref[4] = "android.intent.action.MAIN"; |
| 52 | ref[5] = "com.android.phone"; |
| 53 | ref[6] = MobileNetworkSettings.class.getName(); |
| 54 | cursor.addRow(ref); |
| 55 | } |
| 56 | return cursor; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public Cursor queryRawData(String[] projection) { |
| 61 | MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS); |
| 62 | return cursor; |
| 63 | } |
| 64 | } |