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(val action: Int) { 24 25 private var colorPackageHash = 0 26 private var fontPackageHash = 0 27 private var shapePackageHash = 0 28 private var clockPackageHash = 0 29 private var launcherGrid = 0 30 private var wallpaperCategoryHash = 0 31 private var wallpaperIdHash = 0 32 private var colorPreference = 0 33 private var locationPreference = StyleEnums.EFFECT_PREFERENCE_UNSPECIFIED 34 private var datePreference = StyleEnums.DATE_PREFERENCE_UNSPECIFIED 35 private var launchedPreference = StyleEnums.LAUNCHED_PREFERENCE_UNSPECIFIED 36 private var effectPreference = StyleEnums.EFFECT_PREFERENCE_UNSPECIFIED 37 private var effectIdHash = 0 38 private var lockWallpaperCategoryHash = 0 39 private var lockWallpaperIdHash = 0 40 private var firstLaunchDateSinceSetup = 0 41 private var firstWallpaperApplyDateSinceSetup = 0 42 private var appLaunchCount = 0 43 private var colorVariant = 0 44 private var timeElapsedMillis = 0L 45 private var effectResultCode = -1 46 <lambda>null47 fun setColorPackageHash(colorPackageHash: Int) = apply { 48 this.colorPackageHash = colorPackageHash 49 } 50 <lambda>null51 fun setFontPackageHash(fontPackageHash: Int) = apply { 52 this.fontPackageHash = fontPackageHash 53 } 54 <lambda>null55 fun setShapePackageHash(shapePackageHash: Int) = apply { 56 this.shapePackageHash = shapePackageHash 57 } 58 <lambda>null59 fun setClockPackageHash(clockPackageHash: Int) = apply { 60 this.clockPackageHash = clockPackageHash 61 } 62 <lambda>null63 fun setLauncherGrid(launcherGrid: Int) = apply { this.launcherGrid = launcherGrid } 64 <lambda>null65 fun setWallpaperCategoryHash(wallpaperCategoryHash: Int) = apply { 66 this.wallpaperCategoryHash = wallpaperCategoryHash 67 } 68 <lambda>null69 fun setWallpaperIdHash(wallpaperIdHash: Int) = apply { 70 this.wallpaperIdHash = wallpaperIdHash 71 } 72 <lambda>null73 fun setColorPreference(colorPreference: Int) = apply { 74 this.colorPreference = colorPreference 75 } 76 <lambda>null77 fun setLocationPreference(locationPreference: Int) = apply { 78 this.locationPreference = locationPreference 79 } 80 <lambda>null81 fun setDatePreference(datePreference: Int) = apply { this.datePreference = datePreference } 82 <lambda>null83 fun setLaunchedPreference(launchedPreference: Int) = apply { 84 this.launchedPreference = launchedPreference 85 } 86 <lambda>null87 fun setEffectPreference(effectPreference: Int) = apply { 88 this.effectPreference = effectPreference 89 } 90 <lambda>null91 fun setEffectIdHash(effectIdHash: Int) = apply { this.effectIdHash = effectIdHash } 92 <lambda>null93 fun setLockWallpaperCategoryHash(lockWallpaperCategoryHash: Int) = apply { 94 this.lockWallpaperCategoryHash = lockWallpaperCategoryHash 95 } 96 <lambda>null97 fun setLockWallpaperIdHash(lockWallpaperIdHash: Int) = apply { 98 this.lockWallpaperIdHash = lockWallpaperIdHash 99 } 100 <lambda>null101 fun setFirstLaunchDateSinceSetup(firstLaunchDateSinceSetup: Int) = apply { 102 this.firstLaunchDateSinceSetup = firstLaunchDateSinceSetup 103 } 104 <lambda>null105 fun setFirstWallpaperApplyDateSinceSetup(firstWallpaperApplyDateSinceSetup: Int) = apply { 106 this.firstWallpaperApplyDateSinceSetup = firstWallpaperApplyDateSinceSetup 107 } 108 <lambda>null109 fun setAppLaunchCount(appLaunchCount: Int) = apply { this.appLaunchCount = appLaunchCount } 110 <lambda>null111 fun setColorVariant(colorVariant: Int) = apply { this.colorVariant = colorVariant } 112 <lambda>null113 fun setTimeElapsed(timeElapsedMillis: Long) = apply { 114 this.timeElapsedMillis = timeElapsedMillis 115 } 116 <lambda>null117 fun setEffectResultCode(effectResultCode: Int) = apply { 118 this.effectResultCode = effectResultCode 119 } 120 lognull121 fun log() { 122 SysUiStatsLog.write( 123 STYLE_UI_CHANGED, 124 action, 125 colorPackageHash, 126 fontPackageHash, 127 shapePackageHash, 128 clockPackageHash, 129 launcherGrid, 130 wallpaperCategoryHash, 131 wallpaperIdHash, 132 colorPreference, 133 locationPreference, 134 datePreference, 135 launchedPreference, 136 effectPreference, 137 effectIdHash, 138 lockWallpaperCategoryHash, 139 lockWallpaperIdHash, 140 firstLaunchDateSinceSetup, 141 firstWallpaperApplyDateSinceSetup, 142 appLaunchCount, 143 colorVariant, 144 timeElapsedMillis, 145 effectResultCode, 146 ) 147 } 148 } 149