1 /* 2 * Copyright (C) 2019 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.O 15 */ 16 package com.android.wallpaper.testing 17 18 import com.android.wallpaper.model.WallpaperMetadata 19 import com.android.wallpaper.module.WallpaperPreferences 20 import com.android.wallpaper.module.WallpaperRefresher 21 import com.android.wallpaper.module.WallpaperRefresher.RefreshListener 22 import javax.inject.Inject 23 import javax.inject.Singleton 24 25 /** 26 * Test implementation of [WallpaperRefresher] which simply provides whatever metadata is saved in 27 * WallpaperPreferences and the image wallpaper set to [WallpaperManager]. 28 */ 29 @Singleton 30 class FakeWallpaperRefresher @Inject constructor(private val prefs: WallpaperPreferences) : 31 WallpaperRefresher { 32 refreshnull33 override fun refresh(listener: RefreshListener) { 34 if (prefs.getLockWallpaperManagerId() > 0) { 35 listener.onRefreshed( 36 WallpaperMetadata( 37 prefs.getHomeWallpaperAttributions(), 38 prefs.getHomeWallpaperActionUrl(), 39 prefs.getHomeWallpaperCollectionId(), /* wallpaperComponent */ 40 null, 41 /* cropHints= */ null, 42 /* imageUri= */ null, 43 ), 44 WallpaperMetadata( 45 prefs.getLockWallpaperAttributions(), 46 prefs.getLockWallpaperActionUrl(), 47 prefs.getLockWallpaperCollectionId(), /* wallpaperComponent */ 48 null, 49 /* cropHints= */ null, 50 /* imageUri= */ null, 51 ), 52 prefs.getWallpaperPresentationMode(), 53 ) 54 } else { 55 listener.onRefreshed( 56 WallpaperMetadata( 57 prefs.getHomeWallpaperAttributions(), 58 prefs.getHomeWallpaperActionUrl(), 59 prefs.getHomeWallpaperCollectionId(), /* wallpaperComponent */ 60 null, 61 /* cropHints= */ null, 62 /* imageUri= */ null, 63 ), 64 null, 65 prefs.getWallpaperPresentationMode(), 66 ) 67 } 68 } 69 } 70