1 package com.android.customization.testing; 2 3 import android.content.Context; 4 5 import androidx.fragment.app.FragmentActivity; 6 7 import com.android.customization.model.theme.OverlayManagerCompat; 8 import com.android.customization.model.theme.ThemeBundleProvider; 9 import com.android.customization.model.theme.ThemeManager; 10 import com.android.customization.module.CustomizationInjector; 11 import com.android.customization.module.CustomizationPreferences; 12 import com.android.customization.module.ThemesUserEventLogger; 13 import com.android.wallpaper.module.DrawableLayerResolver; 14 import com.android.wallpaper.module.PackageStatusNotifier; 15 import com.android.wallpaper.module.UserEventLogger; 16 import com.android.wallpaper.testing.TestInjector; 17 18 /** 19 * Test implementation of the dependency injector. 20 */ 21 public class TestCustomizationInjector extends TestInjector implements CustomizationInjector { 22 private CustomizationPreferences mCustomizationPreferences; 23 private ThemeManager mThemeManager; 24 private PackageStatusNotifier mPackageStatusNotifier; 25 private DrawableLayerResolver mDrawableLayerResolver; 26 private UserEventLogger mUserEventLogger; 27 28 @Override getCustomizationPreferences(Context context)29 public CustomizationPreferences getCustomizationPreferences(Context context) { 30 if (mCustomizationPreferences == null) { 31 mCustomizationPreferences = new TestDefaultCustomizationPreferences(context); 32 } 33 return mCustomizationPreferences; 34 } 35 36 @Override getThemeManager( ThemeBundleProvider provider, FragmentActivity activity, OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger logger)37 public ThemeManager getThemeManager( 38 ThemeBundleProvider provider, 39 FragmentActivity activity, 40 OverlayManagerCompat overlayManagerCompat, 41 ThemesUserEventLogger logger) { 42 if (mThemeManager == null) { 43 mThemeManager = new TestThemeManager(provider, activity, overlayManagerCompat, logger); 44 } 45 return mThemeManager; 46 } 47 48 @Override getPackageStatusNotifier(Context context)49 public PackageStatusNotifier getPackageStatusNotifier(Context context) { 50 if (mPackageStatusNotifier == null) { 51 mPackageStatusNotifier = new TestPackageStatusNotifier(); 52 } 53 return mPackageStatusNotifier; 54 } 55 56 @Override getDrawableLayerResolver()57 public DrawableLayerResolver getDrawableLayerResolver() { 58 if (mDrawableLayerResolver == null) { 59 mDrawableLayerResolver = new TestDrawableLayerResolver(); 60 } 61 return mDrawableLayerResolver; 62 } 63 64 @Override getUserEventLogger(Context unused)65 public UserEventLogger getUserEventLogger(Context unused) { 66 if (mUserEventLogger == null) { 67 mUserEventLogger = new TestThemesUserEventLogger(); 68 } 69 return mUserEventLogger; 70 } 71 } 72