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