1 /* 2 * Copyright (C) 2024 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 17 package com.android.wallpaper.testing 18 19 import android.content.ContentProvider 20 import android.content.ContentValues 21 import android.database.Cursor 22 import android.database.MatrixCursor 23 import android.net.Uri 24 import com.android.wallpaper.effects.EffectContract 25 import com.android.wallpaper.effects.FakeEffectsController 26 import javax.inject.Inject 27 import javax.inject.Singleton 28 29 @Singleton 30 class FakeContentProvider @Inject constructor() : ContentProvider() { querynull31 override fun query( 32 uri: Uri, 33 projection: Array<out String>?, 34 selection: String?, 35 selectionArgs: Array<out String>?, 36 sortOrder: String? 37 ): Cursor { 38 val cursor = 39 MatrixCursor( 40 arrayOf( 41 EffectContract.ASSET_ID, 42 EffectContract.KEY_EFFECT_ID, 43 EffectContract.KEY_EFFECT_TITLE, 44 ), 45 ) 46 if (uri.authority.equals(FakeEffectsController.AUTHORITY)) { 47 // Return to-be-installed component names (flatten String) 48 cursor 49 .newRow() 50 .add(EffectContract.ASSET_ID, FAKE_ASSET_ID) 51 .add(EffectContract.KEY_EFFECT_ID, FAKE_EFFECT_ID) 52 .add(EffectContract.KEY_EFFECT_TITLE, FAKE_EFFECT_TITLE) 53 } 54 return cursor 55 } 56 getTypenull57 override fun getType(uri: Uri): String? { 58 TODO("Not yet implemented") 59 } 60 insertnull61 override fun insert(uri: Uri, values: ContentValues?): Uri? { 62 TODO("Not yet implemented") 63 } 64 deletenull65 override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int { 66 TODO("Not yet implemented") 67 } 68 updatenull69 override fun update( 70 uri: Uri, 71 values: ContentValues?, 72 selection: String?, 73 selectionArgs: Array<out String>? 74 ): Int { 75 TODO("Not yet implemented") 76 } 77 onCreatenull78 override fun onCreate(): Boolean { 79 TODO("Not yet implemented") 80 } 81 82 companion object { 83 const val FAKE_ASSET_ID = 1 84 const val FAKE_EFFECT_ID = 1 85 const val FAKE_EFFECT_TITLE = "Fake Effect Title" 86 } 87 } 88