Add new logging APIs (1/2)

Test: Will test manually in later CLs when log APIs are used
Bug: 299659307
Change-Id: If8091555c4ea62001e212db8d25eee3f19949ba3
diff --git a/src/com/android/customization/module/logging/StatsLogUserEventLogger.kt b/src/com/android/customization/module/logging/StatsLogUserEventLogger.kt
index 90a1c6f..344a4f8 100644
--- a/src/com/android/customization/module/logging/StatsLogUserEventLogger.kt
+++ b/src/com/android/customization/module/logging/StatsLogUserEventLogger.kt
@@ -22,6 +22,7 @@
 import com.android.customization.model.color.ColorOption
 import com.android.customization.model.grid.GridOption
 import com.android.customization.module.SysUiStatsLogger
+import com.android.customization.module.logging.ThemesUserEventLogger.ClockSize
 import com.android.systemui.shared.system.SysUiStatsLog
 import com.android.wallpaper.module.WallpaperPersister.DEST_BOTH
 import com.android.wallpaper.module.WallpaperPersister.DEST_HOME_SCREEN
@@ -37,18 +38,6 @@
 class StatsLogUserEventLogger(private val preferences: WallpaperPreferences) :
     NoOpUserEventLogger(), ThemesUserEventLogger {
 
-    override fun logAppLaunched(launchSource: Intent) {
-        SysUiStatsLogger(SysUiStatsLog.STYLE_UICHANGED__ACTION__APP_LAUNCHED)
-            .setLaunchedPreference(getAppLaunchSource(launchSource))
-            .log()
-    }
-
-    override fun logActionClicked(collectionId: String, actionLabelResId: Int) {
-        SysUiStatsLogger(StyleEnums.WALLPAPER_EXPLORE)
-            .setWallpaperCategoryHash(getIdHashCode(collectionId))
-            .log()
-    }
-
     override fun logSnapshot() {
         SysUiStatsLogger(StyleEnums.SNAPSHOT)
             .setWallpaperCategoryHash(preferences.getHomeCategoryHash())
@@ -59,6 +48,12 @@
             .log()
     }
 
+    override fun logAppLaunched(launchSource: Intent) {
+        SysUiStatsLogger(StyleEnums.APP_LAUNCHED)
+            .setLaunchedPreference(launchSource.getAppLaunchSource())
+            .log()
+    }
+
     override fun logWallpaperApplied(
         collectionId: String?,
         wallpaperId: String?,
@@ -114,20 +109,69 @@
             .log()
     }
 
-    override fun logColorApplied(action: Int, colorOption: ColorOption) {
-        SysUiStatsLogger(action)
+    override fun logResetApplied() {
+        SysUiStatsLogger(StyleEnums.RESET_APPLIED).log()
+    }
+
+    override fun logWallpaperExploreButtonClicked() {
+        SysUiStatsLogger(StyleEnums.WALLPAPER_EXPLORE).log()
+    }
+
+    override fun logThemeColorApplied(colorOption: ColorOption) {
+        SysUiStatsLogger(StyleEnums.THEME_COLOR_APPLIED)
             .setColorPreference(colorOption.index)
             .setColorVariant(colorOption.style.ordinal + 1)
             .log()
     }
 
     override fun logGridApplied(grid: GridOption) {
-        SysUiStatsLogger(StyleEnums.PICKER_APPLIED).setLauncherGrid(grid.cols).log()
+        SysUiStatsLogger(StyleEnums.GRID_APPLIED).setLauncherGrid(grid.getLauncherGridInt()).log()
     }
 
-    private fun getAppLaunchSource(launchSource: Intent): Int {
-        return if (launchSource.hasExtra(LaunchSourceUtils.WALLPAPER_LAUNCH_SOURCE)) {
-            when (launchSource.getStringExtra(LaunchSourceUtils.WALLPAPER_LAUNCH_SOURCE)) {
+    override fun logClockApplied(clockId: String) {
+        SysUiStatsLogger(StyleEnums.CLOCK_APPLIED).setClockPackageHash(getIdHashCode(clockId)).log()
+    }
+
+    override fun logClockColorApplied(seedColor: Int) {
+        SysUiStatsLogger(StyleEnums.CLOCK_COLOR_APPLIED).setSeedColor(seedColor).log()
+    }
+
+    override fun logClockSizeApplied(@ClockSize clockSize: Int) {
+        SysUiStatsLogger(StyleEnums.CLOCK_SIZE_APPLIED).setClockSize(clockSize).log()
+    }
+
+    override fun logThemedIconApplied(useThemeIcon: Boolean) {
+        SysUiStatsLogger(StyleEnums.THEMED_ICON_APPLIED).setToggleOn(useThemeIcon).log()
+    }
+
+    override fun logLockScreenNotificationApplied(showLockScreenNotifications: Boolean) {
+        SysUiStatsLogger(StyleEnums.LOCK_SCREEN_NOTIFICATION_APPLIED)
+            .setToggleOn(showLockScreenNotifications)
+            .log()
+    }
+
+    override fun logShortcutApplied(shortcut: String, shortcutSlotId: String) {
+        SysUiStatsLogger(StyleEnums.SHORTCUT_APPLIED)
+            .setShortcut(shortcut)
+            .setShortcutSlotId(shortcutSlotId)
+            .log()
+    }
+
+    override fun logDarkThemeApplied(useDarkTheme: Boolean) {
+        SysUiStatsLogger(StyleEnums.DARK_THEME_APPLIED).setToggleOn(useDarkTheme).log()
+    }
+
+    /**
+     * The grid integer depends on the column and row numbers. For example: 4x5 is 405 13x37 is 1337
+     * The upper limit for the column / row count is 99.
+     */
+    private fun GridOption.getLauncherGridInt(): Int {
+        return cols * 100 + rows
+    }
+
+    private fun Intent.getAppLaunchSource(): Int {
+        return if (hasExtra(LaunchSourceUtils.WALLPAPER_LAUNCH_SOURCE)) {
+            when (getStringExtra(LaunchSourceUtils.WALLPAPER_LAUNCH_SOURCE)) {
                 LaunchSourceUtils.LAUNCH_SOURCE_LAUNCHER ->
                     SysUiStatsLog.STYLE_UICHANGED__LAUNCHED_PREFERENCE__LAUNCHED_LAUNCHER
                 LaunchSourceUtils.LAUNCH_SOURCE_SETTINGS ->
@@ -142,17 +186,11 @@
                     SysUiStatsLog
                         .STYLE_UICHANGED__LAUNCHED_PREFERENCE__LAUNCHED_PREFERENCE_UNSPECIFIED
             }
-        } else if (launchSource.hasExtra(LaunchSourceUtils.LAUNCH_SETTINGS_SEARCH)) {
+        } else if (hasExtra(LaunchSourceUtils.LAUNCH_SETTINGS_SEARCH)) {
             SysUiStatsLog.STYLE_UICHANGED__LAUNCHED_PREFERENCE__LAUNCHED_SETTINGS_SEARCH
-        } else if (
-            launchSource.action != null &&
-                launchSource.action == WallpaperManager.ACTION_CROP_AND_SET_WALLPAPER
-        ) {
+        } else if (action != null && action == WallpaperManager.ACTION_CROP_AND_SET_WALLPAPER) {
             SysUiStatsLog.STYLE_UICHANGED__LAUNCHED_PREFERENCE__LAUNCHED_CROP_AND_SET_ACTION
-        } else if (
-            launchSource.categories != null &&
-                launchSource.categories.contains(Intent.CATEGORY_LAUNCHER)
-        ) {
+        } else if (categories != null && categories.contains(Intent.CATEGORY_LAUNCHER)) {
             SysUiStatsLog.STYLE_UICHANGED__LAUNCHED_PREFERENCE__LAUNCHED_LAUNCH_ICON
         } else {
             SysUiStatsLog.STYLE_UICHANGED__LAUNCHED_PREFERENCE__LAUNCHED_PREFERENCE_UNSPECIFIED
diff --git a/src/com/android/customization/module/logging/ThemesUserEventLogger.kt b/src/com/android/customization/module/logging/ThemesUserEventLogger.kt
index 4fd5334..1210343 100644
--- a/src/com/android/customization/module/logging/ThemesUserEventLogger.kt
+++ b/src/com/android/customization/module/logging/ThemesUserEventLogger.kt
@@ -15,19 +15,38 @@
  */
 package com.android.customization.module.logging
 
+import android.stats.style.StyleEnums
+import androidx.annotation.IntDef
 import com.android.customization.model.color.ColorOption
 import com.android.customization.model.grid.GridOption
 import com.android.wallpaper.module.logging.UserEventLogger
 
 /** Extension of [UserEventLogger] that adds ThemePicker specific events. */
 interface ThemesUserEventLogger : UserEventLogger {
-    /**
-     * Logs the color usage while color is applied.
-     *
-     * @param action color applied action.
-     * @param colorOption applied color option.
-     */
-    fun logColorApplied(action: Int, colorOption: ColorOption)
+
+    fun logThemeColorApplied(colorOption: ColorOption)
 
     fun logGridApplied(grid: GridOption)
+
+    fun logClockApplied(clockId: String)
+
+    fun logClockColorApplied(seedColor: Int)
+
+    fun logClockSizeApplied(@ClockSize clockSize: Int)
+
+    fun logThemedIconApplied(useThemeIcon: Boolean)
+
+    fun logLockScreenNotificationApplied(showLockScreenNotifications: Boolean)
+
+    fun logShortcutApplied(shortcut: String, shortcutSlotId: String)
+
+    fun logDarkThemeApplied(useDarkTheme: Boolean)
+
+    @IntDef(
+        StyleEnums.CLOCK_SIZE_UNSPECIFIED,
+        StyleEnums.CLOCK_SIZE_DYNAMIC,
+        StyleEnums.CLOCK_SIZE_SMALL,
+    )
+    @Retention(AnnotationRetention.SOURCE)
+    annotation class ClockSize
 }
diff --git a/tests/common/src/com/android/customization/testing/TestThemesUserEventLogger.kt b/tests/common/src/com/android/customization/testing/TestThemesUserEventLogger.kt
index 2236b62..8b14688 100644
--- a/tests/common/src/com/android/customization/testing/TestThemesUserEventLogger.kt
+++ b/tests/common/src/com/android/customization/testing/TestThemesUserEventLogger.kt
@@ -23,7 +23,21 @@
 /** Test implementation of [ThemesUserEventLogger]. */
 class TestThemesUserEventLogger : TestUserEventLogger(), ThemesUserEventLogger {
 
-    override fun logColorApplied(action: Int, colorOption: ColorOption) {}
+    override fun logThemeColorApplied(colorOption: ColorOption) {}
 
     override fun logGridApplied(grid: GridOption) {}
+
+    override fun logClockApplied(clockId: String) {}
+
+    override fun logClockColorApplied(seedColor: Int) {}
+
+    override fun logClockSizeApplied(clockSize: Int) {}
+
+    override fun logThemedIconApplied(useThemeIcon: Boolean) {}
+
+    override fun logLockScreenNotificationApplied(showLockScreenNotifications: Boolean) {}
+
+    override fun logShortcutApplied(shortcut: String, shortcutSlotId: String) {}
+
+    override fun logDarkThemeApplied(useDarkTheme: Boolean) {}
 }