Merge "Add missing permission to manifest" into tm-qpr-dev
diff --git a/ktfmt_includes.txt b/ktfmt_includes.txt
index 703e852..112b4a1 100644
--- a/ktfmt_includes.txt
+++ b/ktfmt_includes.txt
@@ -1,7 +1,3 @@
 +src/
 +src_override/
 +tests/
--src/com/android/customization/model/color/ColorProvider.kt
--src/com/android/customization/model/color/ColorUtils.kt
--src/com/android/customization/module/SysUiStatsLogger.kt
--src/com/android/customization/picker/clock/ClockSectionView.kt
diff --git a/src/com/android/customization/model/color/ColorBundle.java b/src/com/android/customization/model/color/ColorBundle.java
index dc5a367..2f2df51 100644
--- a/src/com/android/customization/model/color/ColorBundle.java
+++ b/src/com/android/customization/model/color/ColorBundle.java
@@ -15,18 +15,11 @@
  */
 package com.android.customization.model.color;
 
-import static com.android.customization.model.ResourceConstants.PATH_SIZE;
-
 import android.content.Context;
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.graphics.Color;
-import android.graphics.Path;
 import android.graphics.PorterDuff;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.ShapeDrawable;
-import android.graphics.drawable.shapes.PathShape;
-import android.text.TextUtils;
 import android.view.View;
 import android.widget.ImageView;
 
@@ -34,16 +27,13 @@
 import androidx.annotation.Dimension;
 import androidx.annotation.NonNull;
 import androidx.annotation.VisibleForTesting;
-import androidx.core.graphics.PathParser;
 
 import com.android.customization.model.ResourceConstants;
 import com.android.systemui.monet.Style;
 import com.android.wallpaper.R;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -103,8 +93,6 @@
         // Monet system palette and accent colors
         @ColorInt public final int primaryColorLight;
         @ColorInt public final int primaryColorDark;
-        public final List<Drawable> icons;
-        public final Drawable shapeDrawable;
         @Dimension
         public final int bottomSheetCornerRadius;
 
@@ -115,14 +103,11 @@
 
         private PreviewInfo(
                 int secondaryColorLight, int secondaryColorDark, int colorSystemPaletteLight,
-                int primaryColorDark, List<Drawable> icons, Drawable shapeDrawable,
-                @Dimension int cornerRadius) {
+                int primaryColorDark, @Dimension int cornerRadius) {
             this.secondaryColorLight = secondaryColorLight;
             this.secondaryColorDark = secondaryColorDark;
             this.primaryColorLight = colorSystemPaletteLight;
             this.primaryColorDark = primaryColorDark;
-            this.icons = icons;
-            this.shapeDrawable = shapeDrawable;
             this.bottomSheetCornerRadius = cornerRadius;
         }
 
@@ -188,7 +173,6 @@
         // System and Monet colors
         @ColorInt private int mPrimaryColorLight = Color.TRANSPARENT;
         @ColorInt private int mPrimaryColorDark = Color.TRANSPARENT;
-        private List<Drawable> mIcons = new ArrayList<>();
         private boolean mIsDefault;
         private Style mStyle = Style.TONAL_SPOT;
         private int mIndex;
@@ -213,26 +197,12 @@
          * @return the {@link PreviewInfo} object
          */
         public PreviewInfo createPreviewInfo(@NonNull Context context) {
-            ShapeDrawable shapeDrawable = null;
             Resources system = context.getResources().getSystem();
-            String pathString = system.getString(
-                    system.getIdentifier(ResourceConstants.CONFIG_ICON_MASK,
-                            "string", ResourceConstants.ANDROID_PACKAGE));
-            Path path = null;
-            if (!TextUtils.isEmpty(pathString)) {
-                path = PathParser.createPathFromPathData(pathString);
-            }
-            if (path != null) {
-                PathShape shape = new PathShape(path, PATH_SIZE, PATH_SIZE);
-                shapeDrawable = new ShapeDrawable(shape);
-                shapeDrawable.setIntrinsicHeight((int) PATH_SIZE);
-                shapeDrawable.setIntrinsicWidth((int) PATH_SIZE);
-            }
             return new PreviewInfo(mSecondaryColorLight,
-                    mSecondaryColorDark, mPrimaryColorLight, mPrimaryColorDark, mIcons,
-                    shapeDrawable, system.getDimensionPixelOffset(
-                    system.getIdentifier(ResourceConstants.CONFIG_CORNERRADIUS,
-                            "dimen", ResourceConstants.ANDROID_PACKAGE)));
+                    mSecondaryColorDark, mPrimaryColorLight, mPrimaryColorDark,
+                    system.getDimensionPixelOffset(
+                            system.getIdentifier(ResourceConstants.CONFIG_CORNERRADIUS, "dimen",
+                                    ResourceConstants.ANDROID_PACKAGE)));
         }
 
         public Map<String, String> getPackages() {
@@ -298,16 +268,6 @@
         }
 
         /**
-         * Sets icon for bundle
-         * @param icon icon in {@link Drawable}
-         * @return this of {@link Builder}
-         */
-        public Builder addIcon(Drawable icon) {
-            mIcons.add(icon);
-            return this;
-        }
-
-        /**
          * Sets overlay package for bundle
          * @param category the category of bundle
          * @param packageName tha name of package in the category
diff --git a/src/com/android/customization/model/color/ColorBundlePreviewExtractor.java b/src/com/android/customization/model/color/ColorBundlePreviewExtractor.java
index b67eec8..55b637f 100644
--- a/src/com/android/customization/model/color/ColorBundlePreviewExtractor.java
+++ b/src/com/android/customization/model/color/ColorBundlePreviewExtractor.java
@@ -15,18 +15,12 @@
  */
 package com.android.customization.model.color;
 
-import static com.android.customization.model.ResourceConstants.ANDROID_PACKAGE;
-import static com.android.customization.model.ResourceConstants.ICONS_FOR_PREVIEW;
 import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_COLOR;
 import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SYSTEM_PALETTE;
 import static com.android.customization.model.color.ColorUtils.toColorString;
 
 import android.content.Context;
 import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.Resources;
-import android.content.res.Resources.NotFoundException;
-import android.graphics.drawable.Drawable;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -80,26 +74,4 @@
         }
         builder.setStyle(s);
     }
-
-    void addAndroidIconOverlay(ColorBundle.Builder builder) throws NameNotFoundException {
-        addSystemDefaultIcons(builder, ICONS_FOR_PREVIEW);
-    }
-
-    void addSystemDefaultIcons(ColorBundle.Builder builder, String... previewIcons) {
-        try {
-            for (String iconName : previewIcons) {
-                builder.addIcon(loadIconPreviewDrawable(iconName));
-            }
-        } catch (NameNotFoundException | NotFoundException e) {
-            Log.w(TAG, "Didn't find android package icons, will skip preview", e);
-        }
-    }
-
-    Drawable loadIconPreviewDrawable(String drawableName)
-            throws NameNotFoundException, NotFoundException {
-        Resources packageRes = mPackageManager.getResourcesForApplication(ANDROID_PACKAGE);
-        Resources res = Resources.getSystem();
-        return res.getDrawable(packageRes.getIdentifier(drawableName, "drawable",
-                        ANDROID_PACKAGE), null);
-    }
 }
diff --git a/src/com/android/customization/model/color/ColorProvider.kt b/src/com/android/customization/model/color/ColorProvider.kt
index a63f904..814a963 100644
--- a/src/com/android/customization/model/color/ColorProvider.kt
+++ b/src/com/android/customization/model/color/ColorProvider.kt
@@ -19,7 +19,6 @@
 import android.content.Context
 import android.content.res.ColorStateList
 import android.content.res.Resources
-import android.text.TextUtils
 import androidx.annotation.ColorInt
 import androidx.core.graphics.ColorUtils.setAlphaComponent
 import androidx.lifecycle.LifecycleOwner
@@ -29,8 +28,8 @@
 import com.android.customization.model.ResourceConstants.COLOR_BUNDLE_MAIN_COLOR_PREFIX
 import com.android.customization.model.ResourceConstants.COLOR_BUNDLE_NAME_PREFIX
 import com.android.customization.model.ResourceConstants.COLOR_BUNDLE_STYLE_PREFIX
-import com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SYSTEM_PALETTE
 import com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_COLOR
+import com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SYSTEM_PALETTE
 import com.android.customization.model.ResourcesApkProvider
 import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_HOME
 import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_LOCK
@@ -39,19 +38,18 @@
 import com.android.systemui.monet.Style
 import com.android.wallpaper.compat.WallpaperManagerCompat
 import com.android.wallpaper.module.InjectorProvider
+import java.util.*
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.SupervisorJob
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.withContext
-import java.util.*
 
 /**
- * Default implementation of {@link ColorOptionsProvider} that reads preset colors from
- * a stub APK.
+ * Default implementation of {@link ColorOptionsProvider} that reads preset colors from a stub APK.
  */
 class ColorProvider(context: Context, stubPackageName: String) :
-        ResourcesApkProvider(context, stubPackageName), ColorOptionsProvider {
+    ResourcesApkProvider(context, stubPackageName), ColorOptionsProvider {
 
     companion object {
         const val themeStyleEnabled = true
@@ -64,36 +62,41 @@
 
     private val monetEnabled = ColorUtils.isMonetEnabled(context)
     // TODO(b/202145216): Use style method to fetch the list of style.
-    private var styleList = if (themeStyleEnabled) arrayOf(
-        Style.TONAL_SPOT, Style.SPRITZ, Style.VIBRANT, Style.EXPRESSIVE
-    ) else arrayOf(Style.TONAL_SPOT)
+    private var styleList =
+        if (themeStyleEnabled)
+            arrayOf(Style.TONAL_SPOT, Style.SPRITZ, Style.VIBRANT, Style.EXPRESSIVE)
+        else arrayOf(Style.TONAL_SPOT)
 
-    private val scope = if (mContext is LifecycleOwner) {
-        mContext.lifecycleScope
-    } else {
-        CoroutineScope(Dispatchers.Default + SupervisorJob())
-    }
+    private val scope =
+        if (mContext is LifecycleOwner) {
+            mContext.lifecycleScope
+        } else {
+            CoroutineScope(Dispatchers.Default + SupervisorJob())
+        }
 
     private var colorsAvailable = true
     private var colorBundles: List<ColorOption>? = null
     private var homeWallpaperColors: WallpaperColors? = null
     private var lockWallpaperColors: WallpaperColors? = null
 
-
     override fun isAvailable(): Boolean {
         return monetEnabled && super.isAvailable() && colorsAvailable
     }
 
-    override fun fetch(callback: OptionsFetchedListener<ColorOption>?, reload: Boolean,
-                       homeWallpaperColors: WallpaperColors?,
-                       lockWallpaperColors: WallpaperColors?) {
-        val wallpaperColorsChanged = this.homeWallpaperColors != homeWallpaperColors
-                || this.lockWallpaperColors != lockWallpaperColors
+    override fun fetch(
+        callback: OptionsFetchedListener<ColorOption>?,
+        reload: Boolean,
+        homeWallpaperColors: WallpaperColors?,
+        lockWallpaperColors: WallpaperColors?
+    ) {
+        val wallpaperColorsChanged =
+            this.homeWallpaperColors != homeWallpaperColors ||
+                this.lockWallpaperColors != lockWallpaperColors
         if (wallpaperColorsChanged) {
             this.homeWallpaperColors = homeWallpaperColors
             this.lockWallpaperColors = lockWallpaperColors
         }
-        if(colorBundles == null || reload || wallpaperColorsChanged) {
+        if (colorBundles == null || reload || wallpaperColorsChanged) {
             scope.launch {
                 try {
                     if (colorBundles == null || reload) {
@@ -119,46 +122,56 @@
         // is the most recently set wallpaper
         val manager = InjectorProvider.getInjector().getWallpaperManagerCompat(mContext)
         return manager.getWallpaperId(WallpaperManagerCompat.FLAG_LOCK) >
-                manager.getWallpaperId(WallpaperManagerCompat.FLAG_SYSTEM)
+            manager.getWallpaperId(WallpaperManagerCompat.FLAG_SYSTEM)
     }
 
-    private fun loadSeedColors(homeWallpaperColors: WallpaperColors?,
-                               lockWallpaperColors: WallpaperColors?) {
+    private fun loadSeedColors(
+        homeWallpaperColors: WallpaperColors?,
+        lockWallpaperColors: WallpaperColors?
+    ) {
         if (homeWallpaperColors == null) return
 
         val bundles: MutableList<ColorOption> = ArrayList()
-        val colorsPerSource = if (lockWallpaperColors == null) {
-            MAX_SEED_COLORS
-        } else {
-            MAX_SEED_COLORS / 2
-        }
+        val colorsPerSource =
+            if (lockWallpaperColors == null) {
+                MAX_SEED_COLORS
+            } else {
+                MAX_SEED_COLORS / 2
+            }
 
         if (lockWallpaperColors != null) {
             val shouldLockColorsGoFirst = isLockScreenWallpaperLastApplied()
             // First half of the colors
             buildColorSeeds(
-                    if (shouldLockColorsGoFirst) lockWallpaperColors else homeWallpaperColors,
-                    colorsPerSource,
-                    if (shouldLockColorsGoFirst) COLOR_SOURCE_LOCK else COLOR_SOURCE_HOME,
-                    true,
-                    bundles)
+                if (shouldLockColorsGoFirst) lockWallpaperColors else homeWallpaperColors,
+                colorsPerSource,
+                if (shouldLockColorsGoFirst) COLOR_SOURCE_LOCK else COLOR_SOURCE_HOME,
+                true,
+                bundles
+            )
             // Second half of the colors
             buildColorSeeds(
-                    if (shouldLockColorsGoFirst) homeWallpaperColors else lockWallpaperColors,
-                    MAX_SEED_COLORS - bundles.size / styleSize,
-                    if (shouldLockColorsGoFirst) COLOR_SOURCE_HOME else COLOR_SOURCE_LOCK,
-                    false,
-                    bundles)
+                if (shouldLockColorsGoFirst) homeWallpaperColors else lockWallpaperColors,
+                MAX_SEED_COLORS - bundles.size / styleSize,
+                if (shouldLockColorsGoFirst) COLOR_SOURCE_HOME else COLOR_SOURCE_LOCK,
+                false,
+                bundles
+            )
         } else {
             buildColorSeeds(homeWallpaperColors, colorsPerSource, COLOR_SOURCE_HOME, true, bundles)
         }
 
-        bundles.addAll(colorBundles?.filterNot{it is ColorSeedOption} ?: emptyList())
+        bundles.addAll(colorBundles?.filterNot { it is ColorSeedOption } ?: emptyList())
         colorBundles = bundles
     }
 
-    private fun buildColorSeeds(wallpaperColors: WallpaperColors, maxColors: Int, source: String,
-                                containsDefault: Boolean, bundles: MutableList<ColorOption>) {
+    private fun buildColorSeeds(
+        wallpaperColors: WallpaperColors,
+        maxColors: Int,
+        source: String,
+        containsDefault: Boolean,
+        bundles: MutableList<ColorOption>
+    ) {
         val seedColors = ColorScheme.getSeedColors(wallpaperColors)
         val defaultSeed = seedColors.first()
         buildBundle(defaultSeed, 0, containsDefault, source, bundles)
@@ -167,19 +180,27 @@
         }
     }
 
-    private fun buildBundle(colorInt: Int, i: Int, isDefault: Boolean, source: String,
-                            bundles: MutableList<ColorOption>) {
+    private fun buildBundle(
+        colorInt: Int,
+        i: Int,
+        isDefault: Boolean,
+        source: String,
+        bundles: MutableList<ColorOption>
+    ) {
         // TODO(b/202145216): Measure time cost in the loop.
         for (style in styleList) {
             val builder = ColorSeedOption.Builder()
             val lightColorScheme = ColorScheme(colorInt, /* darkTheme= */ false, style)
             val darkColorScheme = ColorScheme(colorInt, /* darkTheme= */ true, style)
-            builder.setLightColors(lightColorScheme.getLightColorPreview())
+            builder
+                .setLightColors(lightColorScheme.getLightColorPreview())
                 .setDarkColors(darkColorScheme.getDarkColorPreview())
-                .addOverlayPackage(OVERLAY_CATEGORY_SYSTEM_PALETTE,
+                .addOverlayPackage(
+                    OVERLAY_CATEGORY_SYSTEM_PALETTE,
                     if (isDefault) "" else toColorString(colorInt)
                 )
-                .addOverlayPackage(OVERLAY_CATEGORY_COLOR,
+                .addOverlayPackage(
+                    OVERLAY_CATEGORY_COLOR,
                     if (isDefault) "" else toColorString(colorInt)
                 )
                 .setSource(source)
@@ -194,88 +215,87 @@
     }
 
     /**
-     * Returns the colors for the light theme version of the preview of a ColorScheme
-     * based on this order:
-     * |-------|
-     * | 0 | 1 |
-     * |---+---|
-     * | 2 | 3 |
-     * |-------|
+     * Returns the colors for the light theme version of the preview of a ColorScheme based on this
+     * order: |-------| | 0 | 1 | |---+---| | 2 | 3 | |-------|
      */
     @ColorInt
     private fun ColorScheme.getLightColorPreview(): IntArray {
-        return intArrayOf(setAlphaComponent(this.accent1[2], ALPHA_MASK),
-                setAlphaComponent(this.accent1[2], ALPHA_MASK),
-                ColorStateList.valueOf(this.accent3[6]).withLStar(85f).colors[0],
-                setAlphaComponent(this.accent1[6], ALPHA_MASK))
+        return intArrayOf(
+            setAlphaComponent(this.accent1[2], ALPHA_MASK),
+            setAlphaComponent(this.accent1[2], ALPHA_MASK),
+            ColorStateList.valueOf(this.accent3[6]).withLStar(85f).colors[0],
+            setAlphaComponent(this.accent1[6], ALPHA_MASK)
+        )
     }
 
     /**
-     * Returns the color for the dark theme version of the preview of a ColorScheme
-     * based on this order:
-     * |-------|
-     * | 0 | 1 |
-     * |---+---|
-     * | 2 | 3 |
-     * |-------|
+     * Returns the color for the dark theme version of the preview of a ColorScheme based on this
+     * order: |-------| | 0 | 1 | |---+---| | 2 | 3 | |-------|
      */
     @ColorInt
     private fun ColorScheme.getDarkColorPreview(): IntArray {
-        return intArrayOf(setAlphaComponent(this.accent1[2], ALPHA_MASK),
-                setAlphaComponent(this.accent1[2], ALPHA_MASK),
-                ColorStateList.valueOf(this.accent3[6]).withLStar(85f).colors[0],
-                setAlphaComponent(this.accent1[6], ALPHA_MASK))
+        return intArrayOf(
+            setAlphaComponent(this.accent1[2], ALPHA_MASK),
+            setAlphaComponent(this.accent1[2], ALPHA_MASK),
+            ColorStateList.valueOf(this.accent3[6]).withLStar(85f).colors[0],
+            setAlphaComponent(this.accent1[6], ALPHA_MASK)
+        )
     }
 
     private fun ColorScheme.getPresetColorPreview(seed: Int): IntArray {
-        return when(this.style) {
+        return when (this.style) {
             Style.FRUIT_SALAD -> intArrayOf(seed, this.accent1[2])
             Style.TONAL_SPOT -> intArrayOf(this.accentColor, this.accentColor)
             else -> intArrayOf(this.accent1[2], this.accent1[2])
         }
     }
 
-    private suspend fun loadPreset() = withContext(Dispatchers.IO) {
-        val extractor = ColorBundlePreviewExtractor(mContext)
-        val bundles: MutableList<ColorOption> = ArrayList()
+    private suspend fun loadPreset() =
+        withContext(Dispatchers.IO) {
+            val extractor = ColorBundlePreviewExtractor(mContext)
+            val bundles: MutableList<ColorOption> = ArrayList()
 
-        val bundleNames = getItemsFromStub(COLOR_BUNDLES_ARRAY_NAME)
-        // Color option index value starts from 1.
-        var index = 1
-        val maxPresetColors = if (themeStyleEnabled) bundleNames.size else MAX_PRESET_COLORS
-        for (bundleName in bundleNames.take(maxPresetColors)) {
-            val builder = ColorBundle.Builder()
-            builder.title = getItemStringFromStub(COLOR_BUNDLE_NAME_PREFIX, bundleName)
-            builder.setIndex(index)
-            val colorFromStub = getItemColorFromStub(COLOR_BUNDLE_MAIN_COLOR_PREFIX, bundleName)
-            extractor.addPrimaryColor(builder, colorFromStub)
-            extractor.addSecondaryColor(builder, colorFromStub)
-            if (themeStyleEnabled) {
-                val styleName = try {
-                    getItemStringFromStub(COLOR_BUNDLE_STYLE_PREFIX, bundleName)
-                } catch (e: Resources.NotFoundException) {
-                    null
-                }
-                extractor.addColorStyle(builder, styleName)
-                val style = try {
-                    if (styleName != null) Style.valueOf(styleName) else Style.TONAL_SPOT
-                } catch (e: IllegalArgumentException) {
-                    Style.TONAL_SPOT
+            val bundleNames = getItemsFromStub(COLOR_BUNDLES_ARRAY_NAME)
+            // Color option index value starts from 1.
+            var index = 1
+            val maxPresetColors = if (themeStyleEnabled) bundleNames.size else MAX_PRESET_COLORS
+            for (bundleName in bundleNames.take(maxPresetColors)) {
+                val builder = ColorBundle.Builder()
+                builder.title = getItemStringFromStub(COLOR_BUNDLE_NAME_PREFIX, bundleName)
+                builder.setIndex(index)
+                val colorFromStub = getItemColorFromStub(COLOR_BUNDLE_MAIN_COLOR_PREFIX, bundleName)
+                extractor.addPrimaryColor(builder, colorFromStub)
+                extractor.addSecondaryColor(builder, colorFromStub)
+                if (themeStyleEnabled) {
+                    val styleName =
+                        try {
+                            getItemStringFromStub(COLOR_BUNDLE_STYLE_PREFIX, bundleName)
+                        } catch (e: Resources.NotFoundException) {
+                            null
+                        }
+                    extractor.addColorStyle(builder, styleName)
+                    val style =
+                        try {
+                            if (styleName != null) Style.valueOf(styleName) else Style.TONAL_SPOT
+                        } catch (e: IllegalArgumentException) {
+                            Style.TONAL_SPOT
+                        }
+
+                    val darkColors =
+                        ColorScheme(colorFromStub, true, style).getPresetColorPreview(colorFromStub)
+                    val lightColors =
+                        ColorScheme(colorFromStub, false, style)
+                            .getPresetColorPreview(colorFromStub)
+                    builder.setColorPrimaryDark(darkColors[0]).setColorSecondaryDark(darkColors[1])
+                    builder
+                        .setColorPrimaryLight(lightColors[0])
+                        .setColorSecondaryLight(lightColors[1])
                 }
 
-                val darkColors = ColorScheme(colorFromStub, true, style)
-                        .getPresetColorPreview(colorFromStub)
-                val lightColors = ColorScheme(colorFromStub, false, style)
-                        .getPresetColorPreview(colorFromStub)
-                builder.setColorPrimaryDark(darkColors[0]).setColorSecondaryDark(darkColors[1])
-                builder.setColorPrimaryLight(lightColors[0]).setColorSecondaryLight(lightColors[1])
+                bundles.add(builder.build(mContext))
+                index++
             }
 
-            extractor.addAndroidIconOverlay(builder)
-            bundles.add(builder.build(mContext))
-            index++
+            colorBundles = bundles
         }
-
-        colorBundles = bundles
-    }
 }
diff --git a/src/com/android/customization/model/color/ColorUtils.kt b/src/com/android/customization/model/color/ColorUtils.kt
index f07ff31..9d925e1 100644
--- a/src/com/android/customization/model/color/ColorUtils.kt
+++ b/src/com/android/customization/model/color/ColorUtils.kt
@@ -22,18 +22,14 @@
 import android.util.Log
 import androidx.annotation.ColorInt
 
-/**
- * Utility to wrap Monet's color extraction
- */
+/** Utility to wrap Monet's color extraction */
 object ColorUtils {
     private const val TAG = "ColorUtils"
     private const val MONET_FLAG = "flag_monet"
     private var sSysuiRes: Resources? = null
     private var sFlagId = 0
 
-    /**
-     * Returns true if color extraction is enabled in systemui.
-     */
+    /** Returns true if color extraction is enabled in systemui. */
     @JvmStatic
     fun isMonetEnabled(context: Context): Boolean {
         var monetEnabled = SystemProperties.getBoolean("persist.systemui.flag_monet", false)
@@ -41,8 +37,11 @@
             if (sSysuiRes == null) {
                 try {
                     val pm = context.packageManager
-                    val sysUIInfo = pm.getApplicationInfo("com.android.systemui",
-                            PackageManager.GET_META_DATA or PackageManager.MATCH_SYSTEM_ONLY)
+                    val sysUIInfo =
+                        pm.getApplicationInfo(
+                            "com.android.systemui",
+                            PackageManager.GET_META_DATA or PackageManager.MATCH_SYSTEM_ONLY
+                        )
                     if (sysUIInfo != null) {
                         sSysuiRes = pm.getResourcesForApplication(sysUIInfo)
                     }
@@ -51,8 +50,9 @@
                 }
             }
             if (sFlagId == 0) {
-                sFlagId = if (sSysuiRes == null) 0 else sSysuiRes!!.getIdentifier(
-                        MONET_FLAG, "bool", "com.android.systemui")
+                sFlagId =
+                    if (sSysuiRes == null) 0
+                    else sSysuiRes!!.getIdentifier(MONET_FLAG, "bool", "com.android.systemui")
             }
             if (sFlagId > 0) {
                 monetEnabled = sSysuiRes!!.getBoolean(sFlagId)
@@ -65,4 +65,4 @@
     fun toColorString(@ColorInt color: Int): String {
         return String.format("%06X", 0xFFFFFF and color)
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/customization/module/SysUiStatsLogger.kt b/src/com/android/customization/module/SysUiStatsLogger.kt
index eb3bcc0..9887b52 100644
--- a/src/com/android/customization/module/SysUiStatsLogger.kt
+++ b/src/com/android/customization/module/SysUiStatsLogger.kt
@@ -19,9 +19,7 @@
 import com.android.systemui.shared.system.SysUiStatsLog
 import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UI_CHANGED
 
-/**
- * The builder for [SysUiStatsLog].
- */
+/** The builder for [SysUiStatsLog]. */
 class SysUiStatsLogger {
 
     private var atom = STYLE_UI_CHANGED
@@ -46,67 +44,73 @@
     private var appLaunchCount = 0
     private var colorVariant = 0
 
-    fun setAction(action: Int) =
-        apply { this.action = action }
+    fun setAction(action: Int) = apply { this.action = action }
 
-    fun setColorPackageHash(color_package_hash: Int) =
-        apply { this.colorPackageHash = color_package_hash }
+    fun setColorPackageHash(color_package_hash: Int) = apply {
+        this.colorPackageHash = color_package_hash
+    }
 
-    fun setFontPackageHash(font_package_hash: Int) =
-        apply { this.fontPackageHash = font_package_hash }
+    fun setFontPackageHash(font_package_hash: Int) = apply {
+        this.fontPackageHash = font_package_hash
+    }
 
-    fun setShapePackageHash(shape_package_hash: Int) =
-        apply { this.shapePackageHash = shape_package_hash }
+    fun setShapePackageHash(shape_package_hash: Int) = apply {
+        this.shapePackageHash = shape_package_hash
+    }
 
-    fun setClockPackageHash(clock_package_hash: Int) =
-        apply { this.clockPackageHash = clock_package_hash }
+    fun setClockPackageHash(clock_package_hash: Int) = apply {
+        this.clockPackageHash = clock_package_hash
+    }
 
-    fun setLauncherGrid(launcher_grid: Int) =
-        apply { this.launcherGrid = launcher_grid }
+    fun setLauncherGrid(launcher_grid: Int) = apply { this.launcherGrid = launcher_grid }
 
-    fun setWallpaperCategoryHash(wallpaper_category_hash: Int) =
-        apply { this.wallpaperCategoryHash = wallpaper_category_hash }
+    fun setWallpaperCategoryHash(wallpaper_category_hash: Int) = apply {
+        this.wallpaperCategoryHash = wallpaper_category_hash
+    }
 
-    fun setWallpaperIdHash(wallpaper_id_hash: Int) =
-        apply { this.wallpaperIdHash = wallpaper_id_hash }
+    fun setWallpaperIdHash(wallpaper_id_hash: Int) = apply {
+        this.wallpaperIdHash = wallpaper_id_hash
+    }
 
-    fun setColorPreference(color_preference: Int) =
-        apply { this.colorPreference = color_preference }
+    fun setColorPreference(color_preference: Int) = apply {
+        this.colorPreference = color_preference
+    }
 
-    fun setLocationPreference(location_preference: Int) =
-        apply { this.locationPreference = location_preference }
+    fun setLocationPreference(location_preference: Int) = apply {
+        this.locationPreference = location_preference
+    }
 
-    fun setDatePreference(date_preference: Int) =
-        apply { this.datePreference = date_preference }
+    fun setDatePreference(date_preference: Int) = apply { this.datePreference = date_preference }
 
-    fun setLaunchedPreference(launched_preference: Int) =
-        apply { this.launchedPreference = launched_preference }
+    fun setLaunchedPreference(launched_preference: Int) = apply {
+        this.launchedPreference = launched_preference
+    }
 
-    fun setEffectPreference(effect_preference: Int) =
-        apply { this.effectPreference = effect_preference }
+    fun setEffectPreference(effect_preference: Int) = apply {
+        this.effectPreference = effect_preference
+    }
 
-    fun setEffectIdHash(effect_id_hash: Int) =
-        apply { this.effectIdHash = effect_id_hash }
+    fun setEffectIdHash(effect_id_hash: Int) = apply { this.effectIdHash = effect_id_hash }
 
-    fun setLockWallpaperCategoryHash(lock_wallpaper_category_hash: Int) =
-        apply { this.lockWallpaperCategoryHash = lock_wallpaper_category_hash }
+    fun setLockWallpaperCategoryHash(lock_wallpaper_category_hash: Int) = apply {
+        this.lockWallpaperCategoryHash = lock_wallpaper_category_hash
+    }
 
-    fun setLockWallpaperIdHash(lock_wallpaper_id_hash: Int) =
-        apply { this.lockWallpaperIdHash = lock_wallpaper_id_hash }
+    fun setLockWallpaperIdHash(lock_wallpaper_id_hash: Int) = apply {
+        this.lockWallpaperIdHash = lock_wallpaper_id_hash
+    }
 
-    fun setFirstLaunchDateSinceSetup(first_launch_date_since_setup: Int) =
-        apply { this.firstLaunchDateSinceSetup = first_launch_date_since_setup }
+    fun setFirstLaunchDateSinceSetup(first_launch_date_since_setup: Int) = apply {
+        this.firstLaunchDateSinceSetup = first_launch_date_since_setup
+    }
 
-    fun setFirstWallpaperApplyDateSinceSetup(first_wallpaper_apply_date_since_setup: Int) =
-        apply {
-            this.firstWallpaperApplyDateSinceSetup = first_wallpaper_apply_date_since_setup
-        }
+    fun setFirstWallpaperApplyDateSinceSetup(first_wallpaper_apply_date_since_setup: Int) = apply {
+        this.firstWallpaperApplyDateSinceSetup = first_wallpaper_apply_date_since_setup
+    }
 
-    fun setAppLaunchCount(app_launch_count: Int) =
-        apply { this.appLaunchCount = app_launch_count }
+    fun setAppLaunchCount(app_launch_count: Int) = apply { this.appLaunchCount = app_launch_count }
 
-    fun setColorVariant(color_variant: Int) =
-        apply { this.colorVariant = color_variant }
+    fun setColorVariant(color_variant: Int) = apply { this.colorVariant = color_variant }
 
     fun log() {
         SysUiStatsLog.write(
@@ -133,4 +137,4 @@
             colorVariant
         )
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/customization/module/DefaultCustomizationInjector.java b/src/com/android/customization/module/ThemePickerInjector.java
similarity index 62%
rename from src/com/android/customization/module/DefaultCustomizationInjector.java
rename to src/com/android/customization/module/ThemePickerInjector.java
index 220c406..ef2b60a 100644
--- a/src/com/android/customization/module/DefaultCustomizationInjector.java
+++ b/src/com/android/customization/module/ThemePickerInjector.java
@@ -15,9 +15,16 @@
  */
 package com.android.customization.module;
 
+import static com.android.wallpaper.picker.PreviewFragment.ARG_FULL_SCREEN;
+import static com.android.wallpaper.picker.PreviewFragment.ARG_PREVIEW_MODE;
+import static com.android.wallpaper.picker.PreviewFragment.ARG_TESTING_MODE_ENABLED;
+import static com.android.wallpaper.picker.PreviewFragment.ARG_VIEW_AS_HOME;
+import static com.android.wallpaper.picker.PreviewFragment.ARG_WALLPAPER;
+
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
+import android.os.Bundle;
 
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentActivity;
@@ -25,80 +32,31 @@
 import com.android.customization.model.theme.OverlayManagerCompat;
 import com.android.customization.model.theme.ThemeBundleProvider;
 import com.android.customization.model.theme.ThemeManager;
-import com.android.wallpaper.model.CategoryProvider;
+import com.android.wallpaper.model.LiveWallpaperInfo;
 import com.android.wallpaper.model.WallpaperInfo;
-import com.android.wallpaper.module.BaseWallpaperInjector;
 import com.android.wallpaper.module.CustomizationSections;
-import com.android.wallpaper.module.DefaultCategoryProvider;
-import com.android.wallpaper.module.LoggingOptInStatusProvider;
+import com.android.wallpaper.module.WallpaperPicker2Injector;
 import com.android.wallpaper.module.WallpaperPreferences;
-import com.android.wallpaper.module.WallpaperRotationRefresher;
-import com.android.wallpaper.monitor.PerformanceMonitor;
 import com.android.wallpaper.picker.CustomizationPickerActivity;
+import com.android.wallpaper.picker.ImagePreviewFragment;
+import com.android.wallpaper.picker.LivePreviewFragment;
 import com.android.wallpaper.picker.PreviewFragment;
 
-public class DefaultCustomizationInjector extends BaseWallpaperInjector
+/**
+ * A concrete, real implementation of the dependency provider.
+ */
+public class ThemePickerInjector extends WallpaperPicker2Injector
         implements CustomizationInjector {
-    private CategoryProvider mCategoryProvider;
-    private ThemesUserEventLogger mUserEventLogger;
-    private WallpaperRotationRefresher mWallpaperRotationRefresher;
-    private PerformanceMonitor mPerformanceMonitor;
-    private WallpaperPreferences mPrefs;
     private CustomizationSections mCustomizationSections;
+    private ThemesUserEventLogger mUserEventLogger;
+    private WallpaperPreferences mPrefs;
 
     @Override
-    public synchronized WallpaperPreferences getPreferences(Context context) {
-        if (mPrefs == null) {
-            mPrefs = new DefaultCustomizationPreferences(context.getApplicationContext());
+    public CustomizationSections getCustomizationSections() {
+        if (mCustomizationSections == null) {
+            mCustomizationSections = new DefaultCustomizationSections();
         }
-        return mPrefs;
-    }
-
-    @Override
-    public CustomizationPreferences getCustomizationPreferences(Context context) {
-        return (CustomizationPreferences) getPreferences(context);
-    }
-
-    @Override
-    public synchronized CategoryProvider getCategoryProvider(Context context) {
-        if (mCategoryProvider == null) {
-            mCategoryProvider = new DefaultCategoryProvider(context.getApplicationContext());
-        }
-        return mCategoryProvider;
-    }
-
-    @Override
-    public synchronized ThemesUserEventLogger getUserEventLogger(Context context) {
-        if (mUserEventLogger == null) {
-            mUserEventLogger = new StatsLogUserEventLogger(context);
-        }
-        return mUserEventLogger;
-    }
-
-    @Override
-    public synchronized WallpaperRotationRefresher getWallpaperRotationRefresher() {
-        if (mWallpaperRotationRefresher == null) {
-            mWallpaperRotationRefresher = new WallpaperRotationRefresher() {
-                @Override
-                public void refreshWallpaper(Context context, Listener listener) {
-                    // Not implemented
-                    listener.onError();
-                }
-            };
-        }
-        return mWallpaperRotationRefresher;
-    }
-
-    @Override
-    public Fragment getPreviewFragment(
-            Context context,
-            WallpaperInfo wallpaperInfo,
-            int mode,
-            boolean viewAsHome,
-            boolean viewFullScreen,
-            boolean testingModeEnabled) {
-        return PreviewFragment.newInstance(wallpaperInfo, mode, viewAsHome, viewFullScreen,
-                testingModeEnabled);
+        return mCustomizationSections;
     }
 
     @Override
@@ -116,21 +74,47 @@
     }
 
     @Override
-    public synchronized PerformanceMonitor getPerformanceMonitor() {
-        if (mPerformanceMonitor == null) {
-            mPerformanceMonitor = new PerformanceMonitor() {
-                @Override
-                public void recordFullResPreviewLoadedMemorySnapshot() {
-                    // No Op
-                }
-            };
-        }
-        return mPerformanceMonitor;
+    public Fragment getPreviewFragment(
+            Context context,
+            WallpaperInfo wallpaperInfo,
+            int mode,
+            boolean viewAsHome,
+            boolean viewFullScreen,
+            boolean testingModeEnabled) {
+        Bundle args = new Bundle();
+        args.putParcelable(ARG_WALLPAPER, wallpaperInfo);
+        args.putInt(ARG_PREVIEW_MODE, mode);
+        args.putBoolean(ARG_VIEW_AS_HOME, viewAsHome);
+        args.putBoolean(ARG_FULL_SCREEN, viewFullScreen);
+        args.putBoolean(ARG_TESTING_MODE_ENABLED, testingModeEnabled);
+        PreviewFragment fragment = wallpaperInfo instanceof LiveWallpaperInfo
+                ? new LivePreviewFragment() : new ImagePreviewFragment();
+        fragment.setArguments(args);
+        return fragment;
     }
 
     @Override
-    public synchronized LoggingOptInStatusProvider getLoggingOptInStatusProvider(Context context) {
-        return null;
+    public synchronized ThemesUserEventLogger getUserEventLogger(Context context) {
+        if (mUserEventLogger == null) {
+            mUserEventLogger = new StatsLogUserEventLogger(context);
+        }
+        return mUserEventLogger;
+    }
+
+    @Override
+    public synchronized WallpaperPreferences getPreferences(Context context) {
+        if (mPrefs == null) {
+            mPrefs = new DefaultCustomizationPreferences(context.getApplicationContext());
+        }
+        return mPrefs;
+    }
+
+    //
+    // Functions from {@link CustomizationInjector}
+    //
+    @Override
+    public CustomizationPreferences getCustomizationPreferences(Context context) {
+        return (CustomizationPreferences) getPreferences(context);
     }
 
     @Override
@@ -138,12 +122,4 @@
             OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger logger) {
         return new ThemeManager(provider, activity, overlayManagerCompat, logger);
     }
-
-    @Override
-    public CustomizationSections getCustomizationSections() {
-        if (mCustomizationSections == null) {
-            mCustomizationSections = new DefaultCustomizationSections();
-        }
-        return mCustomizationSections;
-    }
 }
diff --git a/src/com/android/customization/picker/CustomizationPickerApplication.java b/src/com/android/customization/picker/CustomizationPickerApplication.java
index 79d075a..178cfbf 100644
--- a/src/com/android/customization/picker/CustomizationPickerApplication.java
+++ b/src/com/android/customization/picker/CustomizationPickerApplication.java
@@ -17,7 +17,7 @@
 
 import android.app.Application;
 
-import com.android.customization.module.DefaultCustomizationInjector;
+import com.android.customization.module.ThemePickerInjector;
 import com.android.wallpaper.module.InjectorProvider;
 
 public class CustomizationPickerApplication extends Application {
@@ -26,6 +26,6 @@
         super.onCreate();
 
         // Initialize the injector.
-        InjectorProvider.setInjector(new DefaultCustomizationInjector());
+        InjectorProvider.setInjector(new ThemePickerInjector());
     }
 }
diff --git a/src/com/android/customization/picker/clock/ClockSectionView.kt b/src/com/android/customization/picker/clock/ClockSectionView.kt
index c043209..fac975a 100644
--- a/src/com/android/customization/picker/clock/ClockSectionView.kt
+++ b/src/com/android/customization/picker/clock/ClockSectionView.kt
@@ -19,5 +19,5 @@
 import android.util.AttributeSet
 import com.android.wallpaper.picker.SectionView
 
-/** The [SectionView] for app clock.  */
-class ClockSectionView(context: Context?, attrs: AttributeSet?) : SectionView(context, attrs)
\ No newline at end of file
+/** The [SectionView] for app clock. */
+class ClockSectionView(context: Context?, attrs: AttributeSet?) : SectionView(context, attrs)
diff --git a/src/com/android/customization/picker/grid/GridFragment.java b/src/com/android/customization/picker/grid/GridFragment.java
index c4029d6..d60ebca 100644
--- a/src/com/android/customization/picker/grid/GridFragment.java
+++ b/src/com/android/customization/picker/grid/GridFragment.java
@@ -160,7 +160,7 @@
                 getActivity(), view.findViewById(R.id.wallpaper_preview_image), wallpaperSurface);
         // Loads current Wallpaper.
         CurrentWallpaperInfoFactory factory = InjectorProvider.getInjector()
-                .getCurrentWallpaperFactory(getContext().getApplicationContext());
+                .getCurrentWallpaperInfoFactory(getContext().getApplicationContext());
         factory.createCurrentWallpaperInfos((homeWallpaper, lockWallpaper, presentationMode) -> {
             mHomeWallpaper = homeWallpaper;
             wallpaperPreviewer.setWallpaper(mHomeWallpaper, /* listener= */ null);
diff --git a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
index 6f20a1a..ea9099f 100644
--- a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
@@ -69,7 +69,7 @@
         mTitle = view.findViewById(R.id.component_options_title);
         mTitle.setText(mTitleResId);
         CurrentWallpaperInfoFactory currentWallpaperFactory = InjectorProvider.getInjector()
-                .getCurrentWallpaperFactory(getActivity().getApplicationContext());
+                .getCurrentWallpaperInfoFactory(getActivity().getApplicationContext());
         CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
         mCustomizationPreferences = injector.getCustomizationPreferences(getContext());
 
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index f5d56ca..3a9a56f 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -115,7 +115,7 @@
         mLoading = view.findViewById(R.id.loading_indicator);
         mError = view.findViewById(R.id.error_section);
         mCurrentWallpaperFactory = InjectorProvider.getInjector()
-                .getCurrentWallpaperFactory(getActivity().getApplicationContext());
+                .getCurrentWallpaperInfoFactory(getActivity().getApplicationContext());
         mOptionsContainer = view.findViewById(R.id.options_container);
 
         mThemeOptionPreviewer = new ThemeOptionPreviewer(
diff --git a/src_override/com/android/wallpaper/module/WallpapersInjector.java b/src_override/com/android/wallpaper/module/WallpapersInjector.java
deleted file mode 100755
index 9f8fe9c..0000000
--- a/src_override/com/android/wallpaper/module/WallpapersInjector.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.wallpaper.module;
-
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-
-import androidx.fragment.app.Fragment;
-
-import com.android.wallpaper.model.CategoryProvider;
-import com.android.wallpaper.model.WallpaperInfo;
-import com.android.wallpaper.monitor.PerformanceMonitor;
-import com.android.wallpaper.picker.CustomizationPickerActivity;
-import com.android.wallpaper.picker.ImagePreviewFragment;
-
-/**
- * A concrete, real implementation of the dependency provider.
- */
-public class WallpapersInjector extends BaseWallpaperInjector {
-    private CategoryProvider mCategoryProvider;
-    private UserEventLogger mUserEventLogger;
-    private WallpaperRotationRefresher mWallpaperRotationRefresher;
-    private PerformanceMonitor mPerformanceMonitor;
-
-    @Override
-    public synchronized CategoryProvider getCategoryProvider(Context context) {
-        if (mCategoryProvider == null) {
-            mCategoryProvider = new DefaultCategoryProvider(context.getApplicationContext());
-        }
-        return mCategoryProvider;
-    }
-
-    @Override
-    public synchronized UserEventLogger getUserEventLogger(Context context) {
-        if (mUserEventLogger == null) {
-            mUserEventLogger = new NoOpUserEventLogger();
-        }
-        return mUserEventLogger;
-    }
-
-    @Override
-    public synchronized WallpaperRotationRefresher getWallpaperRotationRefresher() {
-        if (mWallpaperRotationRefresher == null) {
-            mWallpaperRotationRefresher = new WallpaperRotationRefresher() {
-                @Override
-                public void refreshWallpaper(Context context, Listener listener) {
-                    // Not implemented
-                    listener.onError();
-                }
-            };
-        }
-        return mWallpaperRotationRefresher;
-    }
-
-    @Override
-    public Fragment getPreviewFragment(
-            Context context,
-            WallpaperInfo wallpaperInfo,
-            int mode,
-            boolean viewAsHome,
-            boolean viewFullScreen,
-            boolean testingModeEnabled) {
-        return ImagePreviewFragment.newInstance(wallpaperInfo, mode, viewAsHome, viewFullScreen,
-                testingModeEnabled);
-    }
-
-    @Override
-    public Intent getDeepLinkRedirectIntent(Context context, Uri uri) {
-        Intent intent = new Intent();
-        intent.setClass(context, CustomizationPickerActivity.class);
-        intent.setData(uri);
-        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
-        return intent;
-    }
-
-    @Override
-    public synchronized PerformanceMonitor getPerformanceMonitor() {
-        if (mPerformanceMonitor == null) {
-            mPerformanceMonitor = new PerformanceMonitor() {
-                @Override
-                public void recordFullResPreviewLoadedMemorySnapshot() {
-                    // No Op
-                }
-            };
-        }
-        return mPerformanceMonitor;
-    }
-
-    @Override
-    public synchronized LoggingOptInStatusProvider getLoggingOptInStatusProvider(Context context) {
-        return null;
-    }
-
-    @Override
-    public String getDownloadableIntentAction() {
-        return null;
-    }
-}