summaryrefslogtreecommitdiff
path: root/src/com/android/customization/module/SysUiStatsLogger.kt
blob: 318bf1ffd6852cb6d198bb9106a7659cd12adfa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.customization.module

import android.stats.style.StyleEnums
import com.android.systemui.shared.system.SysUiStatsLog
import com.android.systemui.shared.system.SysUiStatsLog.STYLE_UI_CHANGED

/** The builder for [SysUiStatsLog]. */
class SysUiStatsLogger {

    private var atom = STYLE_UI_CHANGED
    private var action = StyleEnums.DEFAULT_ACTION
    private var colorPackageHash = 0
    private var fontPackageHash = 0
    private var shapePackageHash = 0
    private var clockPackageHash = 0
    private var launcherGrid = 0
    private var wallpaperCategoryHash = 0
    private var wallpaperIdHash = 0
    private var colorPreference = 0
    private var locationPreference = StyleEnums.EFFECT_PREFERENCE_UNSPECIFIED
    private var datePreference = StyleEnums.DATE_PREFERENCE_UNSPECIFIED
    private var launchedPreference = StyleEnums.LAUNCHED_PREFERENCE_UNSPECIFIED
    private var effectPreference = StyleEnums.EFFECT_PREFERENCE_UNSPECIFIED
    private var effectIdHash = 0
    private var lockWallpaperCategoryHash = 0
    private var lockWallpaperIdHash = 0
    private var firstLaunchDateSinceSetup = 0
    private var firstWallpaperApplyDateSinceSetup = 0
    private var appLaunchCount = 0
    private var colorVariant = 0
    private var timeElapsedMillis = 0L
    private var effectResultCode = -1

    fun setAction(action: Int) = apply { this.action = action }

    fun setColorPackageHash(color_package_hash: Int) = apply {
        this.colorPackageHash = color_package_hash
    }

    fun setFontPackageHash(font_package_hash: Int) = apply {
        this.fontPackageHash = font_package_hash
    }

    fun setShapePackageHash(shape_package_hash: Int) = apply {
        this.shapePackageHash = shape_package_hash
    }

    fun setClockPackageHash(clock_package_hash: Int) = apply {
        this.clockPackageHash = clock_package_hash
    }

    fun setLauncherGrid(launcher_grid: Int) = apply { this.launcherGrid = launcher_grid }

    fun setWallpaperCategoryHash(wallpaper_category_hash: Int) = apply {
        this.wallpaperCategoryHash = wallpaper_category_hash
    }

    fun setWallpaperIdHash(wallpaper_id_hash: Int) = apply {
        this.wallpaperIdHash = wallpaper_id_hash
    }

    fun setColorPreference(color_preference: Int) = apply {
        this.colorPreference = color_preference
    }

    fun setLocationPreference(location_preference: Int) = apply {
        this.locationPreference = location_preference
    }

    fun setDatePreference(date_preference: Int) = apply { this.datePreference = date_preference }

    fun setLaunchedPreference(launched_preference: Int) = apply {
        this.launchedPreference = launched_preference
    }

    fun setEffectPreference(effect_preference: Int) = apply {
        this.effectPreference = effect_preference
    }

    fun setEffectIdHash(effect_id_hash: Int) = apply { this.effectIdHash = effect_id_hash }

    fun setLockWallpaperCategoryHash(lock_wallpaper_category_hash: Int) = apply {
        this.lockWallpaperCategoryHash = lock_wallpaper_category_hash
    }

    fun setLockWallpaperIdHash(lock_wallpaper_id_hash: Int) = apply {
        this.lockWallpaperIdHash = lock_wallpaper_id_hash
    }

    fun setFirstLaunchDateSinceSetup(first_launch_date_since_setup: Int) = apply {
        this.firstLaunchDateSinceSetup = first_launch_date_since_setup
    }

    fun setFirstWallpaperApplyDateSinceSetup(first_wallpaper_apply_date_since_setup: Int) = apply {
        this.firstWallpaperApplyDateSinceSetup = first_wallpaper_apply_date_since_setup
    }

    fun setAppLaunchCount(app_launch_count: Int) = apply { this.appLaunchCount = app_launch_count }

    fun setColorVariant(color_variant: Int) = apply { this.colorVariant = color_variant }

    fun setTimeElapsed(time_elapsed_millis: Long) = apply {
      this.timeElapsedMillis = time_elapsed_millis
    }

    fun setEffectResultCode(effect_result_code: Int) = apply {
        this.effectResultCode = effect_result_code
    }

    fun log() {
        SysUiStatsLog.write(
            atom,
            action,
            colorPackageHash,
            fontPackageHash,
            shapePackageHash,
            clockPackageHash,
            launcherGrid,
            wallpaperCategoryHash,
            wallpaperIdHash,
            colorPreference,
            locationPreference,
            datePreference,
            launchedPreference,
            effectPreference,
            effectIdHash,
            lockWallpaperCategoryHash,
            lockWallpaperIdHash,
            firstLaunchDateSinceSetup,
            firstWallpaperApplyDateSinceSetup,
            appLaunchCount,
            colorVariant,
            timeElapsedMillis,
            effectResultCode,
        )
    }
}