1 /* 2 * Copyright (C) 2017 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.wallpaper.module 17 18 import android.app.WallpaperColors 19 import android.content.Context 20 import android.content.Intent 21 import android.net.Uri 22 import androidx.activity.ComponentActivity 23 import androidx.fragment.app.Fragment 24 import androidx.lifecycle.LifecycleOwner 25 import com.android.customization.model.color.WallpaperColorResources 26 import com.android.wallpaper.config.BaseFlags 27 import com.android.wallpaper.effects.EffectsController 28 import com.android.wallpaper.model.CategoryProvider 29 import com.android.wallpaper.model.InlinePreviewIntentFactory 30 import com.android.wallpaper.model.WallpaperInfo 31 import com.android.wallpaper.module.logging.UserEventLogger 32 import com.android.wallpaper.monitor.PerformanceMonitor 33 import com.android.wallpaper.network.Requester 34 import com.android.wallpaper.picker.MyPhotosStarter.MyPhotosIntentProvider 35 import com.android.wallpaper.picker.category.wrapper.WallpaperCategoryWrapper 36 import com.android.wallpaper.picker.customization.data.content.WallpaperClient 37 import com.android.wallpaper.picker.customization.data.repository.WallpaperColorsRepository 38 import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor 39 import com.android.wallpaper.picker.customization.domain.interactor.WallpaperSnapshotRestorer 40 import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer 41 import com.android.wallpaper.picker.undo.domain.interactor.UndoInteractor 42 import com.android.wallpaper.util.DisplayUtils 43 import kotlinx.coroutines.CoroutineScope 44 45 /** 46 * Interface for a provider of "injected dependencies." (NOTE: The term "injector" is somewhat of a 47 * misnomer; this is more aptly a service registry as part of a service locator design pattern.) 48 */ 49 interface Injector { 50 /** 51 * Returns a [CoroutineScope] that's bound to the lifecycle of the application. 52 * 53 * It starts immediately and is never paused, stopped, or destroyed. 54 */ getApplicationCoroutineScopenull55 fun getApplicationCoroutineScope(): CoroutineScope 56 57 fun getAlarmManagerWrapper(context: Context): AlarmManagerWrapper 58 59 fun getBitmapCropper(): BitmapCropper 60 61 fun getCategoryProvider(context: Context): CategoryProvider 62 63 fun getCurrentWallpaperInfoFactory(context: Context): CurrentWallpaperInfoFactory 64 65 fun getCustomizationSections(activity: ComponentActivity): CustomizationSections 66 67 fun getDeepLinkRedirectIntent(context: Context, uri: Uri): Intent 68 69 fun getDisplayUtils(context: Context): DisplayUtils 70 71 fun getDownloadableIntentAction(): String? 72 73 fun getDrawableLayerResolver(): DrawableLayerResolver 74 75 fun getEffectsController(context: Context): EffectsController? 76 77 fun getExploreIntentChecker(context: Context): ExploreIntentChecker 78 79 fun getIndividualPickerFragment(context: Context, collectionId: String): Fragment 80 81 fun getLiveWallpaperInfoFactory(context: Context): LiveWallpaperInfoFactory 82 83 fun getNetworkStatusNotifier(context: Context): NetworkStatusNotifier 84 85 fun getPackageStatusNotifier(context: Context): PackageStatusNotifier 86 87 fun getPartnerProvider(context: Context): PartnerProvider 88 89 fun getPerformanceMonitor(): PerformanceMonitor? 90 91 // TODO b/242908637 Remove this method when migrating to the new wallpaper preview screen 92 fun getPreviewFragment( 93 context: Context, 94 wallpaperInfo: WallpaperInfo, 95 viewAsHome: Boolean, 96 isAssetIdPresent: Boolean, 97 isNewTask: Boolean, 98 ): Fragment 99 100 fun getRequester(context: Context): Requester 101 102 fun getSystemFeatureChecker(): SystemFeatureChecker 103 104 fun getUserEventLogger(): UserEventLogger 105 106 fun getWallpaperPersister(context: Context): WallpaperPersister 107 108 fun getPreferences(context: Context): WallpaperPreferences 109 110 fun getWallpaperRefresher(context: Context): WallpaperRefresher 111 112 fun getWallpaperStatusChecker(context: Context): WallpaperStatusChecker 113 114 fun getFragmentFactory(): FragmentFactory? { 115 return null 116 } 117 getFlagsnull118 fun getFlags(): BaseFlags 119 120 fun getUndoInteractor(context: Context, lifecycleOwner: LifecycleOwner): UndoInteractor 121 122 fun getSnapshotRestorers(context: Context): Map<Int, SnapshotRestorer> { 123 // Empty because we don't support undoing in WallpaperPicker2. 124 return HashMap() 125 } 126 getWallpaperInteractornull127 fun getWallpaperInteractor(context: Context): WallpaperInteractor 128 129 fun getWallpaperClient(context: Context): WallpaperClient 130 131 fun getWallpaperSnapshotRestorer(context: Context): WallpaperSnapshotRestorer 132 133 fun getWallpaperColorsRepository(): WallpaperColorsRepository 134 135 fun getWallpaperCategoryWrapper(): WallpaperCategoryWrapper 136 137 fun getWallpaperColorResources( 138 wallpaperColors: WallpaperColors, 139 context: Context, 140 ): WallpaperColorResources 141 142 fun getMyPhotosIntentProvider(): MyPhotosIntentProvider 143 144 fun isInstrumentationTest(): Boolean { 145 return false 146 } 147 isCurrentSelectedColorPresetnull148 fun isCurrentSelectedColorPreset(context: Context): Boolean 149 150 /** 151 * Implements [InlinePreviewIntentFactory] that provides an intent to start [PreviewActivity]. 152 */ 153 fun getPreviewActivityIntentFactory(): InlinePreviewIntentFactory 154 155 /** 156 * Implements [InlinePreviewIntentFactory] that provides an intent to start 157 * [ViewOnlyPreviewActivity]. 158 * 159 * TODO(b/298037335): Rename or remove view only preview. 160 */ 161 fun getViewOnlyPreviewActivityIntentFactory(): InlinePreviewIntentFactory 162 } 163