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 */ 16package com.android.quicksearchbox.tests.naughty; 17 18import android.app.SearchManager; 19import android.content.ContentProvider; 20import android.content.ContentValues; 21import android.content.res.AssetFileDescriptor; 22import android.net.Uri; 23import android.os.Bundle; 24 25/** 26 * Base class for 'naughty' suggestion providers. 27 */ 28public abstract class NaughtySuggestionProvider extends ContentProvider { 29 30 @Override 31 public boolean onCreate() { 32 return true; 33 } 34 35 protected abstract void beNaughty(); 36 37 @Override 38 public String getType(Uri uri) { 39 return SearchManager.SUGGEST_MIME_TYPE; 40 } 41 42 @Override 43 public Uri insert(Uri uri, ContentValues values) { 44 throw new UnsupportedOperationException(); 45 } 46 47 @Override 48 public int update(Uri uri, ContentValues values, String selection, 49 String[] selectionArgs) { 50 throw new UnsupportedOperationException(); 51 } 52 53 @Override 54 public int delete(Uri uri, String selection, String[] selectionArgs) { 55 throw new UnsupportedOperationException(); 56 } 57 58 @Override 59 public AssetFileDescriptor openTypedAssetFile(Uri uri, String mimeTypeFilter, Bundle opts) { 60 beNaughty(); 61 return null; 62 } 63 64} 65