Add indexing for Settings (Part 1)

- implement PhoneSearchIndexablesProvider as a SearchIndexablesProvider
- update the AndroidManifest for publishing the new provider
- protect access thru using android.permission.READ_SEARCH_INDEXABLES

Some other CLs will need to be done to define the data to be indexed
thru PhoneIndexablesProvider

Change-Id: I687c35be0e5523b8770524c108f27dbd3fa825de
diff --git a/src/com/android/phone/PhoneSearchIndexablesProvider.java b/src/com/android/phone/PhoneSearchIndexablesProvider.java
new file mode 100644
index 0000000..08af326
--- /dev/null
+++ b/src/com/android/phone/PhoneSearchIndexablesProvider.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.phone;
+
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.provider.SearchIndexableResource;
+import android.provider.SearchIndexablesProvider;
+
+import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
+import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
+
+public class PhoneSearchIndexablesProvider extends SearchIndexablesProvider {
+    private static final String TAG = "PhoneSearchIndexablesProvider";
+
+    private static SearchIndexableResource[] INDEXABLE_RES = new SearchIndexableResource[] {
+            new SearchIndexableResource(1, R.xml.network_setting,
+                    MobileNetworkSettings.class.getName(),
+                    R.mipmap.ic_launcher_phone),
+    };
+
+    @Override
+    public boolean onCreate() {
+        return true;
+    }
+
+    @Override
+    public Cursor queryXmlResources(String[] projection) {
+        MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS);
+        final int count = INDEXABLE_RES.length;
+        for (int n = 0; n < count; n++) {
+            Object[] ref = new Object[7];
+            ref[0] = INDEXABLE_RES[n].rank;
+            ref[1] = INDEXABLE_RES[n].xmlResId;
+            ref[2] = null;
+            ref[3] = INDEXABLE_RES[n].iconResId;
+            ref[4] = "android.intent.action.MAIN";
+            ref[5] = "com.android.phone";
+            ref[6] = MobileNetworkSettings.class.getName();
+            cursor.addRow(ref);
+        }
+        return cursor;
+    }
+
+    @Override
+    public Cursor queryRawData(String[] projection) {
+        MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
+        return cursor;
+    }
+}
\ No newline at end of file