[1/n] Color picking show up performance

Remove unused color code to reduce the time on getting color resources
for basic colors.

Bug: 229595282
Test: manual
Change-Id: I334f45b379c1a959868ac628ac7881c88049796e
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..5d6aefc 100644
--- a/src/com/android/customization/model/color/ColorProvider.kt
+++ b/src/com/android/customization/model/color/ColorProvider.kt
@@ -271,7 +271,6 @@
                 builder.setColorPrimaryLight(lightColors[0]).setColorSecondaryLight(lightColors[1])
             }
 
-            extractor.addAndroidIconOverlay(builder)
             bundles.add(builder.build(mContext))
             index++
         }