CrashingIconProvider.java revision e29d52aa72c96c3147fa91d83aeb8dafc6d1f578
1e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood/* 2e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * Copyright (C) 2010 The Android Open Source Project 3e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * 4e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * Licensed under the Apache License, Version 2.0 (the "License"); 5e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * you may not use this file except in compliance with the License. 6e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * You may obtain a copy of the License at 7e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * 8e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * http://www.apache.org/licenses/LICENSE-2.0 9e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * 10e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * Unless required by applicable law or agreed to in writing, software 11e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * distributed under the License is distributed on an "AS IS" BASIS, 12e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * See the License for the specific language governing permissions and 14e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * limitations under the License. 15e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood */ 16e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwoodpackage com.android.quicksearchbox.tests; 17e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 18e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwoodimport android.content.ContentProvider; 19e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwoodimport android.content.ContentValues; 20e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwoodimport android.database.Cursor; 21e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwoodimport android.net.Uri; 22e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwoodimport android.os.ParcelFileDescriptor; 23e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwoodimport android.util.Log; 24e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 25e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood/** 26e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood * A content provider that crashes when something is requested. 27e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood */ 28e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwoodpublic class CrashingIconProvider extends ContentProvider { 29e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 30e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood private static final String TAG = "QSB." + CrashingIconProvider.class.getSimpleName(); 31e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood private static final boolean DBG = false; 32e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 33e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood public static final String AUTHORITY = "com.android.quicksearchbox.tests.iconcrash"; 34e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 35e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood @Override 36e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood public boolean onCreate() { 37e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood Log.i(TAG, "onCreate"); 38e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood return true; 39e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood } 40e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 41e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood @Override 42e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood public ParcelFileDescriptor openFile(Uri uri, String mode) { 43e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood if (DBG) Log.d(TAG, "openFile(" + uri + ", " + mode + ")"); 44e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood throw new CrashException(); 45e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood } 46e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 47e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood @Override 48e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood public int delete(Uri uri, String selection, String[] selectionArgs) { 49e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood if (DBG) Log.d(TAG, "delete(" + uri + ", " + selection + ", " + selectionArgs + ")"); 50e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood throw new UnsupportedOperationException(); 51e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood } 52e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 53e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood @Override 54e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood public String getType(Uri uri) { 55e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood if (DBG) Log.d(TAG, "getType(" + uri + ")"); 56e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood return "image/png"; 57e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood } 58e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 59e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood @Override 60e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood public Uri insert(Uri uri, ContentValues values) { 61e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood if (DBG) Log.d(TAG, "insert(" + uri + ", " + values + ")"); 62e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood throw new UnsupportedOperationException(); 63e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood } 64e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 65e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood @Override 66e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, 67e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood String sortOrder) { 68e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood if (DBG) Log.d(TAG, "query(" + uri + ")"); 69e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood throw new UnsupportedOperationException(); 70e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood } 71e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 72e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood @Override 73e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { 74e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood if (DBG) Log.d(TAG, "update(" + uri + ")"); 75e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood throw new UnsupportedOperationException(); 76e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood } 77e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 78e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood private static class CrashException extends RuntimeException { 79e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood } 80e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood 81e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood} 82