Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d727574 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10970117 from 80262ef7 to 24Q1-release

Change-Id: Iebb360daac768220082a15c745f1ac8509b2e06e
parents 7901f741 80262ef7
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import com.android.customization.model.themedicon.data.repository.ThemeIconRepos
import com.android.customization.model.themedicon.domain.interactor.ThemedIconInteractor
import com.android.customization.model.themedicon.domain.interactor.ThemedIconSnapshotRestorer
import com.android.customization.module.logging.ThemesUserEventLogger
import com.android.customization.module.logging.ThemesUserEventLoggerImpl
import com.android.customization.picker.clock.data.repository.ClockPickerRepositoryImpl
import com.android.customization.picker.clock.data.repository.ClockRegistryProvider
import com.android.customization.picker.clock.domain.interactor.ClockPickerInteractor
@@ -72,7 +71,6 @@ import com.android.wallpaper.dispatchers.MainDispatcher
import com.android.wallpaper.module.CustomizationSections
import com.android.wallpaper.module.FragmentFactory
import com.android.wallpaper.module.WallpaperPicker2Injector
import com.android.wallpaper.module.logging.UserEventLogger
import com.android.wallpaper.picker.CustomizationPickerActivity
import com.android.wallpaper.picker.customization.data.content.WallpaperClientImpl
import com.android.wallpaper.picker.customization.data.repository.WallpaperColorsRepository
@@ -92,9 +90,9 @@ internal constructor(
    @MainDispatcher private val mainScope: CoroutineScope,
    @MainDispatcher private val mainDispatcher: CoroutineDispatcher,
    @BackgroundDispatcher private val bgDispatcher: CoroutineDispatcher,
) : WallpaperPicker2Injector(mainScope, bgDispatcher), CustomizationInjector {
    private val userEventLogger: ThemesUserEventLogger,
) : WallpaperPicker2Injector(mainScope, bgDispatcher, userEventLogger), CustomizationInjector {
    private var customizationSections: CustomizationSections? = null
    private var userEventLogger: UserEventLogger? = null
    private var wallpaperInteractor: WallpaperInteractor? = null
    private var keyguardQuickAffordancePickerInteractor: KeyguardQuickAffordancePickerInteractor? =
        null
@@ -166,10 +164,7 @@ internal constructor(

    @Synchronized
    override fun getUserEventLogger(context: Context): ThemesUserEventLogger {
        return userEventLogger as? ThemesUserEventLogger
            ?: ThemesUserEventLoggerImpl(getPreferences(context.applicationContext)).also {
                userEventLogger = it
            }
        return userEventLogger
    }

    override fun getFragmentFactory(): FragmentFactory? {
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.logging

import com.android.internal.logging.InstanceId
import com.android.internal.logging.InstanceIdSequence
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class AppSessionId @Inject constructor() {

    private var sessionId: InstanceId = newInstanceId()

    fun createNewId(): AppSessionId {
        sessionId = newInstanceId()
        return this
    }

    fun getId(): Int {
        return sessionId.hashCode()
    }

    private fun newInstanceId(): InstanceId = InstanceIdSequence(INSTANCE_ID_MAX).newInstanceId()

    companion object {
        // At most 20 bits: ~1m possibilities, ~0.5% probability of collision in 100 values
        private const val INSTANCE_ID_MAX = 1 shl 20
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class SysUiStatsLogger(val action: Int) {
    private var colorVariant = 0
    private var timeElapsedMillis = 0L
    private var effectResultCode = -1
    private var sessionId = 0
    private var appSessionId = 0
    private var setWallpaperEntryPoint =
        STYLE_UICHANGED__SET_WALLPAPER_ENTRY_POINT__SET_WALLPAPER_ENTRY_POINT_UNSPECIFIED
    private var wallpaperDestination =
@@ -133,7 +133,7 @@ class SysUiStatsLogger(val action: Int) {
        this.effectResultCode = effectResultCode
    }

    fun setSessionId(sessionId: Int) = apply { this.sessionId = sessionId }
    fun setAppSessionId(sessionId: Int) = apply { this.appSessionId = sessionId }

    fun setSetWallpaperEntryPoint(@SetWallpaperEntryPoint setWallpaperEntryPoint: Int) = apply {
        this.setWallpaperEntryPoint = setWallpaperEntryPoint
@@ -180,7 +180,7 @@ class SysUiStatsLogger(val action: Int) {
            colorVariant,
            timeElapsedMillis,
            effectResultCode,
            sessionId,
            appSessionId,
            setWallpaperEntryPoint,
            wallpaperDestination,
            colorSource,
+43 −10
Original line number Diff line number Diff line
@@ -31,10 +31,17 @@ import com.android.wallpaper.module.logging.UserEventLogger.EffectStatus
import com.android.wallpaper.module.logging.UserEventLogger.SetWallpaperEntryPoint
import com.android.wallpaper.module.logging.UserEventLogger.WallpaperDestination
import com.android.wallpaper.util.LaunchSourceUtils
import javax.inject.Inject
import javax.inject.Singleton

/** StatsLog-backed implementation of [ThemesUserEventLogger]. */
class ThemesUserEventLoggerImpl(private val preferences: WallpaperPreferences) :
    ThemesUserEventLogger {
@Singleton
class ThemesUserEventLoggerImpl
@Inject
constructor(
    private val preferences: WallpaperPreferences,
    private val appSessionId: AppSessionId,
) : ThemesUserEventLogger {

    override fun logSnapshot() {
        SysUiStatsLogger(StyleEnums.SNAPSHOT)
@@ -48,6 +55,7 @@ class ThemesUserEventLoggerImpl(private val preferences: WallpaperPreferences) :

    override fun logAppLaunched(launchSource: Intent) {
        SysUiStatsLogger(StyleEnums.APP_LAUNCHED)
            .setAppSessionId(appSessionId.createNewId().getId())
            .setLaunchedPreference(launchSource.getAppLaunchSource())
            .log()
    }
@@ -64,6 +72,7 @@ class ThemesUserEventLoggerImpl(private val preferences: WallpaperPreferences) :
        val isHomeWallpaperSet = destination == DEST_HOME_SCREEN || destination == DEST_BOTH
        val isLockWallpaperSet = destination == DEST_LOCK_SCREEN || destination == DEST_BOTH
        SysUiStatsLogger(StyleEnums.WALLPAPER_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setWallpaperCategoryHash(if (isHomeWallpaperSet) categoryHash else 0)
            .setWallpaperIdHash(if (isHomeWallpaperSet) wallpaperIdHash else 0)
            .setLockWallpaperCategoryHash(if (isLockWallpaperSet) categoryHash else 0)
@@ -81,6 +90,7 @@ class ThemesUserEventLoggerImpl(private val preferences: WallpaperPreferences) :
        resultCode: Int
    ) {
        SysUiStatsLogger(StyleEnums.WALLPAPER_EFFECT_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setEffectPreference(status)
            .setEffectIdHash(getIdHashCode(effect))
            .setTimeElapsed(timeElapsedMillis)
@@ -90,6 +100,7 @@ class ThemesUserEventLoggerImpl(private val preferences: WallpaperPreferences) :

    override fun logEffectProbe(effect: String, @EffectStatus status: Int) {
        SysUiStatsLogger(StyleEnums.WALLPAPER_EFFECT_PROBE)
            .setAppSessionId(appSessionId.getId())
            .setEffectPreference(status)
            .setEffectIdHash(getIdHashCode(effect))
            .log()
@@ -101,6 +112,7 @@ class ThemesUserEventLoggerImpl(private val preferences: WallpaperPreferences) :
        timeElapsedMillis: Long
    ) {
        SysUiStatsLogger(StyleEnums.WALLPAPER_EFFECT_FG_DOWNLOAD)
            .setAppSessionId(appSessionId.getId())
            .setEffectPreference(status)
            .setEffectIdHash(getIdHashCode(effect))
            .setTimeElapsed(timeElapsedMillis)
@@ -108,11 +120,11 @@ class ThemesUserEventLoggerImpl(private val preferences: WallpaperPreferences) :
    }

    override fun logResetApplied() {
        SysUiStatsLogger(StyleEnums.RESET_APPLIED).log()
        SysUiStatsLogger(StyleEnums.RESET_APPLIED).setAppSessionId(appSessionId.getId()).log()
    }

    override fun logWallpaperExploreButtonClicked() {
        SysUiStatsLogger(StyleEnums.WALLPAPER_EXPLORE).log()
        SysUiStatsLogger(StyleEnums.WALLPAPER_EXPLORE).setAppSessionId(appSessionId.getId()).log()
    }

    override fun logThemeColorApplied(
@@ -121,6 +133,7 @@ class ThemesUserEventLoggerImpl(private val preferences: WallpaperPreferences) :
        seedColor: Int,
    ) {
        SysUiStatsLogger(StyleEnums.THEME_COLOR_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setColorSource(source)
            .setColorVariant(variant)
            .setSeedColor(seedColor)
@@ -128,40 +141,60 @@ class ThemesUserEventLoggerImpl(private val preferences: WallpaperPreferences) :
    }

    override fun logGridApplied(grid: GridOption) {
        SysUiStatsLogger(StyleEnums.GRID_APPLIED).setLauncherGrid(grid.getLauncherGridInt()).log()
        SysUiStatsLogger(StyleEnums.GRID_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setLauncherGrid(grid.getLauncherGridInt())
            .log()
    }

    override fun logClockApplied(clockId: String) {
        SysUiStatsLogger(StyleEnums.CLOCK_APPLIED).setClockPackageHash(getIdHashCode(clockId)).log()
        SysUiStatsLogger(StyleEnums.CLOCK_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setClockPackageHash(getIdHashCode(clockId))
            .log()
    }

    override fun logClockColorApplied(seedColor: Int) {
        SysUiStatsLogger(StyleEnums.CLOCK_COLOR_APPLIED).setSeedColor(seedColor).log()
        SysUiStatsLogger(StyleEnums.CLOCK_COLOR_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setSeedColor(seedColor)
            .log()
    }

    override fun logClockSizeApplied(@ClockSize clockSize: Int) {
        SysUiStatsLogger(StyleEnums.CLOCK_SIZE_APPLIED).setClockSize(clockSize).log()
        SysUiStatsLogger(StyleEnums.CLOCK_SIZE_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setClockSize(clockSize)
            .log()
    }

    override fun logThemedIconApplied(useThemeIcon: Boolean) {
        SysUiStatsLogger(StyleEnums.THEMED_ICON_APPLIED).setToggleOn(useThemeIcon).log()
        SysUiStatsLogger(StyleEnums.THEMED_ICON_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setToggleOn(useThemeIcon)
            .log()
    }

    override fun logLockScreenNotificationApplied(showLockScreenNotifications: Boolean) {
        SysUiStatsLogger(StyleEnums.LOCK_SCREEN_NOTIFICATION_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setToggleOn(showLockScreenNotifications)
            .log()
    }

    override fun logShortcutApplied(shortcut: String, shortcutSlotId: String) {
        SysUiStatsLogger(StyleEnums.SHORTCUT_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setShortcut(shortcut)
            .setShortcutSlotId(shortcutSlotId)
            .log()
    }

    override fun logDarkThemeApplied(useDarkTheme: Boolean) {
        SysUiStatsLogger(StyleEnums.DARK_THEME_APPLIED).setToggleOn(useDarkTheme).log()
        SysUiStatsLogger(StyleEnums.DARK_THEME_APPLIED)
            .setAppSessionId(appSessionId.getId())
            .setToggleOn(useDarkTheme)
            .log()
    }

    /**
+11 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ import android.content.Context
import com.android.customization.module.CustomizationInjector
import com.android.customization.module.DefaultCustomizationPreferences
import com.android.customization.module.ThemePickerInjector
import com.android.customization.module.logging.ThemesUserEventLogger
import com.android.customization.module.logging.ThemesUserEventLoggerImpl
import com.android.wallpaper.module.logging.UserEventLogger
import dagger.Binds
import dagger.Module
import dagger.Provides
@@ -32,6 +35,14 @@ import javax.inject.Singleton
abstract class AppModule {
    @Binds @Singleton abstract fun bindInjector(impl: ThemePickerInjector): CustomizationInjector

    @Binds
    @Singleton
    abstract fun bindUserEventLogger(impl: ThemesUserEventLoggerImpl): UserEventLogger

    @Binds
    @Singleton
    abstract fun bindThemesUserEventLogger(impl: ThemesUserEventLoggerImpl): ThemesUserEventLogger

    companion object {
        @Provides
        @Singleton
Loading