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