Merging from ub-launcher3-master @ build 6408463 am: 8a3847e752

Change-Id: I98819cc2b99d43a46e8e12e61c3f6364bb0fc708
diff --git a/res/layout-land/fragment_theme_picker.xml b/res/layout-land/fragment_theme_picker.xml
index f2083f3..dc30232 100644
--- a/res/layout-land/fragment_theme_picker.xml
+++ b/res/layout-land/fragment_theme_picker.xml
@@ -55,30 +55,14 @@
                     android:layout_height="0dp"
                     android:layout_weight="1"/>
 
-                <RelativeLayout
-                    android:layout_width="match_parent"
+                <Button
+                    android:id="@+id/apply_button"
+                    style="@style/ActionPrimaryButton"
+                    android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:background="@null"
-                    android:paddingHorizontal="10dp">
-                    <CheckBox
-                        android:id="@+id/use_my_wallpaper"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentStart="true"
-                        android:layout_centerVertical="true"
-                        android:layout_toStartOf="@+id/apply_button"
-                        android:ellipsize="end"
-                        android:paddingLeft="4dp"
-                        android:minHeight="@dimen/min_taptarget_height"
-                        android:text="@string/keep_my_wallpaper"/>
-                    <Button
-                        android:id="@+id/apply_button"
-                        style="@style/ActionPrimaryButton"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentEnd="true"
-                        android:text="@string/apply_theme_btn"/>
-                </RelativeLayout>
+                    android:layout_gravity="end"
+                    android:paddingHorizontal="10dp"
+                    android:text="@string/apply_theme_btn"/>
             </LinearLayout>
         </LinearLayout>
 
diff --git a/res/layout/fragment_grid_picker.xml b/res/layout/fragment_grid_picker.xml
index f664568..ce571c9 100644
--- a/res/layout/fragment_grid_picker.xml
+++ b/res/layout/fragment_grid_picker.xml
@@ -64,24 +64,11 @@
                 android:id="@+id/placeholder"
                 android:layout_width="match_parent"
                 android:layout_height="@dimen/min_taptarget_height"
-                app:layout_constraintBottom_toTopOf="@id/apply_button"
+                app:layout_constraintBottom_toBottomOf="parent"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toBottomOf="@id/options_container"
                 app:layout_constraintVertical_bias="1.0"/>
 
-            <Button
-                android:id="@+id/apply_button"
-                style="@style/ActionPrimaryButton"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="end"
-                android:layout_marginEnd="10dp"
-                android:layout_marginVertical="10dp"
-                android:layout_weight="1"
-                android:text="@string/apply_theme_btn"
-                app:layout_constraintBottom_toBottomOf="parent"
-                app:layout_constraintEnd_toEndOf="parent"/>
-
         </androidx.constraintlayout.widget.ConstraintLayout>
 
         <androidx.core.widget.ContentLoadingProgressBar
diff --git a/res/layout/fragment_theme_picker.xml b/res/layout/fragment_theme_picker.xml
index 1de5a3c..d15d93f 100644
--- a/res/layout/fragment_theme_picker.xml
+++ b/res/layout/fragment_theme_picker.xml
@@ -53,29 +53,11 @@
                 android:layout_gravity="bottom|center_horizontal"
                 android:layout_marginTop="10dp"
                 android:layout_weight="1"
-                app:layout_constraintBottom_toTopOf="@id/use_my_wallpaper"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toBottomOf="@+id/theme_preview_pager"
                 app:layout_constraintVertical_bias="1.0"/>
 
-            <CheckBox
-                android:id="@+id/use_my_wallpaper"
-                android:layout_width="wrap_content"
-                android:layout_height="@dimen/min_taptarget_height"
-                android:layout_marginStart="10dp"
-                android:ellipsize="end"
-                android:gravity="start|center_vertical"
-                android:paddingLeft="4dp"
-                android:text="@string/keep_my_wallpaper"
-                app:layout_constraintBottom_toTopOf="@id/apply_button"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintHeight_min="@dimen/min_taptarget_height"
-                app:layout_constraintHorizontal_bias="0.0"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintTop_toBottomOf="@id/options_container"
-                app:layout_constraintVertical_bias="1.0"/>
-
             <Button
                 android:id="@+id/apply_button"
                 style="@style/ActionPrimaryButton"
diff --git a/res/layout/fragment_theme_scalable_picker.xml b/res/layout/fragment_theme_scalable_picker.xml
index e03df3e..ae147c2 100644
--- a/res/layout/fragment_theme_scalable_picker.xml
+++ b/res/layout/fragment_theme_scalable_picker.xml
@@ -55,29 +55,11 @@
                 android:layout_gravity="bottom|center_horizontal"
                 android:layout_marginTop="10dp"
                 android:layout_weight="1"
-                app:layout_constraintBottom_toTopOf="@id/use_my_wallpaper"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toTopOf="parent"
                 app:layout_constraintVertical_bias="1.0" />
 
-            <CheckBox
-                android:id="@+id/use_my_wallpaper"
-                android:layout_width="wrap_content"
-                android:layout_height="@dimen/min_taptarget_height"
-                android:layout_marginStart="10dp"
-                android:ellipsize="end"
-                android:gravity="start|center_vertical"
-                android:paddingLeft="4dp"
-                android:text="@string/keep_my_wallpaper"
-                app:layout_constraintBottom_toTopOf="@id/apply_button"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintHeight_min="@dimen/min_taptarget_height"
-                app:layout_constraintHorizontal_bias="0.0"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintTop_toBottomOf="@id/options_container"
-                app:layout_constraintVertical_bias="1.0" />
-
             <Button
                 android:id="@+id/apply_button"
                 style="@style/ActionPrimaryButton"
diff --git a/res/layout/preview_card_wallpaper_content.xml b/res/layout/preview_card_wallpaper_content.xml
deleted file mode 100644
index 0b43c2f..0000000
--- a/res/layout/preview_card_wallpaper_content.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2019 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.
--->
-<FrameLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:id="@+id/preview_static_image"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:layout_gravity="bottom"
-    tools:showIn="@layout/theme_preview_card">
-    <TextView
-        style="@style/CardTitleTextAppearance"
-        android:id="@+id/wallpaper_description"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:gravity="center_horizontal|bottom"/>
-</FrameLayout>
\ No newline at end of file
diff --git a/robolectric_tests/src/com/android/customization/model/theme/ThemeManagerTest.java b/robolectric_tests/src/com/android/customization/model/theme/ThemeManagerTest.java
index 6f1f95e..cfb8a33 100644
--- a/robolectric_tests/src/com/android/customization/model/theme/ThemeManagerTest.java
+++ b/robolectric_tests/src/com/android/customization/model/theme/ThemeManagerTest.java
@@ -40,12 +40,11 @@
 import androidx.annotation.Nullable;
 import androidx.fragment.app.FragmentActivity;
 
-import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
 import com.android.customization.model.CustomizationManager.Callback;
+import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
 import com.android.customization.model.theme.custom.CustomTheme;
 import com.android.customization.module.ThemesUserEventLogger;
 import com.android.customization.testutils.OverlayManagerMocks;
-import com.android.wallpaper.module.WallpaperSetter;
 
 import org.json.JSONObject;
 import org.junit.After;
@@ -61,7 +60,6 @@
 public class ThemeManagerTest {
 
     @Mock OverlayManagerCompat mMockOm;
-    @Mock WallpaperSetter mMockWallpaperSetter;
     @Mock ThemesUserEventLogger mThemesUserEventLogger;
     @Mock ThemeBundleProvider mThemeBundleProvider;
     private OverlayManagerMocks mMockOmHelper;
@@ -75,7 +73,7 @@
         mActivity = spy(activity);
         mMockOmHelper = new OverlayManagerMocks();
         mMockOmHelper.setUpMock(mMockOm);
-        mThemeManager = new ThemeManager(mThemeBundleProvider, activity, mMockWallpaperSetter,
+        mThemeManager = new ThemeManager(mThemeBundleProvider, activity,
                 mMockOm, mThemesUserEventLogger);
     }
 
diff --git a/src/com/android/customization/model/grid/GridOptionsManager.java b/src/com/android/customization/model/grid/GridOptionsManager.java
index a334f5e..b0e0787 100644
--- a/src/com/android/customization/model/grid/GridOptionsManager.java
+++ b/src/com/android/customization/model/grid/GridOptionsManager.java
@@ -67,8 +67,8 @@
     }
 
     /** Call through content provider API to render preview */
-    public void renderPreview(Bundle bundle, String gridName) {
-        mProvider.renderPreview(gridName, bundle);
+    public Bundle renderPreview(Bundle bundle, String gridName) {
+        return mProvider.renderPreview(gridName, bundle);
     }
 
     private static class FetchTask extends AsyncTask<Void, Void, Pair<List<GridOption>, String>> {
diff --git a/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java b/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
index 7d1d5cd..70a8fc8 100644
--- a/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
+++ b/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
@@ -118,9 +118,9 @@
      * @param bundle    surface view request bundle generated from
      *                  {@link SurfaceViewRequestUtils#createSurfaceBundle(SurfaceView)}.
      */
-    void renderPreview(String name, Bundle bundle) {
+    Bundle renderPreview(String name, Bundle bundle) {
         bundle.putString("name", name);
-        mPreviewUtils.renderPreview(bundle);
+        return mPreviewUtils.renderPreview(bundle);
     }
 
     int applyGrid(String name) {
diff --git a/src/com/android/customization/model/theme/DefaultThemeProvider.java b/src/com/android/customization/model/theme/DefaultThemeProvider.java
index ce12d35..7c99f9c 100644
--- a/src/com/android/customization/model/theme/DefaultThemeProvider.java
+++ b/src/com/android/customization/model/theme/DefaultThemeProvider.java
@@ -15,8 +15,6 @@
  */
 package com.android.customization.model.theme;
 
-import static android.content.res.Resources.ID_NULL;
-
 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;
@@ -29,14 +27,9 @@
 import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SHAPE;
 import static com.android.customization.model.ResourceConstants.SYSUI_PACKAGE;
 
-import android.content.ComponentName;
 import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ResolveInfo;
 import android.content.res.Resources.NotFoundException;
-import android.service.wallpaper.WallpaperService;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -49,7 +42,6 @@
 import com.android.customization.module.CustomizationPreferences;
 import com.android.wallpaper.R;
 import com.android.wallpaper.asset.ResourceAsset;
-import com.android.wallpaper.model.LiveWallpaperInfo;
 
 import com.bumptech.glide.request.RequestOptions;
 import com.google.android.apps.wallpaper.asset.ThemeBundleThumbAsset;
@@ -57,9 +49,7 @@
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
-import org.xmlpull.v1.XmlPullParserException;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -83,12 +73,6 @@
     private static final String ICON_THEMEPICKER_PREFIX = "theme_overlay_icon_themepicker_";
     private static final String ICON_SETTINGS_PREFIX = "theme_overlay_icon_settings_";
     private static final String ICON_SYSUI_PREFIX = "theme_overlay_icon_sysui_";
-    private static final String WALLPAPER_PREFIX = "theme_wallpaper_";
-    private static final String WALLPAPER_TITLE_PREFIX = "theme_wallpaper_title_";
-    private static final String WALLPAPER_ATTRIBUTION_PREFIX = "theme_wallpaper_attribution_";
-    private static final String WALLPAPER_THUMB_PREFIX = "theme_wallpaper_thumbnail_";
-    private static final String WALLPAPER_ACTION_PREFIX = "theme_wallpaper_action_";
-    private static final String WALLPAPER_OPTIONS_PREFIX = "theme_wallpaper_options_";
 
     private static final String DEFAULT_THEME_NAME= "default";
     private static final String THEME_TITLE_FIELD = "_theme_title";
@@ -172,8 +156,6 @@
 
                 mOverlayProvider.addNoPreviewIconOverlay(builder, iconSettingsOverlayPackage);
 
-                addWallpaper(themeName, builder);
-
                 mThemes.add(builder.build(mContext));
             } catch (NameNotFoundException | NotFoundException e) {
                 Log.w(TAG, String.format("Couldn't load part of theme %s, will skip it", themeName),
@@ -184,70 +166,6 @@
         addCustomThemes();
     }
 
-    private void addWallpaper(String themeName, Builder builder) {
-        try {
-            String wallpaperResName = WALLPAPER_PREFIX + themeName;
-            int wallpaperResId = mStubApkResources.getIdentifier(wallpaperResName,
-                    "drawable", mStubPackageName);
-            // Check in case the theme has a separate thumbnail for the wallpaper
-            String wallpaperThumbnailResName = WALLPAPER_THUMB_PREFIX + themeName;
-            int wallpaperThumbnailResId = mStubApkResources.getIdentifier(wallpaperThumbnailResName,
-                    "drawable", mStubPackageName);
-            if (wallpaperResId != ID_NULL) {
-                builder.setWallpaperInfo(mStubPackageName, wallpaperResName,
-                        themeName, wallpaperResId,
-                        mStubApkResources.getIdentifier(WALLPAPER_TITLE_PREFIX + themeName,
-                                "string", mStubPackageName),
-                        mStubApkResources.getIdentifier(
-                                WALLPAPER_ATTRIBUTION_PREFIX + themeName, "string",
-                                mStubPackageName),
-                        mStubApkResources.getIdentifier(WALLPAPER_ACTION_PREFIX + themeName,
-                                "string", mStubPackageName))
-                        .setWallpaperAsset(wallpaperThumbnailResId != ID_NULL ?
-                                getThumbAsset(WALLPAPER_THUMB_PREFIX, themeName)
-                                : getDrawableResourceAsset(WALLPAPER_PREFIX, themeName));
-            } else {
-                // Try to see if it's a live wallpaper reference
-                wallpaperResId = mStubApkResources.getIdentifier(wallpaperResName,
-                        "string", mStubPackageName);
-                if (wallpaperResId != ID_NULL) {
-                    String wpComponent = mStubApkResources.getString(wallpaperResId);
-
-                    int wallpaperOptionsResId = mStubApkResources.getIdentifier(
-                            WALLPAPER_OPTIONS_PREFIX + themeName, "string", mStubPackageName);
-                    String wallpaperOptions = wallpaperOptionsResId != ID_NULL
-                            ? mStubApkResources.getString(wallpaperOptionsResId) : null;
-
-                    String[] componentParts = wpComponent.split("/");
-                    Intent liveWpIntent =  new Intent(WallpaperService.SERVICE_INTERFACE);
-                    liveWpIntent.setComponent(
-                            new ComponentName(componentParts[0], componentParts[1]));
-
-                    Context appContext = mContext.getApplicationContext();
-                    PackageManager pm = appContext.getPackageManager();
-                    ResolveInfo resolveInfo =
-                            pm.resolveService(liveWpIntent, PackageManager.GET_META_DATA);
-                    if (resolveInfo != null) {
-                        android.app.WallpaperInfo wallpaperInfo;
-                        try {
-                            wallpaperInfo = new android.app.WallpaperInfo(appContext, resolveInfo);
-                            LiveWallpaperInfo liveInfo = new LiveWallpaperInfo(wallpaperInfo);
-                            builder.setLiveWallpaperInfo(liveInfo).setWallpaperAsset(
-                                    wallpaperThumbnailResId != ID_NULL ?
-                                            getThumbAsset(WALLPAPER_THUMB_PREFIX, themeName)
-                                        : liveInfo.getThumbAsset(mContext))
-                                    .setWallpaperOptions(wallpaperOptions);
-                        } catch (XmlPullParserException | IOException e) {
-                            Log.w(TAG, "Skipping wallpaper " + resolveInfo.serviceInfo, e);
-                        }
-                    }
-                }
-            }
-        } catch (NotFoundException e) {
-            // Nothing to do here, if there's no wallpaper we'll just omit wallpaper
-        }
-    }
-
     /**
      * Default theme requires different treatment: if there are overlay packages specified in the
      * stub apk, we'll use those, otherwise we'll get the System default values. But we cannot skip
@@ -318,8 +236,6 @@
             mOverlayProvider.addSystemDefaultIcons(builder, SYSUI_PACKAGE, ICONS_FOR_PREVIEW);
         }
 
-        addWallpaper(DEFAULT_THEME_NAME, builder);
-
         mThemes.add(builder.build(mContext));
     }
 
diff --git a/src/com/android/customization/model/theme/ThemeBundle.java b/src/com/android/customization/model/theme/ThemeBundle.java
index e83e852..14b2dcd 100644
--- a/src/com/android/customization/model/theme/ThemeBundle.java
+++ b/src/com/android/customization/model/theme/ThemeBundle.java
@@ -31,7 +31,6 @@
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.ShapeDrawable;
 import android.graphics.drawable.shapes.PathShape;
-import android.icu.text.SimpleDateFormat;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
@@ -40,9 +39,7 @@
 
 import androidx.annotation.ColorInt;
 import androidx.annotation.Dimension;
-import androidx.annotation.DrawableRes;
 import androidx.annotation.Nullable;
-import androidx.annotation.StringRes;
 import androidx.core.graphics.PathParser;
 
 import com.android.customization.model.CustomizationManager;
@@ -51,7 +48,6 @@
 import com.android.wallpaper.R;
 import com.android.wallpaper.asset.Asset;
 import com.android.wallpaper.asset.BitmapCachingAsset;
-import com.android.wallpaper.model.LiveWallpaperInfo;
 import com.android.wallpaper.model.WallpaperInfo;
 
 import org.json.JSONException;
@@ -59,12 +55,10 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
@@ -83,20 +77,15 @@
     private final PreviewInfo mPreviewInfo;
     private final boolean mIsDefault;
     protected final Map<String, String> mPackagesByCategory;
-    @Nullable private final WallpaperInfo mWallpaperInfo;
-    @Nullable private final String mWallpaperOptions;
     private WallpaperInfo mOverrideWallpaper;
     private Asset mOverrideWallpaperAsset;
     private CharSequence mContentDescription;
 
     protected ThemeBundle(String title, Map<String, String> overlayPackages,
-            boolean isDefault, @Nullable WallpaperInfo wallpaperInfo,
-            @Nullable String wallpaperOptions, PreviewInfo previewInfo) {
+            boolean isDefault, PreviewInfo previewInfo) {
         mTitle = title;
         mIsDefault = isDefault;
         mPreviewInfo = previewInfo;
-        mWallpaperInfo = wallpaperInfo;
-        mWallpaperOptions = wallpaperOptions;
         mPackagesByCategory = Collections.unmodifiableMap(overlayPackages);
     }
 
@@ -169,16 +158,6 @@
         mOverrideWallpaperAsset = null;
     }
 
-    public boolean shouldUseThemeWallpaper() {
-        return mOverrideWallpaper == null && mWallpaperInfo != null;
-    }
-
-    public Asset getWallpaperPreviewAsset(Context context) {
-        return mOverrideWallpaper != null ?
-                getOverrideWallpaperAsset(context) :
-                getPreviewInfo().wallpaperAsset;
-    }
-
     private Asset getOverrideWallpaperAsset(Context context) {
         if (mOverrideWallpaperAsset == null) {
             mOverrideWallpaperAsset = new BitmapCachingAsset(context,
@@ -187,15 +166,6 @@
         return mOverrideWallpaperAsset;
     }
 
-    public WallpaperInfo getWallpaperInfo() {
-        return mWallpaperInfo;
-    }
-
-    @Nullable
-    public String getWallpaperOptions() {
-        return mWallpaperOptions;
-    }
-
     boolean isDefault() {
         return mIsDefault;
     }
@@ -280,14 +250,13 @@
         @ColorInt public final int colorAccentDark;
         public final List<Drawable> icons;
         public final Drawable shapeDrawable;
-        @Nullable public final Asset wallpaperAsset;
         public final List<Drawable> shapeAppIcons;
         @Dimension public final int bottomSheeetCornerRadius;
 
         private PreviewInfo(Context context, Typeface bodyFontFamily, Typeface headlineFontFamily,
                 int colorAccentLight, int colorAccentDark, List<Drawable> icons,
                 Drawable shapeDrawable, @Dimension int cornerRadius,
-                @Nullable Asset wallpaperAsset, List<Drawable> shapeAppIcons) {
+                List<Drawable> shapeAppIcons) {
             this.bodyFontFamily = bodyFontFamily;
             this.headlineFontFamily = headlineFontFamily;
             this.colorAccentLight = colorAccentLight;
@@ -295,8 +264,6 @@
             this.icons = icons;
             this.shapeDrawable = shapeDrawable;
             this.bottomSheeetCornerRadius = cornerRadius;
-            this.wallpaperAsset = wallpaperAsset == null
-                    ? null : new BitmapCachingAsset(context, wallpaperAsset);
             this.shapeAppIcons = shapeAppIcons;
         }
 
@@ -323,15 +290,11 @@
         private Path mShapePath;
         private boolean mIsDefault;
         @Dimension private int mCornerRadius;
-        private Asset mWallpaperAsset;
-        private WallpaperInfo mWallpaperInfo;
-        private String mWallpaperOptions;
         protected Map<String, String> mPackages = new HashMap<>();
         private List<Drawable> mAppIcons = new ArrayList<>();
 
         public ThemeBundle build(Context context) {
-            return new ThemeBundle(mTitle, mPackages, mIsDefault, mWallpaperInfo, mWallpaperOptions,
-                    createPreviewInfo(context));
+            return new ThemeBundle(mTitle, mPackages, mIsDefault, createPreviewInfo(context));
         }
 
         public PreviewInfo createPreviewInfo(Context context) {
@@ -359,8 +322,7 @@
                 }
             }
             return new PreviewInfo(context, mBodyFontFamily, mHeadlineFontFamily, mColorAccentLight,
-                    mColorAccentDark, mIcons, shapeDrawable, mCornerRadius,
-                    mWallpaperAsset, shapeIcons);
+                    mColorAccentDark, mIcons, shapeDrawable, mCornerRadius, shapeIcons);
         }
 
         public Map<String, String> getPackages() {
@@ -416,30 +378,6 @@
             return this;
         }
 
-        public Builder setWallpaperInfo(String wallpaperPackageName, String wallpaperResName,
-                String themeId, @DrawableRes int wallpaperResId, @StringRes int titleResId,
-                @StringRes int attributionResId, @StringRes int actionUrlResId) {
-            mWallpaperInfo = new ThemeBundledWallpaperInfo(wallpaperPackageName, wallpaperResName,
-                    themeId, wallpaperResId, titleResId, attributionResId, actionUrlResId);
-            return this;
-        }
-
-        public Builder setLiveWallpaperInfo(LiveWallpaperInfo info) {
-            mWallpaperInfo = info;
-            return this;
-        }
-
-
-        public Builder setWallpaperAsset(Asset wallpaperAsset) {
-            mWallpaperAsset = wallpaperAsset;
-            return this;
-        }
-
-        public Builder setWallpaperOptions(String wallpaperOptions) {
-            mWallpaperOptions = wallpaperOptions;
-            return this;
-        }
-
         public Builder asDefault() {
             mIsDefault = true;
             return this;
diff --git a/src/com/android/customization/model/theme/ThemeManager.java b/src/com/android/customization/model/theme/ThemeManager.java
index 79b45fd..533fbd0 100644
--- a/src/com/android/customization/model/theme/ThemeManager.java
+++ b/src/com/android/customization/model/theme/ThemeManager.java
@@ -24,7 +24,6 @@
 import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_ICON_THEMEPICKER;
 import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SHAPE;
 
-import android.graphics.Point;
 import android.provider.Settings;
 import android.text.TextUtils;
 
@@ -35,13 +34,6 @@
 import com.android.customization.model.ResourceConstants;
 import com.android.customization.model.theme.custom.CustomTheme;
 import com.android.customization.module.ThemesUserEventLogger;
-import com.android.wallpaper.R;
-import com.android.wallpaper.asset.Asset;
-import com.android.wallpaper.model.LiveWallpaperInfo;
-import com.android.wallpaper.model.WallpaperInfo;
-import com.android.wallpaper.module.WallpaperPersister.SetWallpaperCallback;
-import com.android.wallpaper.module.WallpaperSetter;
-import com.android.wallpaper.util.WallpaperCropUtils;
 
 import org.json.JSONObject;
 
@@ -61,25 +53,22 @@
         THEME_CATEGORIES.add(OVERLAY_CATEGORY_ICON_SYSUI);
         THEME_CATEGORIES.add(OVERLAY_CATEGORY_ICON_LAUNCHER);
         THEME_CATEGORIES.add(OVERLAY_CATEGORY_ICON_THEMEPICKER);
-    };
-
+    }
 
     private final ThemeBundleProvider mProvider;
     private final OverlayManagerCompat mOverlayManagerCompat;
 
-    private final WallpaperSetter mWallpaperSetter;
     protected final FragmentActivity mActivity;
     private final ThemesUserEventLogger mEventLogger;
 
     private Map<String, String> mCurrentOverlays;
 
     public ThemeManager(ThemeBundleProvider provider, FragmentActivity activity,
-            WallpaperSetter wallpaperSetter, OverlayManagerCompat overlayManagerCompat,
+            OverlayManagerCompat overlayManagerCompat,
             ThemesUserEventLogger logger) {
         mProvider = provider;
         mActivity = activity;
         mOverlayManagerCompat = overlayManagerCompat;
-        mWallpaperSetter = wallpaperSetter;
         mEventLogger = logger;
     }
 
@@ -90,67 +79,7 @@
 
     @Override
     public void apply(ThemeBundle theme, Callback callback) {
-        // Set wallpaper
-        if (theme.shouldUseThemeWallpaper()) {
-            mWallpaperSetter.requestDestination(mActivity, mActivity.getSupportFragmentManager(),
-                    R.string.set_theme_wallpaper_dialog_message,
-                    destination -> applyWallpaper(
-                            theme,
-                            destination,
-                            createSetWallpaperCallback(theme, callback)),
-                    theme.getWallpaperInfo() instanceof LiveWallpaperInfo);
-
-        } else {
-            applyOverlays(theme, callback);
-        }
-    }
-
-    private SetWallpaperCallback createSetWallpaperCallback(ThemeBundle theme, Callback callback) {
-        return new SetWallpaperCallback() {
-            @Override
-            public void onSuccess(WallpaperInfo wallpaperInfo) {
-                applyWallpaperOptions(theme);
-                applyOverlays(theme, callback);
-            }
-
-            @Override
-            public void onError(@Nullable Throwable throwable) {
-                callback.onError(throwable);
-            }
-        };
-    }
-
-    protected void applyWallpaperOptions(ThemeBundle theme) {
-        //Do nothing.
-    }
-
-    private void applyWallpaper(ThemeBundle theme, int destination,
-            SetWallpaperCallback callback) {
-        Point defaultCropSurfaceSize = WallpaperCropUtils.getDefaultCropSurfaceSize(
-                mActivity.getResources(),
-                mActivity.getWindowManager().getDefaultDisplay());
-        Asset wallpaperAsset = theme.getWallpaperInfo().getAsset(mActivity);
-        if (wallpaperAsset != null) {
-            wallpaperAsset.decodeRawDimensions(mActivity,
-                    dimensions -> {
-                        float scale = 1f;
-                        // Calculate scale to fit the screen height
-                        if (dimensions != null && dimensions.y > 0) {
-                            scale = (float) defaultCropSurfaceSize.y / dimensions.y;
-                        }
-                        mWallpaperSetter.setCurrentWallpaper(mActivity,
-                                theme.getWallpaperInfo(),
-                                wallpaperAsset,
-                                destination,
-                                scale, null, callback);
-                    });
-        } else {
-            mWallpaperSetter.setCurrentWallpaper(mActivity,
-                    theme.getWallpaperInfo(),
-                    null,
-                    destination,
-                    1f, null, callback);
-        }
+        applyOverlays(theme, callback);
     }
 
     private void applyOverlays(ThemeBundle theme, Callback callback) {
diff --git a/src/com/android/customization/model/theme/custom/CustomTheme.java b/src/com/android/customization/model/theme/custom/CustomTheme.java
index 8a7ca05..9c14f01 100644
--- a/src/com/android/customization/model/theme/custom/CustomTheme.java
+++ b/src/com/android/customization/model/theme/custom/CustomTheme.java
@@ -41,7 +41,7 @@
 
     public CustomTheme(@NonNull String id, String title, Map<String, String> overlayPackages,
             @Nullable PreviewInfo previewInfo) {
-        super(title, overlayPackages, false, null, null, previewInfo);
+        super(title, overlayPackages, false, previewInfo);
         mId = id;
     }
 
@@ -76,11 +76,6 @@
     }
 
     @Override
-    public boolean shouldUseThemeWallpaper() {
-        return false;
-    }
-
-    @Override
     public boolean isActive(CustomizationManager<ThemeBundle> manager) {
         return isDefined() && super.isActive(manager);
     }
diff --git a/src/com/android/customization/module/CustomizationInjector.java b/src/com/android/customization/module/CustomizationInjector.java
index d25f925..85853de 100644
--- a/src/com/android/customization/module/CustomizationInjector.java
+++ b/src/com/android/customization/module/CustomizationInjector.java
@@ -23,13 +23,11 @@
 import com.android.customization.model.theme.ThemeBundleProvider;
 import com.android.customization.model.theme.ThemeManager;
 import com.android.wallpaper.module.Injector;
-import com.android.wallpaper.module.WallpaperSetter;
 
 public interface CustomizationInjector extends Injector {
 
     CustomizationPreferences getCustomizationPreferences(Context context);
 
     ThemeManager getThemeManager(ThemeBundleProvider provider, FragmentActivity activity,
-            WallpaperSetter wallpaperSetter, OverlayManagerCompat overlayManagerCompat,
-            ThemesUserEventLogger logger);
+            OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger logger);
 }
diff --git a/src/com/android/customization/module/DefaultCustomizationInjector.java b/src/com/android/customization/module/DefaultCustomizationInjector.java
index a0d435b..7358d8f 100644
--- a/src/com/android/customization/module/DefaultCustomizationInjector.java
+++ b/src/com/android/customization/module/DefaultCustomizationInjector.java
@@ -30,7 +30,6 @@
 import com.android.wallpaper.module.LoggingOptInStatusProvider;
 import com.android.wallpaper.module.WallpaperPreferences;
 import com.android.wallpaper.module.WallpaperRotationRefresher;
-import com.android.wallpaper.module.WallpaperSetter;
 import com.android.wallpaper.monitor.PerformanceMonitor;
 import com.android.wallpaper.picker.PreviewFragment;
 
@@ -50,7 +49,6 @@
         return mPrefs;
     }
 
-
     @Override
     public CustomizationPreferences getCustomizationPreferences(Context context) {
         return (CustomizationPreferences) getPreferences(context);
@@ -115,9 +113,8 @@
 
     @Override
     public ThemeManager getThemeManager(ThemeBundleProvider provider, FragmentActivity activity,
-            WallpaperSetter wallpaperSetter, OverlayManagerCompat overlayManagerCompat,
-            ThemesUserEventLogger logger) {
-        return new ThemeManager(provider, activity, wallpaperSetter, overlayManagerCompat, logger);
+            OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger logger) {
+        return new ThemeManager(provider, activity, overlayManagerCompat, logger);
     }
 
 }
diff --git a/src/com/android/customization/picker/CustomizationPickerActivity.java b/src/com/android/customization/picker/CustomizationPickerActivity.java
index 86a0bf6..15ced54 100644
--- a/src/com/android/customization/picker/CustomizationPickerActivity.java
+++ b/src/com/android/customization/picker/CustomizationPickerActivity.java
@@ -65,7 +65,6 @@
 import com.android.wallpaper.module.Injector;
 import com.android.wallpaper.module.InjectorProvider;
 import com.android.wallpaper.module.UserEventLogger;
-import com.android.wallpaper.module.WallpaperSetter;
 import com.android.wallpaper.picker.CategoryFragment;
 import com.android.wallpaper.picker.CategoryFragment.CategoryFragmentHost;
 import com.android.wallpaper.picker.MyPhotosStarter;
@@ -73,6 +72,7 @@
 import com.android.wallpaper.picker.TopLevelPickerActivity;
 import com.android.wallpaper.picker.WallpaperPickerDelegate;
 import com.android.wallpaper.picker.WallpapersUiContainer;
+import com.android.wallpaper.widget.BottomActionBar;
 
 import com.google.android.material.bottomnavigation.BottomNavigationView;
 
@@ -98,7 +98,6 @@
 
     private static final Map<Integer, CustomizationSection> mSections = new HashMap<>();
     private CategoryFragment mWallpaperCategoryFragment;
-    private WallpaperSetter mWallpaperSetter;
 
     private boolean mWallpaperCategoryInitialized;
 
@@ -194,14 +193,11 @@
         }
         //Theme
         CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
-        mWallpaperSetter = new WallpaperSetter(injector.getWallpaperPersister(this),
-                injector.getPreferences(this), mUserEventLogger, false);
         ThemesUserEventLogger eventLogger = (ThemesUserEventLogger) injector.getUserEventLogger(
                 this);
         ThemeManager themeManager = injector.getThemeManager(
                 new DefaultThemeProvider(this, injector.getCustomizationPreferences(this)),
-                this,
-                mWallpaperSetter, new OverlayManagerCompat(this), eventLogger);
+                this, new OverlayManagerCompat(this), eventLogger);
         if (themeManager.isAvailable()) {
             mSections.put(R.id.nav_theme, new ThemeSection(R.id.nav_theme, themeManager));
         } else {
@@ -292,9 +288,18 @@
 
     @Override
     public void onBackPressed() {
+        // For wallpaper tab, since it had child fragment.
         if (mWallpaperCategoryFragment != null && mWallpaperCategoryFragment.popChildFragment()) {
             return;
         }
+
+        // For other tabs without child fragment. Hide the BottomActionBar if back key is pressed.
+        BottomActionBar bottomActionBar = findViewById(R.id.bottom_actionbar);
+        if (bottomActionBar != null && bottomActionBar.isVisible()) {
+            bottomActionBar.hide();
+            return;
+        }
+
         if (getSupportFragmentManager().popBackStackImmediate()) {
             return;
         }
@@ -391,14 +396,6 @@
     }
 
     @Override
-    protected void onDestroy() {
-        super.onDestroy();
-        if (mWallpaperSetter != null) {
-            mWallpaperSetter.cleanUp();
-        }
-    }
-
-    @Override
     protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
         if (mDelegate.handleActivityResult(requestCode, resultCode, data)) {
diff --git a/src/com/android/customization/picker/grid/GridFragment.java b/src/com/android/customization/picker/grid/GridFragment.java
index 7a01f26..c9589ce 100644
--- a/src/com/android/customization/picker/grid/GridFragment.java
+++ b/src/com/android/customization/picker/grid/GridFragment.java
@@ -17,12 +17,17 @@
 
 import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
 
+import static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY;
+import static com.android.wallpaper.widget.BottomActionBar.BottomAction.CANCEL;
+
 import android.app.Activity;
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.drawable.BitmapDrawable;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.Message;
+import android.os.RemoteException;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -47,7 +52,6 @@
 import com.android.customization.picker.BasePreviewAdapter;
 import com.android.customization.picker.BasePreviewAdapter.PreviewPage;
 import com.android.customization.widget.OptionSelectorController;
-import com.android.systemui.shared.system.SurfaceViewRequestUtils;
 import com.android.wallpaper.R;
 import com.android.wallpaper.asset.Asset;
 import com.android.wallpaper.asset.ContentUriAsset;
@@ -55,11 +59,14 @@
 import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
 import com.android.wallpaper.module.InjectorProvider;
 import com.android.wallpaper.picker.ToolbarFragment;
+import com.android.wallpaper.util.SurfaceViewUtils;
+import com.android.wallpaper.widget.BottomActionBar;
 import com.android.wallpaper.widget.PreviewPager;
 
 import com.bumptech.glide.Glide;
 import com.bumptech.glide.request.RequestOptions;
 
+import java.util.EnumSet;
 import java.util.List;
 
 /**
@@ -98,6 +105,7 @@
     private ContentLoadingProgressBar mLoading;
     private View mContent;
     private View mError;
+    private BottomActionBar mBottomActionBar;
     private ThemesUserEventLogger mEventLogger;
 
     @Override
@@ -139,20 +147,7 @@
         // Clear memory cache whenever grid fragment view is being loaded.
         Glide.get(getContext()).clearMemory();
         setUpOptions();
-        view.findViewById(R.id.apply_button).setOnClickListener(v -> {
-            mGridManager.apply(mSelectedOption,  new Callback() {
-                @Override
-                public void onSuccess() {
-                    getActivity().finish();
-                }
 
-                @Override
-                public void onError(@Nullable Throwable throwable) {
-                    //TODO(santie): handle
-                }
-            });
-
-        });
         CurrentWallpaperInfoFactory factory = InjectorProvider.getInjector()
                 .getCurrentWallpaperFactory(getContext().getApplicationContext());
 
@@ -172,6 +167,24 @@
                 loadWallpaperBackground();
             }
         });
+
+        mBottomActionBar = getActivity().findViewById(R.id.bottom_actionbar);
+        mBottomActionBar.showActionsOnly(EnumSet.of(CANCEL, APPLY));
+        mBottomActionBar.setActionClickListener(CANCEL, unused -> getActivity().onBackPressed());
+        mBottomActionBar.setActionClickListener(APPLY, unused -> {
+            mBottomActionBar.disableActions();
+            mGridManager.apply(mSelectedOption, new Callback() {
+                @Override
+                public void onSuccess() {
+                    getActivity().finish();
+                }
+
+                @Override
+                public void onError(@Nullable Throwable throwable) {
+                    //TODO(santie): handle
+                }
+            });
+        });
         return view;
     }
 
@@ -205,6 +218,7 @@
 
                 mOptionsController.addListener(selected -> {
                     mSelectedOption = (GridOption) selected;
+                    mBottomActionBar.show();
                     mEventLogger.logGridSelected(mSelectedOption);
                     createAdapter();
                 });
@@ -282,11 +296,18 @@
             if (usesSurfaceViewForPreview) {
                 mPreviewSurface.setZOrderOnTop(true);
                 mPreviewSurface.getHolder().addCallback(new SurfaceHolder.Callback() {
+
+                    private Message mCallback;
+
                     @Override
                     public void surfaceCreated(SurfaceHolder holder) {
-                        Bundle bundle = SurfaceViewRequestUtils.createSurfaceBundle(
-                                mPreviewSurface);
-                        mGridManager.renderPreview(bundle, mName);
+                        Bundle result = mGridManager.renderPreview(
+                                SurfaceViewUtils.createSurfaceViewRequest(mPreviewSurface), mName);
+                        if (result != null) {
+                            mPreviewSurface.setChildSurfacePackage(
+                                    SurfaceViewUtils.getSurfacePackage(result));
+                            mCallback = SurfaceViewUtils.getCallback(result);
+                        }
                     }
 
                     @Override
@@ -294,7 +315,17 @@
                             int height) {}
 
                     @Override
-                    public void surfaceDestroyed(SurfaceHolder holder) {}
+                    public void surfaceDestroyed(SurfaceHolder holder) {
+                        if (mCallback != null) {
+                            try {
+                                mCallback.replyTo.send(mCallback);
+                            } catch (RemoteException e) {
+                                e.printStackTrace();
+                            } finally {
+                                mCallback = null;
+                            }
+                        }
+                    }
                 });
             } else {
                 mPreviewAsset.loadDrawableWithTransition(mActivity,
diff --git a/src/com/android/customization/picker/theme/CustomThemeActivity.java b/src/com/android/customization/picker/theme/CustomThemeActivity.java
index fe537ba..6173b3d 100644
--- a/src/com/android/customization/picker/theme/CustomThemeActivity.java
+++ b/src/com/android/customization/picker/theme/CustomThemeActivity.java
@@ -53,7 +53,6 @@
 import com.android.customization.picker.theme.CustomThemeStepFragment.CustomThemeComponentStepHost;
 import com.android.wallpaper.R;
 import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.module.WallpaperSetter;
 
 import org.json.JSONException;
 
@@ -106,8 +105,6 @@
         mThemeManager = injector.getThemeManager(
                 new DefaultThemeProvider(this, injector.getCustomizationPreferences(this)),
                 this,
-                new WallpaperSetter(injector.getWallpaperPersister(this),
-                        injector.getPreferences(this), mUserEventLogger, false),
                 new OverlayManagerCompat(this),
                 mUserEventLogger);
         mThemeManager.fetchOptions(null, false);
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index b5c68e5..c3f2a8d 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -35,7 +35,6 @@
 import android.view.View.OnClickListener;
 import android.view.View.OnLayoutChangeListener;
 import android.view.ViewGroup;
-import android.widget.CheckBox;
 import android.widget.CompoundButton;
 import android.widget.ImageView;
 import android.widget.SeekBar;
@@ -63,6 +62,7 @@
 import com.android.wallpaper.R;
 import com.android.wallpaper.asset.Asset;
 import com.android.wallpaper.asset.Asset.CenterCropBitmapTask;
+import com.android.wallpaper.asset.BitmapCachingAsset;
 import com.android.wallpaper.model.WallpaperInfo;
 import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
 import com.android.wallpaper.module.InjectorProvider;
@@ -92,7 +92,6 @@
     }
 
     private RecyclerView mOptionsContainer;
-    private CheckBox mUseMyWallpaperButton;
     private OptionSelectorController<ThemeBundle> mOptionsController;
     private ThemeManager mThemeManager;
     private ThemesUserEventLogger mEventLogger;
@@ -102,8 +101,9 @@
     private ContentLoadingProgressBar mLoading;
     private View mContent;
     private View mError;
-    private boolean mUseMyWallpaper;
+    private boolean mUseMyWallpaper = true;
     private WallpaperInfo mCurrentHomeWallpaper;
+    private Asset mCurrentWallpaperThumbAsset;
     private CurrentWallpaperInfoFactory mCurrentWallpaperFactory;
     private TimeTicker mTicker;
 
@@ -145,8 +145,6 @@
         view.findViewById(R.id.apply_button).setOnClickListener(v -> {
             applyTheme();
         });
-        mUseMyWallpaperButton = view.findViewById(R.id.use_my_wallpaper);
-        mUseMyWallpaperButton.setOnCheckedChangeListener(this::onUseMyWallpaperCheckChanged);
         setUpOptions(savedInstanceState);
 
         return view;
@@ -220,32 +218,23 @@
         super.onActivityResult(requestCode, resultCode, data);
     }
 
-    private void onUseMyWallpaperCheckChanged(CompoundButton checkbox, boolean checked) {
-        mUseMyWallpaper = checked;
-        reloadWallpaper();
-    }
-
     private void reloadWallpaper() {
         mCurrentWallpaperFactory.createCurrentWallpaperInfos(
                 (homeWallpaper, lockWallpaper, presentationMode) -> {
                     mCurrentHomeWallpaper = homeWallpaper;
-                    if (mSelectedTheme != null) {
-                        if (mUseMyWallpaper || (mSelectedTheme instanceof CustomTheme)) {
-                            mSelectedTheme.setOverrideThemeWallpaper(homeWallpaper);
-                        } else {
-                            mSelectedTheme.setOverrideThemeWallpaper(null);
-                        }
-                        if (mAdapter != null) {
-                            mAdapter.rebindWallpaperIfAvailable();
-                        }
+                    mCurrentWallpaperThumbAsset = new BitmapCachingAsset(getContext(),
+                            mCurrentHomeWallpaper.getThumbAsset(getContext()));
+                    if (mSelectedTheme != null && mAdapter != null) {
+                        mAdapter.setWallpaperAsset(mCurrentWallpaperThumbAsset);
+                        mAdapter.rebindWallpaperIfAvailable();
                     }
         }, false);
     }
 
     private void createAdapter(List<ThemeBundle> options) {
         mAdapter = new ThemePreviewAdapter(getActivity(), mSelectedTheme,
-                mSelectedTheme instanceof CustomTheme ? this::onEditClicked : null,
-                new PreloadWallpapersLayoutListener(options));
+                mCurrentWallpaperThumbAsset,
+                mSelectedTheme instanceof CustomTheme ? this::onEditClicked : null);
         mPreviewPager.setAdapter(mAdapter);
     }
 
@@ -255,11 +244,6 @@
         }
     }
 
-    private void updateButtonsVisibility() {
-        mUseMyWallpaperButton.setVisibility(mSelectedTheme instanceof CustomTheme
-                ? View.INVISIBLE : View.VISIBLE);
-    }
-
     private void hideError() {
         mContent.setVisibility(View.VISIBLE);
         mError.setVisibility(View.GONE);
@@ -292,7 +276,6 @@
                         mEventLogger.logThemeSelected(mSelectedTheme,
                                 selected instanceof CustomTheme);
                         createAdapter(options);
-                        updateButtonsVisibility();
                     }
                 });
                 mOptionsController.initOptions(mThemeManager);
@@ -384,11 +367,12 @@
                 R.id.shape_preview_icon_0, R.id.shape_preview_icon_1, R.id.shape_preview_icon_2,
                 R.id.shape_preview_icon_3, R.id.shape_preview_icon_4, R.id.shape_preview_icon_5
         };
+        private Asset mWallpaperAsset;
 
-        ThemePreviewAdapter(Activity activity, ThemeBundle theme,
-                @Nullable OnClickListener editClickListener,
-                @Nullable OnLayoutChangeListener coverCardLayoutListener) {
+        ThemePreviewAdapter(Activity activity, ThemeBundle theme, @Nullable Asset wallpaperAsset,
+                @Nullable OnClickListener editClickListener) {
             super(activity, R.layout.theme_preview_card);
+            mWallpaperAsset = wallpaperAsset;
             final Resources res = activity.getResources();
             final PreviewInfo previewInfo = theme.getPreviewInfo();
 
@@ -397,14 +381,14 @@
                     : null;
 
             WallpaperPreviewLayoutListener wallpaperListener = new WallpaperPreviewLayoutListener(
-                    theme, previewInfo, coverScrim, true);
+                    () -> mWallpaperAsset, previewInfo, coverScrim, true);
 
             addPage(new ThemeCoverPage(activity, theme.getTitle(),
                     previewInfo.resolveAccentColor(res), previewInfo.icons,
                     previewInfo.headlineFontFamily, previewInfo.bottomSheeetCornerRadius,
                     previewInfo.shapeDrawable, previewInfo.shapeAppIcons, editClickListener,
                     mColorButtonIds, mColorTileIds, mColorTileIconIds, mShapeIconIds,
-                    wallpaperListener, coverCardLayoutListener));
+                    wallpaperListener));
             addPage(new ThemePreviewPage(activity, R.string.preview_name_font, R.drawable.ic_font,
                     R.layout.preview_card_font_content,
                     previewInfo.resolveAccentColor(res)) {
@@ -501,31 +485,6 @@
                     }
                 });
             }
-            if (previewInfo.wallpaperAsset != null) {
-                addPage(new ThemePreviewPage(activity, R.string.preview_name_wallpaper,
-                        R.drawable.ic_nav_wallpaper, R.layout.preview_card_wallpaper_content,
-                        previewInfo.resolveAccentColor(res)) {
-
-                    private final WallpaperPreviewLayoutListener mListener =
-                            new WallpaperPreviewLayoutListener(theme, previewInfo, null, false);
-
-                    @Override
-                    protected boolean containsWallpaper() {
-                        return true;
-                    }
-
-                    @Override
-                    protected void bindBody(boolean forceRebind) {
-                        if (card == null) {
-                            return;
-                        }
-                        card.addOnLayoutChangeListener(mListener);
-                        if (forceRebind) {
-                            card.requestLayout();
-                        }
-                    }
-                });
-            }
         }
 
         public void rebindWallpaperIfAvailable() {
@@ -544,15 +503,23 @@
             }
         }
 
+        public void setWallpaperAsset(Asset wallpaperAsset) {
+            mWallpaperAsset = wallpaperAsset;
+        }
+
         private static class WallpaperPreviewLayoutListener implements OnLayoutChangeListener {
-            private final ThemeBundle mTheme;
+            interface WallpaperPreviewAssetProvider {
+                Asset getAsset();
+            }
+            private final WallpaperPreviewAssetProvider mWallpaperPreviewAssetProvider;
             private final PreviewInfo mPreviewInfo;
             private final Drawable mScrim;
             private final boolean mIsTranslucent;
 
-            public WallpaperPreviewLayoutListener(ThemeBundle theme, PreviewInfo previewInfo,
-                    Drawable scrim, boolean translucent) {
-                mTheme = theme;
+            WallpaperPreviewLayoutListener(
+                    WallpaperPreviewAssetProvider wallpaperPreviewAssetProvider,
+                    PreviewInfo previewInfo, Drawable scrim, boolean translucent) {
+                mWallpaperPreviewAssetProvider = wallpaperPreviewAssetProvider;
                 mPreviewInfo = previewInfo;
                 mScrim = scrim;
                 mIsTranslucent = translucent;
@@ -564,8 +531,7 @@
                 int targetWidth = right - left;
                 int targetHeight = bottom - top;
                 if (targetWidth > 0 && targetHeight > 0) {
-                    Asset wallpaperPreviewAsset = mTheme.getWallpaperPreviewAsset(
-                            view.getContext());
+                    Asset wallpaperPreviewAsset = mWallpaperPreviewAssetProvider.getAsset();
                     if (wallpaperPreviewAsset != null) {
                         wallpaperPreviewAsset.decodeBitmap(
                                 targetWidth, targetHeight,
@@ -611,41 +577,4 @@
             }
         }
     }
-
-    /**
-     * Runs only once after the card size is known, and requests decoding wallpaper bitmaps
-     * for all the options, to warm-up the bitmap cache.
-     */
-    private static class PreloadWallpapersLayoutListener implements OnLayoutChangeListener {
-        private static boolean alreadyRunOnce;
-        private final List<ThemeBundle> mOptions;
-
-        public PreloadWallpapersLayoutListener(List<ThemeBundle> options) {
-            mOptions = options;
-        }
-
-        @Override
-        public void onLayoutChange(View view, int left, int top, int right,
-                int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
-            if (alreadyRunOnce) {
-                view.removeOnLayoutChangeListener(this);
-                return;
-            }
-            int targetWidth = right - left;
-            int targetHeight = bottom - top;
-            if (targetWidth > 0 && targetHeight > 0) {
-                for (ThemeBundle theme : mOptions) {
-                    if (theme instanceof CustomTheme && !((CustomTheme) theme).isDefined()) {
-                        continue;
-                    }
-                    Asset wallpaperAsset = theme.getWallpaperPreviewAsset(view.getContext());
-                    if (wallpaperAsset != null) {
-                        wallpaperAsset.decodeBitmap(targetWidth, targetHeight, bitmap -> {});
-                    }
-                }
-                view.removeOnLayoutChangeListener(this);
-                alreadyRunOnce = true;
-            }
-        }
-    }
 }
diff --git a/src/com/android/customization/picker/theme/ThemePreviewPage.java b/src/com/android/customization/picker/theme/ThemePreviewPage.java
index c3af91c..cbcbc78 100644
--- a/src/com/android/customization/picker/theme/ThemePreviewPage.java
+++ b/src/com/android/customization/picker/theme/ThemePreviewPage.java
@@ -179,7 +179,6 @@
             }
 
             // Shape preview icons:
-
             for (int i = 0; i < 3 && i < mShapeAppIcons.size(); i++) {
                 ImageView iconView = card.findViewById(mShapeIconIds[i]);
                 iconView.setBackground(mShapeAppIcons.get(i));
diff --git a/tests/src/com/android/customization/testing/TestCustomizationInjector.java b/tests/src/com/android/customization/testing/TestCustomizationInjector.java
index 10b5934..dbbdb74 100644
--- a/tests/src/com/android/customization/testing/TestCustomizationInjector.java
+++ b/tests/src/com/android/customization/testing/TestCustomizationInjector.java
@@ -13,7 +13,6 @@
 import com.android.wallpaper.module.DrawableLayerResolver;
 import com.android.wallpaper.module.PackageStatusNotifier;
 import com.android.wallpaper.module.UserEventLogger;
-import com.android.wallpaper.module.WallpaperSetter;
 import com.android.wallpaper.testing.TestInjector;
 
 /**
@@ -38,12 +37,10 @@
     public ThemeManager getThemeManager(
             ThemeBundleProvider provider,
             FragmentActivity activity,
-            WallpaperSetter wallpaperSetter,
             OverlayManagerCompat overlayManagerCompat,
             ThemesUserEventLogger logger) {
         if (mThemeManager == null) {
-            mThemeManager = new TestThemeManager(provider, activity, wallpaperSetter,
-                    overlayManagerCompat, logger);
+            mThemeManager = new TestThemeManager(provider, activity, overlayManagerCompat, logger);
         }
         return mThemeManager;
     }
diff --git a/tests/src/com/android/customization/testing/TestThemeManager.java b/tests/src/com/android/customization/testing/TestThemeManager.java
index cc8567f..c4d25fb 100644
--- a/tests/src/com/android/customization/testing/TestThemeManager.java
+++ b/tests/src/com/android/customization/testing/TestThemeManager.java
@@ -6,7 +6,6 @@
 import com.android.customization.model.theme.ThemeBundleProvider;
 import com.android.customization.model.theme.ThemeManager;
 import com.android.customization.module.ThemesUserEventLogger;
-import com.android.wallpaper.module.WallpaperSetter;
 
 /**
  * Test implementation of {@link ThemeManager}.
@@ -18,10 +17,9 @@
     public TestThemeManager(
             ThemeBundleProvider provider,
             FragmentActivity activity,
-            WallpaperSetter wallpaperSetter,
             OverlayManagerCompat overlayManagerCompat,
             ThemesUserEventLogger logger) {
-        super(provider, activity, wallpaperSetter, overlayManagerCompat, logger);
+        super(provider, activity, overlayManagerCompat, logger);
     }
 
     @Override