1 /* 2 * Copyright (C) 2010 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 package com.android.quicksearchbox.tests; 17 18 import android.content.ContentProvider; 19 import android.content.ContentValues; 20 import android.database.Cursor; 21 import android.net.Uri; 22 import android.os.ParcelFileDescriptor; 23 import android.util.Log; 24 25 import java.util.Arrays; 26 27 /** 28 * A content provider that crashes when something is requested. 29 */ 30 public class CrashingIconProvider extends ContentProvider { 31 32 private static final String TAG = "QSB." + CrashingIconProvider.class.getSimpleName(); 33 private static final boolean DBG = false; 34 35 public static final String AUTHORITY = "com.android.quicksearchbox.tests.iconcrash"; 36 37 @Override onCreate()38 public boolean onCreate() { 39 Log.i(TAG, "onCreate"); 40 return true; 41 } 42 43 @Override openFile(Uri uri, String mode)44 public ParcelFileDescriptor openFile(Uri uri, String mode) { 45 if (DBG) Log.d(TAG, "openFile(" + uri + ", " + mode + ")"); 46 throw new CrashException(); 47 } 48 49 @Override delete(Uri uri, String selection, String[] selectionArgs)50 public int delete(Uri uri, String selection, String[] selectionArgs) { 51 if (DBG) { 52 Log.d(TAG, "delete(" + uri + ", " + selection + ", " + 53 Arrays.toString(selectionArgs) + ")"); 54 } 55 throw new UnsupportedOperationException(); 56 } 57 58 @Override getType(Uri uri)59 public String getType(Uri uri) { 60 if (DBG) Log.d(TAG, "getType(" + uri + ")"); 61 return "image/png"; 62 } 63 64 @Override insert(Uri uri, ContentValues values)65 public Uri insert(Uri uri, ContentValues values) { 66 if (DBG) Log.d(TAG, "insert(" + uri + ", " + values + ")"); 67 throw new UnsupportedOperationException(); 68 } 69 70 @Override query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)71 public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, 72 String sortOrder) { 73 if (DBG) Log.d(TAG, "query(" + uri + ")"); 74 throw new UnsupportedOperationException(); 75 } 76 77 @Override update(Uri uri, ContentValues values, String selection, String[] selectionArgs)78 public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { 79 if (DBG) Log.d(TAG, "update(" + uri + ")"); 80 throw new UnsupportedOperationException(); 81 } 82 83 private static class CrashException extends RuntimeException { 84 } 85 86 } 87