102d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert/* 202d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * Copyright (C) 2009 The Android Open Source Project 302d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * 402d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); 502d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * you may not use this file except in compliance with the License. 602d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * You may obtain a copy of the License at 702d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * 802d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 902d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * 1002d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * Unless required by applicable law or agreed to in writing, software 1102d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS, 1202d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1302d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * See the License for the specific language governing permissions and 1402d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert * limitations under the License. 1502d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert */ 1602d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 1702d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringertpackage com.android.quicksearchbox.tests.slow; 1802d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 1902d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringertimport android.app.SearchManager; 2002d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringertimport android.content.ContentProvider; 2102d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringertimport android.content.ContentValues; 2202d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringertimport android.content.Intent; 2302d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringertimport android.database.Cursor; 2402d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringertimport android.database.MatrixCursor; 2502d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringertimport android.net.Uri; 2602d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringertimport android.util.Log; 2702d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 2802d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringertpublic class SlowSuggestionProvider extends ContentProvider { 2902d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 3002d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert private static final String TAG = SlowSuggestionProvider.class.getSimpleName(); 3102d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 3202d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert private static final String[] COLUMNS = { 3302d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert "_id", 3402d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert SearchManager.SUGGEST_COLUMN_TEXT_1, 3502d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert SearchManager.SUGGEST_COLUMN_TEXT_2, 3602d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert SearchManager.SUGGEST_COLUMN_INTENT_ACTION, 3702d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert SearchManager.SUGGEST_COLUMN_INTENT_DATA, 3802d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert }; 3902d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 4002d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert @Override 4102d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert public boolean onCreate() { 4202d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert return true; 4302d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert } 4402d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 4502d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert @Override 4602d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert public Cursor query(Uri uri, String[] projectionIn, String selection, 4702d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert String[] selectionArgs, String sortOrder) { 4802d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert Log.d(TAG, "query(" + uri + ")"); 4902d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 5002d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert try { 5102d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert Thread.sleep(20000); 5202d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert } catch (InterruptedException ex) { 5302d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert Log.d(TAG, "Interrupted"); 5402d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert } 5502d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 5602d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert MatrixCursor cursor = new MatrixCursor(COLUMNS); 5702d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert for (int i = 0; i < 3; i++) { 5802d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert cursor.addRow(new Object[]{ 5902d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert i, 6002d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert "Slow suggestion " + i, 6102d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert "This suggestion takes a long time to appear", 6202d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert Intent.ACTION_VIEW, 6302d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert "content://com.android.quicksearchbox.slow/slow/" + i 6402d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert }); 6502d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert } 6602d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert return cursor; 6702d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert } 6802d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 6902d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert @Override 7002d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert public String getType(Uri uri) { 7102d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert return SearchManager.SUGGEST_MIME_TYPE; 7202d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert } 7302d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 7402d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert @Override 7502d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert public Uri insert(Uri uri, ContentValues values) { 7602d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert throw new UnsupportedOperationException(); 7702d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert } 7802d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 7902d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert @Override 8002d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert public int update(Uri uri, ContentValues values, String selection, 8102d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert String[] selectionArgs) { 8202d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert throw new UnsupportedOperationException(); 8302d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert } 8402d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 8502d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert @Override 8602d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert public int delete(Uri uri, String selection, String[] selectionArgs) { 8702d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert throw new UnsupportedOperationException(); 8802d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert } 8902d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert 9002d897ec26d81fa1f3cb9e1b8f05c6bcb5d7b9dbBjorn Bringert} 91