Clean up logger (2/3)
We do not need context to get logger from injector
Test: Build success
Bug: 317785936
Flag: None
Change-Id: I05e3ba6556fc5efb101e0ec57bf174c823fddffa
diff --git a/src/com/android/customization/model/grid/GridOptionsManager.java b/src/com/android/customization/model/grid/GridOptionsManager.java
index bd24cf5..09c6c65 100644
--- a/src/com/android/customization/model/grid/GridOptionsManager.java
+++ b/src/com/android/customization/model/grid/GridOptionsManager.java
@@ -56,8 +56,8 @@
if (sGridOptionsManager == null) {
Context appContext = context.getApplicationContext();
CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
- ThemesUserEventLogger eventLogger = (ThemesUserEventLogger) injector.getUserEventLogger(
- appContext);
+ ThemesUserEventLogger eventLogger =
+ (ThemesUserEventLogger) injector.getUserEventLogger();
sGridOptionsManager = new GridOptionsManager(
new LauncherGridOptionsProvider(appContext,
appContext.getString(R.string.grid_control_metadata_name)),
diff --git a/src/com/android/customization/module/CustomizationInjector.kt b/src/com/android/customization/module/CustomizationInjector.kt
index 82203d9..d761598 100644
--- a/src/com/android/customization/module/CustomizationInjector.kt
+++ b/src/com/android/customization/module/CustomizationInjector.kt
@@ -18,7 +18,6 @@
import android.content.Context
import android.content.res.Resources
import androidx.activity.ComponentActivity
-import com.android.customization.module.logging.ThemesUserEventLogger
import com.android.customization.picker.clock.domain.interactor.ClockPickerInteractor
import com.android.customization.picker.clock.ui.view.ClockViewFactory
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselViewModel
@@ -55,7 +54,6 @@
interactor: ClockPickerInteractor,
clockViewFactory: ClockViewFactory,
resources: Resources,
- logger: ThemesUserEventLogger,
): ClockCarouselViewModel.Factory
fun getClockViewFactory(activity: ComponentActivity): ClockViewFactory
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index 44dfa6a..23b776f 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -80,6 +80,7 @@
import com.android.wallpaper.picker.di.modules.MainDispatcher
import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer
import com.android.wallpaper.util.ScreenSizeCalculator
+import dagger.Lazy
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.CoroutineDispatcher
@@ -93,8 +94,7 @@
@MainDispatcher private val mainDispatcher: CoroutineDispatcher,
@BackgroundDispatcher private val bgScope: CoroutineScope,
@BackgroundDispatcher private val bgDispatcher: CoroutineDispatcher,
- private val userEventLogger: ThemesUserEventLogger,
-) : WallpaperPicker2Injector(mainScope, bgDispatcher, userEventLogger), CustomizationInjector {
+) : WallpaperPicker2Injector(mainScope, bgDispatcher), CustomizationInjector {
private var customizationSections: CustomizationSections? = null
private var wallpaperInteractor: WallpaperInteractor? = null
private var keyguardQuickAffordancePickerInteractor: KeyguardQuickAffordancePickerInteractor? =
@@ -125,6 +125,7 @@
private var gridSnapshotRestorer: GridSnapshotRestorer? = null
private var gridScreenViewModelFactory: GridScreenViewModel.Factory? = null
private var clockRegistryProvider: ClockRegistryProvider? = null
+ @Inject lateinit var themesUserEventLogger: Lazy<ThemesUserEventLogger>
override fun getCustomizationSections(activity: ComponentActivity): CustomizationSections {
val appContext = activity.applicationContext
@@ -143,13 +144,12 @@
interactor = getClockPickerInteractor(appContext),
clockViewFactory = clockViewFactory,
resources = resources,
- logger = userEventLogger,
),
clockViewFactory,
getThemedIconSnapshotRestorer(appContext),
getThemedIconInteractor(),
getColorPickerInteractor(appContext, getWallpaperColorsRepository()),
- getUserEventLogger(appContext),
+ getUserEventLogger(),
)
.also { customizationSections = it }
}
@@ -167,8 +167,8 @@
}
@Synchronized
- override fun getUserEventLogger(context: Context): ThemesUserEventLogger {
- return userEventLogger
+ override fun getUserEventLogger(): ThemesUserEventLogger {
+ return themesUserEventLogger.get()
}
override fun getFragmentFactory(): FragmentFactory? {
@@ -247,7 +247,7 @@
getKeyguardQuickAffordancePickerInteractor(context),
getWallpaperInteractor(context),
getCurrentWallpaperInfoFactory(context),
- getUserEventLogger(context),
+ getUserEventLogger(),
)
.also { keyguardQuickAffordancePickerViewModelFactory = it }
}
@@ -291,7 +291,7 @@
return notificationSectionViewModelFactory
?: NotificationSectionViewModel.Factory(
interactor = getNotificationsInteractor(context),
- logger = getUserEventLogger(context),
+ logger = getUserEventLogger(),
)
.also { notificationSectionViewModelFactory = it }
}
@@ -357,7 +357,6 @@
interactor: ClockPickerInteractor,
clockViewFactory: ClockViewFactory,
resources: Resources,
- logger: ThemesUserEventLogger,
): ClockCarouselViewModel.Factory {
return clockCarouselViewModelFactory
?: ClockCarouselViewModel.Factory(
@@ -365,7 +364,7 @@
bgDispatcher,
clockViewFactory,
resources,
- logger,
+ getUserEventLogger(),
)
.also { clockCarouselViewModelFactory = it }
}
@@ -436,7 +435,7 @@
?: ColorPickerViewModel.Factory(
context.applicationContext,
getColorPickerInteractor(context, wallpaperColorsRepository),
- userEventLogger,
+ getUserEventLogger(),
)
.also { colorPickerViewModelFactory = it }
}
@@ -508,7 +507,7 @@
context,
wallpaperColorsRepository,
),
- userEventLogger,
+ getUserEventLogger(),
) { clockId ->
clockId?.let { clockViewFactory.getController(clockId).config.isReactiveToTone }
?: false
diff --git a/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt b/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
index 2c00609..8fbbd78 100644
--- a/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
+++ b/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
@@ -203,7 +203,7 @@
context,
lifecycle,
injector.getDarkModeSnapshotRestorer(requireContext()),
- injector.getUserEventLogger(requireContext()),
+ injector.getUserEventLogger(),
)
.createView(requireContext())
darkModeSectionView.background = null
diff --git a/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt b/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt
index 6831e7c..caa5029 100644
--- a/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt
+++ b/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt
@@ -76,7 +76,6 @@
interactor: ClockPickerInteractor,
clockViewFactory: ClockViewFactory,
resources: Resources,
- logger: ThemesUserEventLogger,
): ClockCarouselViewModel.Factory {
throw UnsupportedOperationException("not implemented")
}
@@ -97,7 +96,7 @@
// TestInjector overrides
/////////////////
- override fun getUserEventLogger(context: Context): UserEventLogger {
+ override fun getUserEventLogger(): UserEventLogger {
return themesUserEventLogger
}
}