1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.customization.module 17 18 import android.stats.style.StyleEnums 19 import com.android.systemui.shared.system.SysUiStatsLog 20 import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UI_CHANGED 21 22 /** The builder for [SysUiStatsLog]. */ 23 class SysUiStatsLogger { 24 25 private var atom = STYLE_UI_CHANGED 26 private var action = StyleEnums.DEFAULT_ACTION 27 private var colorPackageHash = 0 28 private var fontPackageHash = 0 29 private var shapePackageHash = 0 30 private var clockPackageHash = 0 31 private var launcherGrid = 0 32 private var wallpaperCategoryHash = 0 33 private var wallpaperIdHash = 0 34 private var colorPreference = 0 35 private var locationPreference = StyleEnums.EFFECT_PREFERENCE_UNSPECIFIED 36 private var datePreference = StyleEnums.DATE_PREFERENCE_UNSPECIFIED 37 private var launchedPreference = StyleEnums.LAUNCHED_PREFERENCE_UNSPECIFIED 38 private var effectPreference = StyleEnums.EFFECT_PREFERENCE_UNSPECIFIED 39 private var effectIdHash = 0 40 private var lockWallpaperCategoryHash = 0 41 private var lockWallpaperIdHash = 0 42 private var firstLaunchDateSinceSetup = 0 43 private var firstWallpaperApplyDateSinceSetup = 0 44 private var appLaunchCount = 0 45 private var colorVariant = 0 46 private var timeElapsedMillis = 0L 47 private var effectResultCode = -1 48 <lambda>null49 fun setAction(action: Int) = apply { this.action = action } 50 <lambda>null51 fun setColorPackageHash(color_package_hash: Int) = apply { 52 this.colorPackageHash = color_package_hash 53 } 54 <lambda>null55 fun setFontPackageHash(font_package_hash: Int) = apply { 56 this.fontPackageHash = font_package_hash 57 } 58 <lambda>null59 fun setShapePackageHash(shape_package_hash: Int) = apply { 60 this.shapePackageHash = shape_package_hash 61 } 62 <lambda>null63 fun setClockPackageHash(clock_package_hash: Int) = apply { 64 this.clockPackageHash = clock_package_hash 65 } 66 <lambda>null67 fun setLauncherGrid(launcher_grid: Int) = apply { this.launcherGrid = launcher_grid } 68 <lambda>null69 fun setWallpaperCategoryHash(wallpaper_category_hash: Int) = apply { 70 this.wallpaperCategoryHash = wallpaper_category_hash 71 } 72 <lambda>null73 fun setWallpaperIdHash(wallpaper_id_hash: Int) = apply { 74 this.wallpaperIdHash = wallpaper_id_hash 75 } 76 <lambda>null77 fun setColorPreference(color_preference: Int) = apply { 78 this.colorPreference = color_preference 79 } 80 <lambda>null81 fun setLocationPreference(location_preference: Int) = apply { 82 this.locationPreference = location_preference 83 } 84 <lambda>null85 fun setDatePreference(date_preference: Int) = apply { this.datePreference = date_preference } 86 <lambda>null87 fun setLaunchedPreference(launched_preference: Int) = apply { 88 this.launchedPreference = launched_preference 89 } 90 <lambda>null91 fun setEffectPreference(effect_preference: Int) = apply { 92 this.effectPreference = effect_preference 93 } 94 <lambda>null95 fun setEffectIdHash(effect_id_hash: Int) = apply { this.effectIdHash = effect_id_hash } 96 <lambda>null97 fun setLockWallpaperCategoryHash(lock_wallpaper_category_hash: Int) = apply { 98 this.lockWallpaperCategoryHash = lock_wallpaper_category_hash 99 } 100 <lambda>null101 fun setLockWallpaperIdHash(lock_wallpaper_id_hash: Int) = apply { 102 this.lockWallpaperIdHash = lock_wallpaper_id_hash 103 } 104 <lambda>null105 fun setFirstLaunchDateSinceSetup(first_launch_date_since_setup: Int) = apply { 106 this.firstLaunchDateSinceSetup = first_launch_date_since_setup 107 } 108 <lambda>null109 fun setFirstWallpaperApplyDateSinceSetup(first_wallpaper_apply_date_since_setup: Int) = apply { 110 this.firstWallpaperApplyDateSinceSetup = first_wallpaper_apply_date_since_setup 111 } 112 <lambda>null113 fun setAppLaunchCount(app_launch_count: Int) = apply { this.appLaunchCount = app_launch_count } 114 <lambda>null115 fun setColorVariant(color_variant: Int) = apply { this.colorVariant = color_variant } 116 <lambda>null117 fun setTimeElapsed(time_elapsed_millis: Long) = apply { 118 this.timeElapsedMillis = time_elapsed_millis 119 } 120 <lambda>null121 fun setEffectResultCode(effect_result_code: Int) = apply { 122 this.effectResultCode = effect_result_code 123 } 124 lognull125 fun log() { 126 SysUiStatsLog.write( 127 atom, 128 action, 129 colorPackageHash, 130 fontPackageHash, 131 shapePackageHash, 132 clockPackageHash, 133 launcherGrid, 134 wallpaperCategoryHash, 135 wallpaperIdHash, 136 colorPreference, 137 locationPreference, 138 datePreference, 139 launchedPreference, 140 effectPreference, 141 effectIdHash, 142 lockWallpaperCategoryHash, 143 lockWallpaperIdHash, 144 firstLaunchDateSinceSetup, 145 firstWallpaperApplyDateSinceSetup, 146 appLaunchCount, 147 colorVariant, 148 timeElapsedMillis, 149 effectResultCode, 150 ) 151 } 152 } 153