Properly handle default custom theme options

Bug: 134186220
Change-Id: Ib1c6b643275d35a35cf0e5b0a27890f80a8a57ac
diff --git a/src/com/android/customization/model/theme/ThemeBundle.java b/src/com/android/customization/model/theme/ThemeBundle.java
index 7c543d4..b3258de 100644
--- a/src/com/android/customization/model/theme/ThemeBundle.java
+++ b/src/com/android/customization/model/theme/ThemeBundle.java
@@ -70,6 +70,7 @@
  */
 public class ThemeBundle implements CustomizationOption<ThemeBundle> {
 
+    private final static String EMPTY_JSON = "{}";
     private final String mTitle;
     private final PreviewInfo mPreviewInfo;
     private final boolean mIsDefault;
@@ -144,7 +145,8 @@
             return false;
         }
         if (mIsDefault) {
-            return other.isDefault() || TextUtils.isEmpty(other.getSerializedPackages());
+            return other.isDefault() || TextUtils.isEmpty(other.getSerializedPackages())
+                    || EMPTY_JSON.equals(other.getSerializedPackages());
         }
         // Map#equals ensures keys and values are compared.
         return mPackagesByCategory.equals(other.mPackagesByCategory);
diff --git a/src/com/android/customization/model/theme/custom/IconOptionsProvider.java b/src/com/android/customization/model/theme/custom/IconOptionsProvider.java
index 73a4a22..f7b669b 100644
--- a/src/com/android/customization/model/theme/custom/IconOptionsProvider.java
+++ b/src/com/android/customization/model/theme/custom/IconOptionsProvider.java
@@ -86,7 +86,7 @@
         }
 
         for (String overlayPackage : mSysUiIconsOverlayPackages) {
-            addOrUpdateOption(optionsByPrefix, overlayPackage,  OVERLAY_CATEGORY_ICON_SYSUI);
+            addOrUpdateOption(optionsByPrefix, overlayPackage, OVERLAY_CATEGORY_ICON_SYSUI);
         }
 
         for (String overlayPackage : mSettingsIconsOverlayPackages) {
@@ -142,6 +142,11 @@
         } catch (NameNotFoundException | NotFoundException e) {
             Log.w(TAG, "Didn't find SystemUi package icons, will skip option", e);
         }
+        option.addOverlayPackage(OVERLAY_CATEGORY_ICON_ANDROID, null);
+        option.addOverlayPackage(OVERLAY_CATEGORY_ICON_SYSUI, null);
+        option.addOverlayPackage(OVERLAY_CATEGORY_ICON_SETTINGS, null);
+        option.addOverlayPackage(OVERLAY_CATEGORY_ICON_LAUNCHER, null);
+        option.addOverlayPackage(OVERLAY_CATEGORY_ICON_THEMEPICKER, null);
         mOptions.add(option);
     }
 
diff --git a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
index 8966dc5..78131cc 100644
--- a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
+++ b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
@@ -34,7 +34,6 @@
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.LayerDrawable;
 import android.graphics.drawable.ShapeDrawable;
-import android.text.TextUtils;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -61,7 +60,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Objects;
 
 /**
@@ -92,11 +90,7 @@
     public abstract void bindPreview(ViewGroup container);
 
     public Builder buildStep(Builder builder) {
-        getOverlayPackages().forEach((category, packageName) -> {
-            if (!TextUtils.isEmpty(packageName)) {
-                builder.addOverlayPackage(category, packageName);
-            }
-        });
+        getOverlayPackages().forEach(builder::addOverlayPackage);
         return builder;
     }