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