1/* 2 * Copyright (C) 2009 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.quicksearchbox.tests.spammy; 18 19import android.app.SearchManager; 20import android.content.ContentProvider; 21import android.content.ContentValues; 22import android.content.Intent; 23import android.database.Cursor; 24import android.database.MatrixCursor; 25import android.net.Uri; 26import android.util.Log; 27 28public class SpammySuggestionProvider extends ContentProvider { 29 30 private static final String TAG = SpammySuggestionProvider.class.getSimpleName(); 31 32 private static final String[] COLUMNS = { 33 "_id", 34 SearchManager.SUGGEST_COLUMN_TEXT_1, 35 SearchManager.SUGGEST_COLUMN_TEXT_2, 36 SearchManager.SUGGEST_COLUMN_INTENT_ACTION, 37 SearchManager.SUGGEST_COLUMN_INTENT_DATA, 38 }; 39 40 @Override 41 public boolean onCreate() { 42 return true; 43 } 44 45 @Override 46 public Cursor query(Uri uri, String[] projectionIn, String selection, 47 String[] selectionArgs, String sortOrder) { 48 Log.d(TAG, "query(" + uri + ")"); 49 50 MatrixCursor cursor = new MatrixCursor(COLUMNS); 51 for (int i = 0; i < 100; i++) { 52 cursor.addRow(new Object[]{ 53 i, 54 "Spam suggestion " + i, 55 "This is spam", 56 Intent.ACTION_VIEW, 57 "content://com.android.quicksearchbox.spammy/spam/" + i 58 }); 59 } 60 return cursor; 61 } 62 63 @Override 64 public String getType(Uri uri) { 65 return SearchManager.SUGGEST_MIME_TYPE; 66 } 67 68 @Override 69 public Uri insert(Uri uri, ContentValues values) { 70 throw new UnsupportedOperationException(); 71 } 72 73 @Override 74 public int update(Uri uri, ContentValues values, String selection, 75 String[] selectionArgs) { 76 throw new UnsupportedOperationException(); 77 } 78 79 @Override 80 public int delete(Uri uri, String selection, String[] selectionArgs) { 81 throw new UnsupportedOperationException(); 82 } 83 84} 85