Store an empty theme object on first visit

Bug: 126230901
Change-Id: Id6a6a6125f82d52c364be04fc63d4c3cd3702a4e
diff --git a/src/com/android/customization/model/theme/ThemeManager.java b/src/com/android/customization/model/theme/ThemeManager.java
index cd33f6b..96a159f 100644
--- a/src/com/android/customization/model/theme/ThemeManager.java
+++ b/src/com/android/customization/model/theme/ThemeManager.java
@@ -29,6 +29,7 @@
 import android.graphics.Point;
 import android.provider.Settings;
 
+import android.text.TextUtils;
 import androidx.annotation.Nullable;
 import androidx.fragment.app.FragmentActivity;
 
@@ -43,6 +44,7 @@
 import com.android.wallpaper.module.WallpaperSetter;
 import com.android.wallpaper.picker.SetWallpaperDialogFragment.Listener;
 import com.android.wallpaper.util.WallpaperCropUtils;
+import org.json.JSONObject;
 
 import java.util.HashSet;
 import java.util.Map;
@@ -242,4 +244,17 @@
     public ThemeBundle findThemeByPackages(ThemeBundle other) {
         return mProvider.findEquivalent(other);
     }
+
+    /**
+     * Store empty theme if no theme has been set yet. This will prevent Settings from showing the
+     * suggestion to select a theme
+     */
+    public void storeEmptyTheme() {
+        String themeSetting = Settings.Secure.getString(mActivity.getContentResolver(),
+                ResourceConstants.THEME_SETTING);
+        if (TextUtils.isEmpty(themeSetting)) {
+            Settings.Secure.putString(mActivity.getContentResolver(),
+                    ResourceConstants.THEME_SETTING, new JSONObject().toString());
+        }
+    }
 }
diff --git a/src/com/android/customization/picker/CustomizationPickerActivity.java b/src/com/android/customization/picker/CustomizationPickerActivity.java
index 110dbaf..c5b79f1 100644
--- a/src/com/android/customization/picker/CustomizationPickerActivity.java
+++ b/src/com/android/customization/picker/CustomizationPickerActivity.java
@@ -17,7 +17,6 @@
 
 import android.app.Activity;
 import android.content.Intent;
-import android.content.SharedPreferences;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.LayerDrawable;
 import android.os.Build;
@@ -227,6 +226,10 @@
             if (!prefs.getTabVisited(name)) {
                 prefs.setTabVisited(name);
                 hideTipDot(item);
+
+                if (id == R.id.nav_theme) {
+                    getThemeManager().storeEmptyTheme();
+                }
             }
             return true;
         });